IonicWind Software

Creative Basic => GUI Programs => Topic started by: Egil on April 29, 2017, 05:31:02 AM

Title: Resizing an Edit Control?
Post by: Egil on April 29, 2017, 05:31:02 AM
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
Title: Re: Resizing an Edit Control?
Post by: Egil on April 29, 2017, 08:19:13 AM
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