Restored from previous forum. Originally posted by Danilo.
Some weeks ago somebody in the german forum
asked how to use the UpDownControl for a
reboot-window and i came up with this little
example:
Code: Select all
; Example
#UPDOWN = #WS_CHILD | #WS_VISIBLE
If OpenWindow(0,100,100,200,45, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget,"Test")
If CreateGadgetList(WindowID())
shwn = TextGadget(1,20,13,145,120,"Shutdown PC after 01 minute")
uhwn = CreateUpDownControl_(#UPDOWN,175,10,10,20,WindowID(),1,GetModuleHandle_(#NULL),shwn,0,0,1)
EndIf
EndIf
;
; Constants
;
#UDM_SETRANGE32 = $400+111
#UDM_GETPOS32 = $400+114
;
; Set Minimum und Maximum ( 1 - 60 )
;
SendMessage_(uhwn, #UDM_SETRANGE32,1,60)
;
; Window Callback
;
Procedure WindowCallback(hWindow, Message, wParam, lParam)
Shared uhwn
Shared pos
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_VSCROLL ; Vertical Scroll Message
If lParam = uhwn ; checked only when it comes
; from Window "uhwn" (UpDown Control)
pos = SendMessage_(uhwn, #UDM_GETPOS32, 0,@pfError) ; Get Position
If pfError
If pos = 1 ; set new Gadget Text
; If value is "1", add a "0"
SetGadgetText(1,"Shutdown PC after 01 minute") ; before.
Else ; "01 minute" -> "02 minutes"
position$ = Str(pos)
If Len(position$) < 2: position$ = "0"+position$:EndIf
SetGadgetText(1,"Shutdown PC after "+position$+" minutes")
EndIf
EndIf
Result = 1
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
SetWindowCallback(@WindowCallback())
;
; Event Loop
;
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow
End
EndSelect
ForEver
Maybe that helps too - as a little example.
cya,
...Danilo
(registered PureBasic user)