I'm having some trouble making controls in a for/next statement. I can make 12 controls per loop at a time and that is it. Look at my code and tell me what I'm doing wrong please.
$INCLUDE "windowssdk.inc"
int MaxRows,t,l,w,h,i
string cLine 'string to store communication info
window w1
OPENWINDOW w1,0,0,350,350,@MINBOX|@MAXBOX|@SIZE|@MAXIMIZED,0,"Monitor",&main
SETWINDOWCOLOR w1,RGB(200,200,200)
SETFONT w1,"Times New Roman",20,500
BACKPEN w1,RGB(200,200,200)
PrintText(w1,"DO",150,20,2)
PrintText(w1,"Temp",240,20,2)
PrintText(w1,"Batt",330,20,2)
PrintText(w1,"Mv",420,20,2)
GETCLIENTSIZE w1,l,t,w,h
MaxRows=(h-50)/40+1
t=1
for i=50 to (MaxRows*40) step 40
'CONTROL w1,@EDIT,"Name",10,i,100,35,@CTEDITCENTER|@CTEDITRO,t 'if this is uncommented, it will not work
'SETFONT w1,"Times New Roman", 20,400,0,t 'I really need about 8 more controls per line
't++
CONTROL w1,@EDIT,"25.5",110,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@EDIT,"78",200,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@EDIT,"12.9",290,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@EDIT,"35.2",380,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@EDIT,"99.9",470,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@BUTTON,"On",550,i,30,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
t++
CONTROL w1,@BUTTON,"Off",580,i,30,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
t++
CONTROL w1,@BUTTON,"AUTO",550,i+18,60,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
SETCONTROLCOLOR w1,t,0,RGB(255,255,0)
t++
CONTROL w1,@EDIT,"99.9",620,i,80,35,@CTEDITCENTER|@CTEDITRO,t
SETFONT w1, "Times New Roman", 20, 500,0,t
t++
CONTROL w1,@BUTTON,"On",700,i,30,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
t++
CONTROL w1,@BUTTON,"Off",730,i,30,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
t++
CONTROL w1,@BUTTON,"AUTO",700,i+18,60,17,@CTLBTNDEFAULT,t
SETFONT w1, "Times New Roman", 8, 400,0,t
SETCONTROLCOLOR w1,t,0,RGB(255,255,0)
t++
next i
WAITUNTIL w1=0
END
SUB main
int RowNum,idtype
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
CLOSEWINDOW w1
case @IDCONTROL
RowNum=((@CONTROLID-1)/12)
idtype= (@CONTROLID-1) % 12
SELECT idtype
CASE 0 'oxy
case 1 'temp
CASE 2 'batt
CASE 3 'mv
CASE 4 'amp1
CASE 5 'amp1 ON
CASE& 9
IF GETCONTROLTEXT(w1,@CONTROLID)="On"
SETCONTROLTEXT w1,@CONTROLID,"ON"
SETCONTROLCOLOR w1,@CONTROLID,0,rgb(0,255,0)
ENDIF
SETCONTROLTEXT w1,@CONTROLID+1,"Off"
SETCONTROLCOLOR w1,@CONTROLID+1,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID+2,"Auto"
SETCONTROLCOLOR w1,@CONTROLID+2,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID-5-(idtype-5),STR$(RowNum)
CASE 6 'amp1 OFF
case& 10
IF GETCONTROLTEXT (w1,@CONTROLID)="Off"
SETCONTROLTEXT w1,@CONTROLID,"OFF"
SETCONTROLCOLOR w1,@CONTROLID,RGB(255,255,255),rgb(255,0,0)
ENDIF
SETCONTROLTEXT w1,@CONTROLID-1,"On"
SETCONTROLCOLOR w1,@CONTROLID-1,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID+1,"Auto"
SETCONTROLCOLOR w1,@CONTROLID+1,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID-6-(idtype-6),STR$(RowNum)
CASE 7 'amp1 AUTO
CASE& 11
IF GETCONTROLTEXT(w1,@CONTROLID)="Auto"
SETCONTROLTEXT w1,@CONTROLID,"AUTO"
SETCONTROLCOLOR w1,@CONTROLID,0,RGB(255,255,0)
ENDIF
SETCONTROLTEXT w1,@CONTROLID-1,"Off"
SETCONTROLCOLOR w1,@CONTROLID-1,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID-2,"On"
SETCONTROLCOLOR w1,@CONTROLID-2,0,rgb(225,225,225)
SETCONTROLTEXT w1,@CONTROLID-7-(idtype-7),STR$(RowNum)
ENDSELECT
ENDSELECT
ENDSUB
SUB PrintText(window w,string txt,int x,int y,int pos)
int pw,ph,px,py
GETTEXTSIZE w,txt,pw,ph
py=y:px=x
SELECT pos
CASE 0 'left
py-=ph/2
CASE 1 'right
px-=pw
py-=ph/2
CASE 2 'center
px-=pw/2
py-=ph/2
DEFAULT 'where it is
ENDSELECT
MOVE w,px,py
PRINT w,txt
ENDSUB
Thanks,
Clint
Found out what it was. Every time a control is added, a windows message is sent. I hadn't updated the number of controls in my formulas in the message handler. :-[
Clint
Thanks Clint, for letting everyone know you found your problem, and even more so that you let us know what it was. :) :)
LarryMc
Sadly sometimes the only way to find your own problems is to show them to everyone else. It can be embarrassing but effective ;)
Easy to over look though.