2004-10-30 19:16:20 +00:00
|
|
|
/*
|
2006-02-26 16:57:59 +00:00
|
|
|
* PROJECT: ReactOS Timedate Control Panel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* FILE: lib/cpl/timedate/timedate.c
|
|
|
|
* PURPOSE: ReactOS Timedate Control Panel
|
2006-02-26 22:58:15 +00:00
|
|
|
* COPYRIGHT: Copyright 2004-2005 Eric Kohl
|
|
|
|
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
|
2006-03-01 21:44:17 +00:00
|
|
|
*
|
2004-10-30 19:16:20 +00:00
|
|
|
*/
|
|
|
|
|
2006-03-07 20:59:11 +00:00
|
|
|
#include <timedate.h>
|
2004-10-30 19:16:20 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
#define NUM_APPLETS 1
|
2004-11-07 16:03:51 +00:00
|
|
|
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
|
2004-10-30 19:16:20 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
HINSTANCE hApplet;
|
2004-10-30 19:16:20 +00:00
|
|
|
|
|
|
|
/* Applets */
|
2006-03-01 21:44:17 +00:00
|
|
|
APPLET Applets[NUM_APPLETS] =
|
2004-10-30 19:16:20 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
{IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
|
2004-10-30 19:16:20 +00:00
|
|
|
};
|
|
|
|
|
2006-10-03 17:02:36 +00:00
|
|
|
#if DBG
|
|
|
|
VOID DisplayWin32ErrorDbg(DWORD dwErrorCode, const char *file, int line)
|
|
|
|
#else
|
|
|
|
VOID DisplayWin32Error(DWORD dwErrorCode)
|
|
|
|
#endif
|
2006-06-21 19:57:58 +00:00
|
|
|
{
|
|
|
|
LPVOID lpMsgBuf;
|
2006-10-03 17:02:36 +00:00
|
|
|
#if DBG
|
2007-07-31 22:17:07 +00:00
|
|
|
WCHAR szMsg[255];
|
2006-10-03 17:02:36 +00:00
|
|
|
#endif
|
2006-06-21 19:57:58 +00:00
|
|
|
|
2007-07-31 22:17:07 +00:00
|
|
|
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
dwErrorCode,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPWSTR) &lpMsgBuf,
|
|
|
|
0,
|
|
|
|
NULL );
|
2006-06-21 19:57:58 +00:00
|
|
|
|
2006-10-03 17:02:36 +00:00
|
|
|
#if DBG
|
2007-07-31 22:17:07 +00:00
|
|
|
if (swprintf(szMsg, L"%hs:%d: %s", file, line, lpMsgBuf))
|
2006-10-03 17:02:36 +00:00
|
|
|
{
|
2007-07-31 22:17:07 +00:00
|
|
|
MessageBoxW(NULL, szMsg, NULL, MB_OK | MB_ICONERROR);
|
2006-10-03 17:02:36 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
MessageBox(NULL, lpMsgBuf, NULL, MB_OK | MB_ICONERROR);
|
|
|
|
#endif
|
2006-06-21 19:57:58 +00:00
|
|
|
|
|
|
|
LocalFree(lpMsgBuf);
|
|
|
|
}
|
|
|
|
|
2004-10-30 19:16:20 +00:00
|
|
|
|
2004-11-14 12:28:21 +00:00
|
|
|
static VOID
|
2007-07-31 22:17:07 +00:00
|
|
|
InitPropSheetPage(PROPSHEETPAGEW *psp, WORD idDlg, DLGPROC DlgProc)
|
2004-11-14 12:28:21 +00:00
|
|
|
{
|
2007-07-31 22:17:07 +00:00
|
|
|
ZeroMemory(psp, sizeof(PROPSHEETPAGEW));
|
|
|
|
psp->dwSize = sizeof(PROPSHEETPAGEW);
|
2006-06-22 17:13:29 +00:00
|
|
|
psp->dwFlags = PSP_DEFAULT;
|
|
|
|
psp->hInstance = hApplet;
|
2007-07-31 22:17:07 +00:00
|
|
|
psp->pszTemplate = MAKEINTRESOURCEW(idDlg);
|
2006-06-22 17:13:29 +00:00
|
|
|
psp->pfnDlgProc = DlgProc;
|
2004-11-14 12:28:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-28 20:02:37 +00:00
|
|
|
static LONG APIENTRY
|
|
|
|
Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
|
2006-03-07 20:59:11 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
PROPSHEETHEADER psh;
|
2007-07-31 22:17:07 +00:00
|
|
|
PROPSHEETPAGEW psp[3];
|
|
|
|
WCHAR Caption[256];
|
2006-06-22 17:13:29 +00:00
|
|
|
LONG Ret = 0;
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
UNREFERENCED_PARAMETER(uMsg);
|
|
|
|
UNREFERENCED_PARAMETER(wParam);
|
|
|
|
UNREFERENCED_PARAMETER(lParam);
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if (RegisterMonthCalControl(hApplet) &&
|
2006-06-22 17:13:29 +00:00
|
|
|
RegisterClockControl())
|
2006-03-07 20:59:11 +00:00
|
|
|
{
|
2007-07-31 22:17:07 +00:00
|
|
|
LoadStringW(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(WCHAR));
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2007-07-31 22:17:07 +00:00
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADERW);
|
2006-06-22 17:13:29 +00:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hwnd;
|
2006-06-22 17:13:29 +00:00
|
|
|
psh.hInstance = hApplet;
|
2007-07-31 22:17:07 +00:00
|
|
|
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
|
2006-06-22 17:13:29 +00:00
|
|
|
psh.pszCaption = Caption;
|
2007-07-31 22:17:07 +00:00
|
|
|
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGEW);
|
2006-06-22 17:13:29 +00:00
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = psp;
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2006-06-23 21:19:01 +00:00
|
|
|
InitPropSheetPage(&psp[0], IDD_DATETIMEPAGE, (DLGPROC) DateTimePageProc);
|
|
|
|
InitPropSheetPage(&psp[1], IDD_TIMEZONEPAGE, (DLGPROC) TimeZonePageProc);
|
|
|
|
InitPropSheetPage(&psp[2], IDD_INETTIMEPAGE, (DLGPROC) InetTimePageProc);
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2007-07-31 22:17:07 +00:00
|
|
|
Ret = (LONG)(PropertySheetW(&psh) != -1);
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
UnregisterMonthCalControl(hApplet);
|
|
|
|
UnregisterClockControl();
|
2006-03-07 20:59:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
/* Control Panel Callback */
|
|
|
|
LONG CALLBACK
|
|
|
|
CPlApplet(HWND hwndCpl,
|
|
|
|
UINT uMsg,
|
|
|
|
LPARAM lParam1,
|
|
|
|
LPARAM lParam2)
|
2006-06-21 19:57:58 +00:00
|
|
|
{
|
2007-06-07 16:18:38 +00:00
|
|
|
INT i = (INT)lParam1;
|
2006-06-21 19:57:58 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
switch (uMsg)
|
2006-06-21 19:57:58 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
case CPL_INIT:
|
|
|
|
return TRUE;
|
2006-02-26 16:57:59 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
case CPL_GETCOUNT:
|
|
|
|
return NUM_APPLETS;
|
2006-06-21 19:57:58 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
case CPL_INQUIRE:
|
2006-06-21 19:57:58 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
CPLINFO *CPlInfo = (CPLINFO*)lParam2;
|
|
|
|
CPlInfo->lData = 0;
|
|
|
|
CPlInfo->idIcon = Applets[i].idIcon;
|
|
|
|
CPlInfo->idName = Applets[i].idName;
|
|
|
|
CPlInfo->idInfo = Applets[i].idDescription;
|
2006-06-21 19:57:58 +00:00
|
|
|
}
|
2006-02-26 16:57:59 +00:00
|
|
|
break;
|
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
case CPL_DBLCLK:
|
2006-02-26 16:57:59 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
Applets[i].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
|
2006-02-26 16:57:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2005-12-30 18:19:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-08 16:45:13 +00:00
|
|
|
BOOL WINAPI
|
2004-10-30 19:16:20 +00:00
|
|
|
DllMain(HINSTANCE hinstDLL,
|
2006-06-22 17:13:29 +00:00
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved)
|
2004-10-30 19:16:20 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
UNREFERENCED_PARAMETER(lpReserved);
|
|
|
|
|
|
|
|
switch (dwReason)
|
2006-06-21 19:57:58 +00:00
|
|
|
{
|
2006-06-22 17:13:29 +00:00
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
{
|
|
|
|
INITCOMMONCONTROLSEX InitControls;
|
2004-11-07 16:03:51 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
|
|
|
InitControls.dwICC = ICC_DATE_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS;
|
|
|
|
InitCommonControlsEx(&InitControls);
|
2004-11-07 16:03:51 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
hApplet = hinstDLL;
|
|
|
|
}
|
|
|
|
break;
|
2006-06-21 19:57:58 +00:00
|
|
|
}
|
2004-10-30 19:16:20 +00:00
|
|
|
|
2006-06-22 17:13:29 +00:00
|
|
|
return TRUE;
|
2004-10-30 19:16:20 +00:00
|
|
|
}
|