ReactOS  0.4.15-dev-1068-g467feb9
timedate.c
Go to the documentation of this file.
1 /*
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>
8  *
9  */
10 
11 #include "timedate.h"
12 
13 #define NUM_APPLETS 1
14 
16 
18 
19 /* Applets */
21 {
23 };
24 
25 #if DBG
26 VOID DisplayWin32ErrorDbg(DWORD dwErrorCode, const char *file, int line)
27 #else
29 #endif
30 {
31  PWSTR lpMsgBuf;
32 #if DBG
33  WCHAR szMsg[255];
34 #endif
35 
39  NULL,
40  dwErrorCode,
42  (LPWSTR) &lpMsgBuf,
43  0,
44  NULL );
45 
46 #if DBG
47  if (swprintf(szMsg, L"%hs:%d: %s", file, line, (PWSTR)lpMsgBuf))
48  {
50  }
51 #else
52  MessageBox(NULL, lpMsgBuf, NULL, MB_OK | MB_ICONERROR);
53 #endif
54 
55  LocalFree(lpMsgBuf);
56 }
57 
58 
59 static VOID
61 {
62  ZeroMemory(psp, sizeof(PROPSHEETPAGEW));
63  psp->dwSize = sizeof(PROPSHEETPAGEW);
64  psp->dwFlags = PSP_DEFAULT;
65  psp->hInstance = hApplet;
67  psp->pfnDlgProc = DlgProc;
68 }
69 
70 static int CALLBACK
72 {
73  // NOTE: This callback is needed to set large icon correctly.
74  HICON hIcon;
75  switch (uMsg)
76  {
77  case PSCB_INITIALIZED:
78  {
80  SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
81  break;
82  }
83  }
84  return 0;
85 }
86 
87 static LONG APIENTRY
89 {
90  PROPSHEETHEADER psh;
91  PROPSHEETPAGEW psp[3];
92  WCHAR Caption[256];
93  LONG Ret = 0;
94 
98 
101  {
102  LoadStringW(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(WCHAR));
103 
104  ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
105  psh.dwSize = sizeof(PROPSHEETHEADERW);
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);
112  psh.nStartPage = 0;
113  psh.ppsp = psp;
114  psh.pfnCallback = PropSheetProc;
115 
119 
120  Ret = (LONG)(PropertySheetW(&psh) != -1);
121 
124  }
125 
126  return Ret;
127 }
128 
129 
130 /* Control Panel Callback */
132 CPlApplet(HWND hwndCpl,
133  UINT uMsg,
134  LPARAM lParam1,
135  LPARAM lParam2)
136 {
137  INT i = (INT)lParam1;
138 
139  switch (uMsg)
140  {
141  case CPL_INIT:
142  return TRUE;
143 
144  case CPL_GETCOUNT:
145  return NUM_APPLETS;
146 
147  case CPL_INQUIRE:
148  {
149  CPLINFO *CPlInfo = (CPLINFO*)lParam2;
150  CPlInfo->lData = 0;
151  CPlInfo->idIcon = Applets[i].idIcon;
152  CPlInfo->idName = Applets[i].idName;
153  CPlInfo->idInfo = Applets[i].idDescription;
154  }
155  break;
156 
157  case CPL_DBLCLK:
158  {
159  Applets[i].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
160  }
161  break;
162  }
163  return FALSE;
164 }
165 
166 
167 BOOL WINAPI
169  DWORD dwReason,
170  LPVOID lpReserved)
171 {
172  UNREFERENCED_PARAMETER(lpReserved);
173 
174  switch (dwReason)
175  {
176  case DLL_PROCESS_ATTACH:
177  {
179 
180  InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
183 
184  hApplet = hinstDLL;
185  }
186  break;
187  }
188 
189  return TRUE;
190 }
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: timedate.c:71
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WORD idDlg
Definition: desk.c:110
static HICON
Definition: imagelist.c:84
Definition: cpl.h:24
LPCWSTR pszTemplate
Definition: prsht.h:218
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
uint16_t * PWSTR
Definition: typedefs.h:56
#define LANG_NEUTRAL
Definition: nls.h:22
int idName
Definition: hotplug.h:36
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define INT
Definition: polytest.cpp:20
int idIcon
Definition: hotplug.h:35
#define CALLBACK
Definition: compat.h:35
int idInfo
Definition: cpl.h:27
#define ZeroMemory
Definition: winbase.h:1648
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define IDD_DATETIMEPAGE
Definition: resource.h:5
struct _PROPSHEETHEADERW PROPSHEETHEADERW
#define PSH_USECALLBACK
Definition: prsht.h:48
#define IDC_CPLICON
Definition: resource.h:7
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
static VOID InitControls(HWND hwnd)
Definition: mplay32.c:303
#define IDD_TIMEZONEPAGE
Definition: resource.h:15
int idIcon
Definition: cpl.h:25
int idDescription
Definition: hotplug.h:37
#define CPL_DBLCLK
Definition: cpl.h:16
BOOL RegisterMonthCalControl(IN HINSTANCE hInstance)
Definition: monthcal.c:1102
VOID DisplayWin32Error(DWORD dwErrorCode)
Definition: timedate.c:28
DWORD dwReason
Definition: misc.cpp:154
INT_PTR CALLBACK TimeZonePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: timezone.c:257
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IDS_CPLNAME
Definition: resource.h:8
DWORD dwSize
Definition: prsht.h:214
#define PSH_USEICONID
Definition: prsht.h:42
#define FALSE
Definition: types.h:117
#define ICC_UPDOWN_CLASS
Definition: commctrl.h:62
unsigned int BOOL
Definition: ntddk_ex.h:94
DLGPROC pfnDlgProc
Definition: prsht.h:226
#define IDD_INETTIMEPAGE
Definition: resource.h:21
long LONG
Definition: pedump.c:60
static LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: timedate.c:88
INT_PTR CALLBACK InetTimePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: internettime.c:381
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
struct _PROPSHEETPAGEW PROPSHEETPAGEW
smooth NULL
Definition: ftsmooth.c:416
#define PROPSHEETHEADER
Definition: prsht.h:392
LONG_PTR LPARAM
Definition: windef.h:208
Definition: parser.c:48
INT_PTR WINAPI PropertySheetW(LPCPROPSHEETHEADERW lppsh)
Definition: propsheet.c:2905
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define IDS_CPLDESCRIPTION
Definition: resource.h:9
#define PSP_DEFAULT
Definition: prsht.h:22
#define ICC_DATE_CLASSES
Definition: commctrl.h:67
VOID UnregisterClockControl(VOID)
Definition: clock.c:291
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PSH_PROPTITLE
Definition: prsht.h:40
APPLET_PROC AppletProc
Definition: hotplug.h:38
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CPL_INIT
Definition: cpl.h:12
INT_PTR CALLBACK DateTimePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dateandtime.c:265
HINSTANCE hApplet
Definition: timedate.c:17
#define CPL_INQUIRE
Definition: cpl.h:14
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
#define MB_ICONERROR
Definition: winuser.h:781
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpReserved)
Definition: timedate.c:168
HINSTANCE hInstance
Definition: prsht.h:216
#define MessageBox
Definition: winuser.h:5797
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
INT_PTR(CALLBACK * DLGPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2871
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:401
#define PSCB_INITIALIZED
Definition: prsht.h:75
VOID UnregisterMonthCalControl(IN HINSTANCE hInstance)
Definition: monthcal.c:1119
APPLET Applets[NUM_APPLETS]
Definition: timedate.c:20
HICON hIcon
Definition: msconfig.c:44
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
#define ICC_PROGRESS_CLASS
Definition: commctrl.h:63
#define MAKELANGID(p, s)
Definition: nls.h:15
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG CALLBACK CPlApplet(HWND hwndCpl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
Definition: timedate.c:132
BOOL RegisterClockControl(VOID)
Definition: clock.c:275
LPARAM lParam
Definition: combotst.c:139
DLGPROC DlgProc
Definition: desk.c:111
DWORD dwFlags
Definition: prsht.h:215
#define NUM_APPLETS
Definition: timedate.c:13
#define CPL_GETCOUNT
Definition: cpl.h:13
#define APIENTRY
Definition: api.h:79
#define ICON_BIG
Definition: tnclass.cpp:51
static VOID InitPropSheetPage(PROPSHEETPAGEW *psp, WORD idDlg, DLGPROC DlgProc)
Definition: timedate.c:60
Definition: hotplug.h:33
Definition: fci.c:126