Eventhandling for the SysDateTimePick32 (DatePicker)
Posted: Sun Aug 15, 2004 7:42 pm
Hi,
this code shows how you can work with the events from the SysDateTimePick32. I hope is usefull!
CU
Michael
this code shows how you can work with the events from the SysDateTimePick32. I hope is usefull!
Code: Select all
; Eventhandling DatePicker (SysDateTimePick32)
; Forum : German
; Author: zomtex2003 (Michael Eberhardt)
; Date : 18.08.2004
#MCM_GETCURSEL = $1001
#DTN_DATETIMECHANGE = #DTN_FIRST + 1
#DTN_DROPDOWN = #DTN_FIRST + 6
#DTN_CLOSEUP = #DTN_FIRST + 7
#MYWINDOWSTYLE = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
#PICKERSTYLE = #WS_CHILD | #WS_VISIBLE | 12
Declare MyWindowCallback(hwnd, msg, wParam, lParam)
Structure INITCOMMONCONTROLSEX
dwSize.l
dwICC.l
EndStructure
Global hMyDatePicker.l
InitICC.INITCOMMONCONTROLSEX
InitICC\dwSize = SizeOf(INITCOMMONCONTROLSEX)
InitICC\dwICC = #ICC_DATE_CLASSES
InitCommonControlsEx_(InitICC)
If OpenWindow(0, 0, 0, 150, 25 , #MYWINDOWSTYLE, "DatePicker")
If CreateGadgetList(WindowID())
hMyDatePicker = CreateWindowEx_(0, "SysDateTimePick32", "Date", #PICKERSTYLE, 0, 0, 100, 25, WindowID() ,0 ,GetModuleHandle_(0), 0)
EndIf
SetWindowCallback(@MyWindowCallback())
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
EndIf
End
Procedure MyWindowCallback(hwnd, msg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select(msg)
Case #WM_NOTIFY
*MySystemTime.SYSTEMTIME
*lpnmhdr.NMHDR
*lpnmhdr = lParam
If *lpnmhdr\hwndFrom = hMyDatePicker
Select(*lpnmhdr\code)
Case #DTN_DROPDOWN
Debug "DatePicker opened"
Case #DTN_CLOSEUP
SendMessage_(hMyDatePicker, #MCM_GETCURSEL, 0, @CurDate.SYSTEMTIME)
MessageRequester("Finish DatePicker", Str(CurDate\wDay) + "." + Str(CurDate\wMonth) + "." + Str(CurDate\wYear), #MB_ICONINFORMATION)
Debug "DatePicker closed"
Case #DTN_DATETIMECHANGE
*lpChange.NMDATETIMECHANGE = lParam
*MySystemTime = *lpChange\st
Debug "choosed date:" + Str(*MySystemTime\wDay) + "." + Str(*MySystemTime\wMonth) + "." + Str(*MySystemTime\wYear)
EndSelect
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
Michael