March 29, 2024, 06:41:07 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Heart Rate Calculator

Started by Doc, December 31, 2011, 11:07:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Doc

Hey folks,
First of all... Happy New Year!

I'm rebuilding a simple little app that I build in another language product, using it to try and get my feet wet with Creative, then maybe IWB2. Although I still have a few tweaks left in order to spruce up the GUI, it's basically function. The one pain in my backside right now is trying to remember how to take care of repainting the screen to avoid residual junk messing things up. Pretty sure it has something to do with @AUTODRAW and/or @IDPAINT, but I can't for the life of me figure how how to implement a correction.

Here is my functional code so far (don't laugh too much... it's been a long while!):
dim max_100, max_90, max_80, max_70, max_60, max_50: int
dim age$: string
dim target:int

def w:window
window w,0,0,543,349,@minbox,0,"Heart Rate Calculator",main
setwindowcolor w,rgb(240,240,240)

control w,"T,Heart Rate Calculator,17,18,495,35,@cteditcenter,1"
setfont w,"verdana",22,700,0,1

control w,"T,100% Of Max,5,80,105,20,@cteditcenter,2"
setfont w,"verdana",10,600,0,2
setcontrolcolor w, 2, rgb(0,0,0), rgb(255,0,0)

control w,"T, 90% Of Max,5,107,105,20,@cteditcenter,3"
setfont w,"verdana",10,600,0,3
setcontrolcolor w, 3, rgb(0,0,0), rgb(255,128,0)

control w,"T, 80% Of Max,5,134,105,20,@cteditcenter,4"
setfont w,"verdana",10,600,0,4
setcontrolcolor w, 4, rgb(0,0,0), rgb(255,200,145)

control w,"T, 70% Of Max,5,161,105,20,@cteditcenter,5"
setfont w,"verdana",10,600,0,5
setcontrolcolor w, 5, rgb(0,0,0), rgb(255,255,0)

control w,"T, 60% Of Max,5,188,105,20,@cteditcenter,6"
setfont w,"verdana",10,600,0,6
setcontrolcolor w, 6, rgb(0,0,0), rgb(255,255,128)

control w,"T, 50% Of Max,5,215,105,20,@cteditcenter,7"
setfont w,"verdana",10,600,0,7
setcontrolcolor w, 7, rgb(0,0,0), rgb(255,255,200)

control w,"E,,115,80,70,20,@cteditcenter,8" :'100%
control w,"E,,115,107,70,20,@cteditcenter,9":'90%
control w,"E,,115,134,70,20,@cteditcenter,10":'80%
control w,"E,,115,161,70,20,@cteditcenter,11":'70%
control w,"E,,115,188,70,20,@cteditcenter,12":'60%
control w,"E,,115,215,70,20,@cteditcenter,13":'50%

control w,"E,,170,288,70,19,@cteditcenter,14":'Age
control w,"T,Enter Your Age:,35,288,120,19,0x5000010B,15"
setfont w,"verdana",10,600,0,15
control w,"B,Calculate,321,288,70,19,0x50000001,16"
setfont w,"verdana",10,550,0,16

control w,"T,VO2 Max (Maximum Effort),190,80,310,20,0x5000010B,17"
setfont w,"verdana",10,600,0,17
control w,"T,Anaerobic (Hardcore Training),190,107,310,20,0x5000010B,18"
setfont w,"verdana",10,600,0,18
control w,"T,Aerobic (Cardio Training - Endurance),190,135,310,20,0x5000010B,19"
setfont w,"verdana",10,600,0,19
control w,"T,Weight Control (Fitness - Fat Burning),190,161,310,20,0x5000010B,20"
setfont w,"verdana",10,600,0,20
control w,"T,Moderate Activity (Maintenance - Warm Up),190,188,340,20,0x5000010B,21"
setfont w,"verdana",10,600,0,21
control w,"T,Light Activity (Warm Up),190,215,310,20,0x5000010B,22"
setfont w,"verdana",10,600,0,22
control w,"C,,10,260,518,59,0x50000007,23"
control w,"C,,10,7,518,52,0x50000007,24"

run = 1

waituntil run = 0
closewindow w

end

sub main

select @class

case @IDcreate
centerwindow w

case @IDcontrol
IF @controlID = 16
gosub DoCalc
endif

case @IDCloseWindow
run = 0
endselect
return

sub DoCalc
age$ = getcontroltext(w,14)
target = val(age$)

max_100 = ((220 - target))
setcontroltext(w,8,str$(max_100))

max_90 = (ceil((220 - target)*.90))
setcontroltext(w,9,str$(max_90))

max_80 = (ceil((220 - target)*.80))
setcontroltext(w,10,str$(max_80))

max_70 = (ceil((220 - target)*.70))
setcontroltext(w,11,str$(max_70))

max_60 = (ceil((220 - target)*.60))
setcontroltext(w,12,str$(max_60))

max_50 = (ceil((220 - target)*.50))
setcontroltext(w,13,str$(max_50))
return


...and I've attached an image so you can see exactly what I'm trying to correct. Any help would be appreciated.

-Doc-

LarryMc

On all the text where you are using a style of 0x5000010B
change them to 0x50000100

For the big title I remarked out these two lines:
'control w,"C,,10,260,518,59,0x50000007,23"
'control w,"C,,10,7,518,52,0x50000007,24"


I didn't check the style flags but I'm guessing they were for a GROUP .

GROUP rectangles were not designed for windows and your problems were typical.
If you converted over to a dialog based app then the group box thing would probably appear ok.

I'm not absolutely sure because I don't use Creative.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

January 01, 2012, 02:15:05 AM #2 Last Edit: January 01, 2012, 02:38:52 AM by aurelCB
Hmm it looks to me like you use static controls for text which is not
properly sized...
I have similiar problems in the past.
Also you add Checkbox controls on wrong place as frame,right?
Better draw frams with RECT.

Doc try this code:
dim max_100, max_90, max_80, max_70, max_60, max_50: int
dim age$: string
dim target:int

def w:window
WINDOW w,0,0,543,349,@minbox,0,"Heart Rate Calculator",main
setwindowcolor w,rgb(240,240,240)

'check this --------------------------------------
Control w,"T,,17,18,495,35,0,1"
SetControlText w,1,"      Heart Rate Calculator"
Setfont w,"Verdana",22,700,0,1
'-------------------------------------------------
'draw frame
RECT w,16,17,497,37

'-------------------------------------------------

control w,"T,100% Of Max,5,80,105,20,0,2"
setfont w,"verdana",10,600,0,2
setcontrolcolor w, 2, rgb(0,0,0), rgb(255,0,0)

control w,"T, 90% Of Max,5,107,105,20,@cteditcenter,3"
setfont w,"verdana",10,600,0,3
setcontrolcolor w, 3, rgb(0,0,0), rgb(255,128,0)

control w,"T, 80% Of Max,5,134,105,20,@cteditcenter,4"
setfont w,"verdana",10,600,0,4
setcontrolcolor w, 4, rgb(0,0,0), rgb(255,200,145)

control w,"T, 70% Of Max,5,161,105,20,@cteditcenter,5"
setfont w,"verdana",10,600,0,5
setcontrolcolor w, 5, rgb(0,0,0), rgb(255,255,0)

control w,"T, 60% Of Max,5,188,105,20,@cteditcenter,6"
setfont w,"verdana",10,600,0,6
setcontrolcolor w, 6, rgb(0,0,0), rgb(255,255,128)

control w,"T, 50% Of Max,5,215,105,20,@cteditcenter,7"
setfont w,"verdana",10,600,0,7
setcontrolcolor w, 7, rgb(0,0,0), rgb(255,255,200)

control w,"E,,115,80,70,20,@cteditcenter,8" :'100%
control w,"E,,115,107,70,20,@cteditcenter,9":'90%
control w,"E,,115,134,70,20,@cteditcenter,10":'80%
control w,"E,,115,161,70,20,@cteditcenter,11":'70%
control w,"E,,115,188,70,20,@cteditcenter,12":'60%
control w,"E,,115,215,70,20,@cteditcenter,13":'50%

control w,"E,,170,288,70,19,@cteditcenter,14":'Age
control w,"T,Enter Your Age:,35,288,120,19,0x5000010B,15"
setfont w,"verdana",10,600,0,15
control w,"B,Calculate,321,288,70,19,0x50000001,16"
setfont w,"verdana",10,550,0,16

'check this---------------------------------------------------
Control w,"T,,190,80,310,20,0,17"
Setfont w,"Verdana",10,600,0,17
SetControlText w,17,"VO2 Max (Maximum Effort)           "
'-------------------------------------------------------------

control w,"T,Anaerobic (Hardcore Training),190,107,310,20,0x5000010B,18"
setfont w,"verdana",10,600,0,18
control w,"T,Aerobic (Cardio Training - Endurance),190,135,310,20,0x5000010B,19"
setfont w,"verdana",10,600,0,19
control w,"T,Weight Control (Fitness - Fat Burning),190,161,310,20,0x5000010B,20"
setfont w,"verdana",10,600,0,20
control w,"T,Moderate Activity (Maintenance - Warm Up),190,188,340,20,0x5000010B,21"
setfont w,"verdana",10,600,0,21
control w,"T,Light Activity (Warm Up),190,215,310,20,0x5000010B,22"
setfont w,"verdana",10,600,0,22
'control w,"C,,10,260,518,59,0x50000007,23"
'control w,"C,,10,7,518,52,0x50000007,24"

run = 1

waituntil run = 0
closewindow w

end

sub main

select @class

case @IDcreate
centerwindow w

case @IDcontrol
IF @controlID = 16
gosub DoCalc
endif

case @IDCloseWindow
run = 0
endselect
return

sub DoCalc
age$ = getcontroltext(w,14)
target = val(age$)

max_100 = ((220 - target))
setcontroltext(w,8,str$(max_100))

max_90 = (ceil((220 - target)*.90))
setcontroltext(w,9,str$(max_90))

max_80 = (ceil((220 - target)*.80))
setcontroltext(w,10,str$(max_80))

max_70 = (ceil((220 - target)*.70))
setcontroltext(w,11,str$(max_70))

max_60 = (ceil((220 - target)*.60))
setcontroltext(w,12,str$(max_60))

max_50 = (ceil((220 - target)*.50))
setcontroltext(w,13,str$(max_50))
return


So just made changes and will look like you wish...
Aurel

Doc

Thanks for the help folks!

Larry offered:
Quote
On all the text where you are using a style of 0x5000010B
change them to 0x50000100

Which did in fact take care of the problem for all of the static text controls.
I just used the flags that were generated using the dialog editor and had no idea it would cause a problem when converting from a dialog to a window. (Live and learn, I guess.)

Aurel says:
QuoteBetter draw frams with RECT.

...replacing the group controls with Aurel's rect did the trick for the other stuff -and- it looks better anyway. :)

I guess I'm a happy camper and will post the finished results here after I've had time to do the final tweaking for the GUI.

-Doc-

Techno

Hi Aurel,

Can you please this converted this application IWB Professional because I'm programming only in the IWB v2.0 Professsional.

I'm very interested in your roulette application.

Kind regards
Stephane

Quote from: aurelCB on January 01, 2012, 02:15:05 AM
Hmm it looks to me like you use static controls for text which is not
properly sized...
I have similiar problems in the past.
Also you add Checkbox controls on wrong place as frame,right?
Better draw frams with RECT.

Doc try this code:
dim max_100, max_90, max_80, max_70, max_60, max_50: int
dim age$: string
dim target:int

def w:window
WINDOW w,0,0,543,349,@minbox,0,"Heart Rate Calculator",main
setwindowcolor w,rgb(240,240,240)

'check this --------------------------------------
Control w,"T,,17,18,495,35,0,1"
SetControlText w,1,"      Heart Rate Calculator"
Setfont w,"Verdana",22,700,0,1
'-------------------------------------------------
'draw frame
RECT w,16,17,497,37

'-------------------------------------------------

control w,"T,100% Of Max,5,80,105,20,0,2"
setfont w,"verdana",10,600,0,2
setcontrolcolor w, 2, rgb(0,0,0), rgb(255,0,0)

control w,"T, 90% Of Max,5,107,105,20,@cteditcenter,3"
setfont w,"verdana",10,600,0,3
setcontrolcolor w, 3, rgb(0,0,0), rgb(255,128,0)

control w,"T, 80% Of Max,5,134,105,20,@cteditcenter,4"
setfont w,"verdana",10,600,0,4
setcontrolcolor w, 4, rgb(0,0,0), rgb(255,200,145)

control w,"T, 70% Of Max,5,161,105,20,@cteditcenter,5"
setfont w,"verdana",10,600,0,5
setcontrolcolor w, 5, rgb(0,0,0), rgb(255,255,0)

control w,"T, 60% Of Max,5,188,105,20,@cteditcenter,6"
setfont w,"verdana",10,600,0,6
setcontrolcolor w, 6, rgb(0,0,0), rgb(255,255,128)

control w,"T, 50% Of Max,5,215,105,20,@cteditcenter,7"
setfont w,"verdana",10,600,0,7
setcontrolcolor w, 7, rgb(0,0,0), rgb(255,255,200)

control w,"E,,115,80,70,20,@cteditcenter,8" :'100%
control w,"E,,115,107,70,20,@cteditcenter,9":'90%
control w,"E,,115,134,70,20,@cteditcenter,10":'80%
control w,"E,,115,161,70,20,@cteditcenter,11":'70%
control w,"E,,115,188,70,20,@cteditcenter,12":'60%
control w,"E,,115,215,70,20,@cteditcenter,13":'50%

control w,"E,,170,288,70,19,@cteditcenter,14":'Age
control w,"T,Enter Your Age:,35,288,120,19,0x5000010B,15"
setfont w,"verdana",10,600,0,15
control w,"B,Calculate,321,288,70,19,0x50000001,16"
setfont w,"verdana",10,550,0,16

'check this---------------------------------------------------
Control w,"T,,190,80,310,20,0,17"
Setfont w,"Verdana",10,600,0,17
SetControlText w,17,"VO2 Max (Maximum Effort)           "
'-------------------------------------------------------------

control w,"T,Anaerobic (Hardcore Training),190,107,310,20,0x5000010B,18"
setfont w,"verdana",10,600,0,18
control w,"T,Aerobic (Cardio Training - Endurance),190,135,310,20,0x5000010B,19"
setfont w,"verdana",10,600,0,19
control w,"T,Weight Control (Fitness - Fat Burning),190,161,310,20,0x5000010B,20"
setfont w,"verdana",10,600,0,20
control w,"T,Moderate Activity (Maintenance - Warm Up),190,188,340,20,0x5000010B,21"
setfont w,"verdana",10,600,0,21
control w,"T,Light Activity (Warm Up),190,215,310,20,0x5000010B,22"
setfont w,"verdana",10,600,0,22
'control w,"C,,10,260,518,59,0x50000007,23"
'control w,"C,,10,7,518,52,0x50000007,24"

run = 1

waituntil run = 0
closewindow w

end

sub main

select @class

case @IDcreate
centerwindow w

case @IDcontrol
IF @controlID = 16
gosub DoCalc
endif

case @IDCloseWindow
run = 0
endselect
return

sub DoCalc
age$ = getcontroltext(w,14)
target = val(age$)

max_100 = ((220 - target))
setcontroltext(w,8,str$(max_100))

max_90 = (ceil((220 - target)*.90))
setcontroltext(w,9,str$(max_90))

max_80 = (ceil((220 - target)*.80))
setcontroltext(w,10,str$(max_80))

max_70 = (ceil((220 - target)*.70))
setcontroltext(w,11,str$(max_70))

max_60 = (ceil((220 - target)*.60))
setcontroltext(w,12,str$(max_60))

max_50 = (ceil((220 - target)*.50))
setcontroltext(w,13,str$(max_50))
return


So just made changes and will look like you wish...
Aurel

ZeroDog

April 08, 2012, 09:08:11 PM #5 Last Edit: April 08, 2012, 09:12:36 PM by ZeroDog
Converted to IWBasic:

dim max_100, max_90, max_80, max_70, max_60, max_50: int
dim age$: string
dim target:int

def w:window
OPENWINDOW w,0,0,543,349,@minbox|@caption,0,"Heart Rate Calculator",&main
setwindowcolor w,rgb(240,240,240)

'check this --------------------------------------
Control w,@STATIC,"",17,18,495,35,0,1
SetControlText w,1,"      Heart Rate Calculator"
Setfont w,"Verdana",22,700,0,1
'-------------------------------------------------
'draw frame
RECT w,16,17,497,37

'-------------------------------------------------

control w,@STATIC,"100% Of Max",5,80,105,20,0,2
setfont w,"verdana",10,600,0,2
setcontrolcolor w, 2, rgb(0,0,0), rgb(255,0,0)

control w,@STATIC, "90% Of Max",5,107,105,20,@cteditcenter,3
setfont w,"verdana",10,600,0,3
setcontrolcolor w, 3, rgb(0,0,0), rgb(255,128,0)

control w,@STATIC, "80% Of Max",5,134,105,20,@cteditcenter,4
setfont w,"verdana",10,600,0,4
setcontrolcolor w, 4, rgb(0,0,0), rgb(255,200,145)

control w,@STATIC, "70% Of Max",5,161,105,20,@cteditcenter,5
setfont w,"verdana",10,600,0,5
setcontrolcolor w, 5, rgb(0,0,0), rgb(255,255,0)

control w,@STATIC, "60% Of Max",5,188,105,20,@cteditcenter,6
setfont w,"verdana",10,600,0,6
setcontrolcolor w, 6, rgb(0,0,0), rgb(255,255,128)

control w,@STATIC, "50% Of Max",5,215,105,20,@cteditcenter,7
setfont w,"verdana",10,600,0,7
setcontrolcolor w, 7, rgb(0,0,0), rgb(255,255,200)

control w,@EDIT,"",115,80,70,20,@cteditcenter,8 :'100%
control w,@EDIT,"",115,107,70,20,@cteditcenter,9:'90%
control w,@EDIT,"",115,134,70,20,@cteditcenter,10:'80%
control w,@EDIT,"",115,161,70,20,@cteditcenter,11:'70%
control w,@EDIT,"",115,188,70,20,@cteditcenter,12:'60%
control w,@EDIT,"",115,215,70,20,@cteditcenter,13:'50%

control w,@EDIT,"",170,288,70,19,@cteditcenter,14:'Age
control w,@STATIC,"Enter Your Age:",35,288,130,19,0x50000100,15
setfont w,"verdana",10,600,0,15
control w,@BUTTON,"Calculate",321,288,70,19,0x50000001,16
setfont w,"verdana",10,550,0,16

'check this---------------------------------------------------
Control w,@STATIC,"",190,80,310,20,0,17
Setfont w,"Verdana",10,600,0,17
SetControlText w,17,"VO2 Max (Maximum Effort)           "
'-------------------------------------------------------------

control w,@STATIC,"Anaerobic (Hardcore Training)",190,107,310,20,0x50000100,18
setfont w,"verdana",10,600,0,18
control w,@STATIC,"Aerobic (Cardio Training - Endurance)",190,135,310,20,0x50000100,19
setfont w,"verdana",10,600,0,19
control w,@STATIC,"Weight Control (Fitness - Fat Burning)",190,161,310,20,0x50000100,20
setfont w,"verdana",10,600,0,20
control w,@STATIC,"Moderate Activity (Maintenance - Warm Up)",190,188,340,20,0x50000100,21
setfont w,"verdana",10,600,0,21
control w,@STATIC,"Light Activity (Warm Up)",190,215,310,20,0x50000100,22
setfont w,"verdana",10,600,0,22
'control w,"C,,10,260,518,59,0x50000007,23"
'control w,"C,,10,7,518,52,0x50000007,24"

run = 1

waituntil run = 0
closewindow w

end

sub main(),int

select @class

case @IDcreate
centerwindow w

case @IDcontrol
IF @controlID = 16
gosub DoCalc
endif

case @IDCloseWindow
run = 0
endselect
return 0
endsub

sub DoCalc
age$ = getcontroltext(w,14)
target = val(age$)

max_100 = ((220 - target))
setcontroltext(w,8,str$(max_100))

max_90 = (ceil((220 - target)*.90))
setcontroltext(w,9,str$(max_90))

max_80 = (ceil((220 - target)*.80))
setcontroltext(w,10,str$(max_80))

max_70 = (ceil((220 - target)*.70))
setcontroltext(w,11,str$(max_70))

max_60 = (ceil((220 - target)*.60))
setcontroltext(w,12,str$(max_60))

max_50 = (ceil((220 - target)*.50))
setcontroltext(w,13,str$(max_50))
return
endsub