#include <commctrl.h>
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
static HWND hDtp;
switch (iMessage) {
case WM_CREATE: {
INITCOMMONCONTROLSEX icex;
icex.dwSize=sizeof(icex);
icex.dwICC=ICC_DATE_CLASSES;
InitCommonControlsEx(&icex);
hDtp=CreateWindow(DATETIMEPICK_CLASS, "DTP",WS_BORDER | WS_CHILD | WS_VISIBLE |
DTS_SHORTDATEFORMAT,
50,50,200,25,hWnd,NULL,g_hInst,NULL);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_LBUTTONDOWN: {
SYSTEMTIME tm;
TCHAR str[255];
DateTime_GetSystemtime(hDtp,&tm);
... tm.wYear ... tm.wMonth ... tm.wDay ...
}
return 0;
case WM_RBUTTONDOWN: {
SYSTEMTIME tm;
memset(&tm,0,sizeof(SYSTEMTIME));
tm.wYear=...;
tm.wMonth=...;
tm.wDay=...;
DateTime_SetSystemtime(hDtp,GDT_VALID,&tm);
}
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}