|
Development | .NET Compact Framework
Free DateTimePicker for Compact Framework
Written by Carole Mitchell
[author's bio]
[read 66573 times]
Edited by Derek
Page 1
Page 2
Page 3
5. In the form_load
event place the following code:
Me.Text = "Form1"
'Set the text of the panel to a unique string
'so that the Load_DTPicker routines
'can find the control on this form.
pnlStartDate.Text = "pnlStartDate"
Form_hWnd = FindWindow(Nothing, Me.Text.ToCharArray)
pStartDate_hWnd = Load_DTPicker(Form_hWnd, pnlStartDate.Text,
_
pnlStartDate.Size.Width, pnlStartDate.Size.Height)
If IntPtr.Zero.Equals(pStartDate_hWnd) Then
MessageBox.Show("DateTimePicker control couldn't be
created")
Else
SetDTP_Format(pStartDate_hWnd, "MM/dd/yyyy")
'Set Date to today's date
DTPicker_SetDate(pStartDate_hWnd, Now.ToShortDateString)
End If
pEndDate_hWnd = Load_DTPicker(Form_hWnd,
pnlEndDate.Text, _
pnlEndDate.Size.Width, pnlEndDate.Size.Height)
If IntPtr.Zero.Equals(pEndDate_hWnd) Then
MessageBox.Show("End DateTime Picker control couldn't
be created")
Else
SetDTP_Format(pEndDate_hWnd, "MM/dd/yyyy")
'Set Date to today's date
DTPicker_SetDate(pEndDate_hWnd, Now.ToShortDateString)
End If
6. In button1_click place the following
code:
Dim DTP_SDate,
DTP_EDate As DateTime
DTP_SDate = getDTP_Time(pStartDate_hWnd)
DTP_EDate = getDTP_Time(pEndDate_hWnd)
MessageBox.Show("Start date is " & DTP_SDate
& _
" and end date is " & DTP_EDate)
7. Place these general declarations
in the form:
Private pStartDate_hWnd
As IntPtr
Private pEndDate_hWnd As IntPtr
Private Form_hWnd As IntPtr
Private Declare Function FindWindow
Lib "Coredll" Alias "FindWindowW" _
(ByVal lpClassName As Char(), ByVal lpWindowName As Char())
As IntPtr
If you run this code you should see
the following:

Please note that both dates are set
to today's date. These dates can be changed and by clicking
on the button "Read Date Picker" you will see
the values of each datetime picker displayed.



Previous
Page Next
Page
Back to .NET Compact Framework | [Article Index]
|