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
|
2011-11-29 14:55:58 +00:00
|
|
|
* FILE: dll/cpl/timedate/timedate.c
|
2006-02-26 16:57:59 +00:00
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +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
|
|
|
{
|
2018-08-20 15:42:27 +00:00
|
|
|
PWSTR 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
|
2018-08-20 15:42:27 +00:00
|
|
|
if (swprintf(szMsg, L"%hs:%d: %s", file, line, (PWSTR)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
|
|
|
}
|
|
|
|
|
2018-12-14 11:06:57 +00:00
|
|
|
static int CALLBACK
|
|
|
|
PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
|
|
|
|
{
|
|
|
|
// NOTE: This callback is needed to set large icon correctly.
|
|
|
|
HICON hIcon;
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case PSCB_INITIALIZED:
|
|
|
|
{
|
|
|
|
hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
|
|
|
|
SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
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);
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
|
2008-05-15 05:43:01 +00:00
|
|
|
psh.hwndParent = hwnd;
|
2006-06-22 17:13:29 +00:00
|
|
|
psh.hInstance = hApplet;
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.pszIcon = 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;
|
2018-12-14 11:06:57 +00:00
|
|
|
psh.pfnCallback = PropSheetProc;
|
2006-03-07 20:59:11 +00:00
|
|
|
|
2017-10-30 23:37:37 +00:00
|
|
|
InitPropSheetPage(&psp[0], IDD_DATETIMEPAGE, DateTimePageProc);
|
|
|
|
InitPropSheetPage(&psp[1], IDD_TIMEZONEPAGE, TimeZonePageProc);
|
|
|
|
InitPropSheetPage(&psp[2], IDD_INETTIMEPAGE, 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
|
|
|
}
|