Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

spin controls in dialogs

Intel_C_Intel
Employee
449 Views
hi,
i coded a nice spin control dialog example here. but i have a problem. i couldnt stop the spin values when they come to max range or min range. you will see it. they exceed the value i assigned...
thank you
0 Kudos
2 Replies
Intel_C_Intel
Employee
449 Views
hi,

i am still trying to slove the problem. but no success:( whenever i put a remark on "set buddy integer" in the style menu of spin controls it works fine. but step is 1. i dont want this. as i remember Jugoslov had told me to add logic to check min/max value. what does that mean? i couldnt teach the spin control to stop when it comes to the min/max value. how can i do that?

thank you...
0 Kudos
Jugoslav_Dujic
Valued Contributor II
449 Views
"Set buddy integer" style means that "buddy" edit control is set to accept only integers; you don't want that, as Windows "doesn't know" about real numbers.

What I meant is to simply add validation logic before filling in the edit box, i.e. insert:
pos = min(10., max(0., pos))
write(text, "(f6.2)") pos


Since your edit boxes are not read-only, it would be a good idea to add some validation code in case user types in the number. You could add a LOSEFOCUS callback to edit box to verify whether the number is correct and within range:
i = DlgSetSub(Dlg, IDC_EDIT1, OnEdit1, DLG_LOSEFOCUS)
...
subroutine OnEdit1(Dlg, id, iEvent)
...
real:: pos
character(20):: text
i = DlgGet(Dlg, id, Text, DLG_STATE)
read(Text,*,iostat = iErr) pos
if (iErr.ne.0) then
   !The number is invalid. Do some kind of error handling:
   i = DlgSet(Dlg, id, "0.")
else
   !Check if it's within range
   pos = max(pos, 0.)
   pos = min(pos, 10.)
   write(text, "(f6.2)") pos   
   status = DlgSet(dlg, IDC_EDIT1, adjustl(text))
end if
Jugoslav





0 Kudos
Reply