Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
InitUpDownControl Increment
#1
Gin, How to set InitUpDownControl with increment 0.01 (2 Digits) and 10 (Multiple 10)?
Thanks
#2
Don't use InitUpDownControl. Your dialog function must process UDN_DELTAPOS message and change edit control text.

Function dialog_with_updown2
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str e3
e3=0
if(!ShowDialog("dialog_with_updown2" &dialog_with_updown2 &controls)) ret

;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Edit 0x54030080 0x204 16 28 32 13 ""
;4 msctls_updown32 0x54000082 0x4 50 26 11 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010703 "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.idFrom
,case 4
,sel nh.code
,,case UDN_DELTAPOS
,,ret UdIncrement(nh 3 0.01 0 100) ;;0.01 is step. change it
,,
Function UdIncrement
Code:
Copy      Help
;/
function# NMHDR*nh idEdit double'step [double'rangeMin] [double'rangeMax]


NMUPDOWN* nu=+nh
;out "%i %i" nu.iPos nu.iDelta ;; :)
int hDlg=GetParent(nh.hwndFrom)
int buddy=id(idEdit hDlg)
double _d=val(_s.getwintext(buddy) 2)
_d-step*nu.iDelta
if(rangeMin or rangeMax)
,if(_d<rangeMin) _d=rangeMin
,if(_d>rangeMax) _d=rangeMax
_s=_d; _s.setwintext(buddy)
ret DT_Ret(hDlg 1)
#3
can this go into negatives?
#4
pass negative rangeMin
or don't use rangeMin and rangeMax. Then the function will not limit the value.
#5
Ok, that works.. many thanks Gin.
#6
ok thanks gint.


Forum Jump:


Users browsing this thread: 1 Guest(s)