April 23, 2024, 06:19:35 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Resizing an Edit Control?

Started by Egil, April 29, 2017, 05:31:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

When trying to resize an Edit Control automaticly by using SETSIZE when the Window size has changed, the control is not found.
Must be doing something wrong, but I'm not able to see it. Any suggestions???

Egil


PS: Works the same way in all versions of CB...




AutoDefine "Off"

def win:window
def wstyle:int
def cleft,ctop,cwidth,cheight:int :'Clientarea
def run:int 

wstyle = @SIZE|@MINBOX|@MAXBOX

Window win,-640,0,640,500,wstyle,0,"test",MainLoop
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
SETWINDOWCOLOR win,RGB(240,202,86)

CONTROL win,"E,,170,40,cwidth-180,cheight-50,0,10" :' Edit Control

run=1

WAITUNTIL run = 0 
CLOSEWINDOW win 
END 

'
SUB MainLoop()
'-------------------------------------------------------------------------------------
SELECT @class

CASE @idcreate 
centerwindow win 

CASE @idclosewindow 
run = 0 

CASE @idsize
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
SETSIZE win,170,40,cwidth-180,cheight-50,10 :' Resizing Edit Control

ENDSELECT 
RETURN
Support Amateur Radio  -  Have a ham  for dinner!

Egil

Maybe my granddaughter is right when she says I am way too old...


I suddenly remembered that I had this resize "problem" before. To get rid of the error message, I had to let the program see that the control existed.
Here is how it was done:
CASE @idsize
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
if CONTROLEXISTS(win,10)
SETSIZE win,170,40,cwidth-180,cheight-50,10 :' Resizing Edit Control
endif


The full working example is shown below.



Have  fun!

Egil





AutoDefine "Off"

def wstyle:int
wstyle = @SIZE|@MINBOX|@MAXBOX

def win:window 

def cleft,ctop,cwidth,cheight:int :'Clientarea
def run:int 

Window win,-640,0,640,500,wstyle,0,"test",MainLoop
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
SETWINDOWCOLOR win,RGB(240,202,86)

CONTROL win,"E,,170,40,cwidth-180,cheight-50,0,10" :' Edit Control

run=1

WAITUNTIL run = 0 
CLOSEWINDOW win 
END 

'
SUB MainLoop()
'-------------------------------------------------------------------------------------
SELECT @class

CASE @idcreate 
centerwindow win 

CASE @idclosewindow 
run = 0 

CASE @idsize
GETCLIENTSIZE win,cleft,ctop,cwidth,cheight
if CONTROLEXISTS(win,10)
SETSIZE win,170,40,cwidth-180,cheight-50,10 :' Resizing Edit Control
endif

ENDSELECT 
RETURN


Support Amateur Radio  -  Have a ham  for dinner!