04-20-2005, 07:32 PM
You need a smart dialog. Example:
Function dialog_with_date_picker:
Three date-time picker controls of different styles. Paste this code using menu Edit -> Other formats -> Paste escaped.
Macro:
Function dialog_with_date_picker:
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
def DTM_FIRST 0x1000
def DTM_GETSYSTEMTIME (DTM_FIRST + 1)
def DTM_SETSYSTEMTIME (DTM_FIRST + 2)
;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 SysDateTimePick32 0x54000000 0x204 8 10 110 14 ""
;4 SysDateTimePick32 0x54000001 0x204 8 32 110 14 ""
;5 SysDateTimePick32 0x54000009 0x204 8 54 110 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010601 "" ""
ret
;messages
SYSTEMTIME- t_st1 t_st2 t_st3
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,;here can be initialized using DTM_SETSYSTEMTIME
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
int ctrlid=wParam&0xFFFF; message=wParam>>16
sel wParam
,case IDOK
,DT_Ok hDlg
,SendMessage(id(3 hDlg) DTM_GETSYSTEMTIME 0 &t_st1)
,SendMessage(id(4 hDlg) DTM_GETSYSTEMTIME 0 &t_st2)
,SendMessage(id(5 hDlg) DTM_GETSYSTEMTIME 0 &t_st3)
,
,case IDCANCEL DT_Cancel hDlg
ret 1
Three date-time picker controls of different styles. Paste this code using menu Edit -> Other formats -> Paste escaped.
Macro:
SYSTEMTIME- t_st1 t_st2 t_st3 ;;we share these variables with the dialog procedure
if(!ShowDialog("dialog_with_date_picker" &dialog_with_date_picker)) ret
DATE d.fromsystemtime(t_st1) ;;convert to DATE (for easy display)
str s=d
out s
;display date and time separately
DATE d2
int i=d.date ;;get integer part, that is date
d2=i
out d2
d2=d.date-i ;;get fractional part, that is time
out d2
;other two controls
d.fromsystemtime(t_st2)
out d
d.fromsystemtime(t_st3)
out d