2 * PROJECT: ReactOS Timedate Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/timedate/timedate.c
5 * PURPOSE: ReactOS Timedate Control Panel
6 * COPYRIGHT: Copyright 2004-2005 Eric Kohl
7 * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
15 static LONG APIENTRY
Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
20 APPLET Applets
[NUM_APPLETS
] =
22 {IDC_CPLICON
, IDS_CPLNAME
, IDS_CPLDESCRIPTION
, Applet
}
26 VOID
DisplayWin32ErrorDbg(DWORD dwErrorCode
, const char *file
, int line
)
28 VOID
DisplayWin32Error(DWORD dwErrorCode
)
36 FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
37 FORMAT_MESSAGE_FROM_SYSTEM
|
38 FORMAT_MESSAGE_IGNORE_INSERTS
,
41 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
47 if (swprintf(szMsg
, L
"%hs:%d: %s", file
, line
, (PWSTR
)lpMsgBuf
))
49 MessageBoxW(NULL
, szMsg
, NULL
, MB_OK
| MB_ICONERROR
);
52 MessageBox(NULL
, lpMsgBuf
, NULL
, MB_OK
| MB_ICONERROR
);
60 InitPropSheetPage(PROPSHEETPAGEW
*psp
, WORD idDlg
, DLGPROC DlgProc
)
62 ZeroMemory(psp
, sizeof(PROPSHEETPAGEW
));
63 psp
->dwSize
= sizeof(PROPSHEETPAGEW
);
64 psp
->dwFlags
= PSP_DEFAULT
;
65 psp
->hInstance
= hApplet
;
66 psp
->pszTemplate
= MAKEINTRESOURCEW(idDlg
);
67 psp
->pfnDlgProc
= DlgProc
;
71 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
73 // NOTE: This callback is needed to set large icon correctly.
77 case PSCB_INITIALIZED
:
79 hIcon
= LoadIconW(hApplet
, MAKEINTRESOURCEW(IDC_CPLICON
));
80 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
88 Applet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
91 PROPSHEETPAGEW psp
[3];
95 UNREFERENCED_PARAMETER(uMsg
);
96 UNREFERENCED_PARAMETER(wParam
);
97 UNREFERENCED_PARAMETER(lParam
);
99 if (RegisterMonthCalControl(hApplet
) &&
100 RegisterClockControl())
102 LoadStringW(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(WCHAR
));
104 ZeroMemory(&psh
, sizeof(PROPSHEETHEADERW
));
105 psh
.dwSize
= sizeof(PROPSHEETHEADERW
);
106 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_PROPTITLE
| PSH_USEICONID
| PSH_USECALLBACK
;
107 psh
.hwndParent
= hwnd
;
108 psh
.hInstance
= hApplet
;
109 psh
.pszIcon
= MAKEINTRESOURCEW(IDC_CPLICON
);
110 psh
.pszCaption
= Caption
;
111 psh
.nPages
= sizeof(psp
) / sizeof(PROPSHEETPAGEW
);
114 psh
.pfnCallback
= PropSheetProc
;
116 InitPropSheetPage(&psp
[0], IDD_DATETIMEPAGE
, DateTimePageProc
);
117 InitPropSheetPage(&psp
[1], IDD_TIMEZONEPAGE
, TimeZonePageProc
);
118 InitPropSheetPage(&psp
[2], IDD_INETTIMEPAGE
, InetTimePageProc
);
120 Ret
= (LONG
)(PropertySheetW(&psh
) != -1);
122 UnregisterMonthCalControl(hApplet
);
123 UnregisterClockControl();
130 /* Control Panel Callback */
132 CPlApplet(HWND hwndCpl
,
137 INT i
= (INT
)lParam1
;
149 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
151 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
152 CPlInfo
->idName
= Applets
[i
].idName
;
153 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
159 Applets
[i
].AppletProc(hwndCpl
, uMsg
, lParam1
, lParam2
);
168 DllMain(HINSTANCE hinstDLL
,
172 UNREFERENCED_PARAMETER(lpReserved
);
176 case DLL_PROCESS_ATTACH
:
178 INITCOMMONCONTROLSEX InitControls
;
180 InitControls
.dwSize
= sizeof(INITCOMMONCONTROLSEX
);
181 InitControls
.dwICC
= ICC_DATE_CLASSES
| ICC_PROGRESS_CLASS
| ICC_UPDOWN_CLASS
;
182 InitCommonControlsEx(&InitControls
);