PDA

View Full Version : simple "calendar / datetime" example



largo_winch
19-12-2011, 11:24
this is a little control example for datetime with calendar. it's possible to change the colour of the calendar background or text (font) style? it's always a red border around date and blue background for current date. control set color doesn't work as this control (SysDateTimePick32) hasn't access to canvas module?


' Empty GUI script created on 12-19-2011 10:14:10 by largo_winch (ThinAIR)
'---------> datetime control for UI/canvas :

Uses "UI"

' -- ID numbers of controls
Begin ControlID
%cCanvasDB
%bModifyBitmap
%bClose
%ID_Date
End ControlID

' -- Create dialog here
FUNCTION TBMAIN()
LOCAL hDlg AS DWORD

Dialog New 0, "simple canvas calendar example",-1,-1, 200, 140, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION OR _
%WS_SYSMENU Or %WS_MINIMIZEBOX, 0 To hDlg
Dim cx, cy As Long
dialog pixels hDlg, 200, 200 to units cx, cy
Control Add Canvas, hDlg, %cCanvasDB, "", 5, 5, cx, cy
Control ADD BUTTON, hDlg, %bClose, "Close", 10+cx, cy+5-14, 50, 14, Call bCloseProc

Control Add "SysDateTimePick32", hDlg, %ID_Date, _
"SysDateTimePick32", 10, 20, 70, 14, %WS_CHILD Or %WS_VISIBLE Or _
%WS_TABSTOP Or %DTS_SHORTDATEFORMAT, %WS_EX_CLIENTEDGE Or _
%WS_EX_LEFT Or %WS_EX_LTRREADING Or %WS_EX_RIGHTSCROLLBAR

'Control Set Color hDlg, %ID_Date, -1, %RED 'always red border with blue background?
'Control Set Color hDlg, %ID_Date, %GREEN, %YELLOW

Control Set Color hDlg, %ID_Date, Rgb(200,100,0), %YELLOW
Control Redraw hDlg, %ID_Date

Dialog Show Modal hDlg, Call dlgProc

END FUNCTION

' -- Callback for dialog
CALLBACK FUNCTION dlgProc()

' -- Test for messages
SELECT CASE CBMSG
Case %WM_INITDIALOG
CANVAS_Attach(CBHNDL, %cCanvasDB, %FALSE)
DrawGraphics()
CANVAS_Redraw

CASE %WM_CLOSE
' -- Put code to be executed before dialog end here

END SELECT

END FUNCTION

' -- Callback for close button
CallBack Function bCloseProc()

If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
DIALOG END CBHNDL
END IF
END IF

End Function


SUB DrawGraphics()

Canvas_Color Rgb(128, 255, 0), Rgb(0, 0, 0)
Canvas_Clear(Rgb(250,250,250))
Canvas_Scale Pixels

END SUB


bye, largo