ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

timedate.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:     ReactOS Timedate Control Panel
00003  * LICENSE:     GPL - See COPYING in the top level directory
00004  * FILE:        dll/cpl/timedate/timedate.c
00005  * PURPOSE:     ReactOS Timedate Control Panel
00006  * COPYRIGHT:   Copyright 2004-2005 Eric Kohl
00007  *              Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
00008  *
00009  */
00010 
00011 #include <timedate.h>
00012 
00013 #define NUM_APPLETS 1
00014 
00015 static LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
00016 
00017 HINSTANCE hApplet;
00018 
00019 /* Applets */
00020 APPLET Applets[NUM_APPLETS] =
00021 {
00022     {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
00023 };
00024 
00025 #if DBG
00026 VOID DisplayWin32ErrorDbg(DWORD dwErrorCode, const char *file, int line)
00027 #else
00028 VOID DisplayWin32Error(DWORD dwErrorCode)
00029 #endif
00030 {
00031     LPVOID lpMsgBuf;
00032 #if DBG
00033     WCHAR szMsg[255];
00034 #endif
00035 
00036     FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
00037                    FORMAT_MESSAGE_FROM_SYSTEM |
00038                    FORMAT_MESSAGE_IGNORE_INSERTS,
00039                    NULL,
00040                    dwErrorCode,
00041                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
00042                    (LPWSTR) &lpMsgBuf,
00043                    0,
00044                    NULL );
00045 
00046 #if DBG
00047     if (swprintf(szMsg, L"%hs:%d: %s", file, line, lpMsgBuf))
00048     {
00049         MessageBoxW(NULL, szMsg, NULL, MB_OK | MB_ICONERROR);
00050     }
00051 #else
00052     MessageBox(NULL, lpMsgBuf, NULL, MB_OK | MB_ICONERROR);
00053 #endif
00054 
00055     LocalFree(lpMsgBuf);
00056 }
00057 
00058 
00059 static VOID
00060 InitPropSheetPage(PROPSHEETPAGEW *psp, WORD idDlg, DLGPROC DlgProc)
00061 {
00062     ZeroMemory(psp, sizeof(PROPSHEETPAGEW));
00063     psp->dwSize = sizeof(PROPSHEETPAGEW);
00064     psp->dwFlags = PSP_DEFAULT;
00065     psp->hInstance = hApplet;
00066     psp->pszTemplate = MAKEINTRESOURCEW(idDlg);
00067     psp->pfnDlgProc = DlgProc;
00068 }
00069 
00070 
00071 static LONG APIENTRY
00072 Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
00073 {
00074     PROPSHEETHEADER psh;
00075     PROPSHEETPAGEW psp[3];
00076     WCHAR Caption[256];
00077     LONG Ret = 0;
00078 
00079     UNREFERENCED_PARAMETER(uMsg);
00080     UNREFERENCED_PARAMETER(wParam);
00081     UNREFERENCED_PARAMETER(lParam);
00082 
00083     if (RegisterMonthCalControl(hApplet) &&
00084         RegisterClockControl())
00085     {
00086         LoadStringW(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(WCHAR));
00087 
00088         ZeroMemory(&psh, sizeof(PROPSHEETHEADERW));
00089         psh.dwSize = sizeof(PROPSHEETHEADERW);
00090         psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_PROPTITLE;
00091         psh.hwndParent = hwnd;
00092         psh.hInstance = hApplet;
00093         psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
00094         psh.pszCaption = Caption;
00095         psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGEW);
00096         psh.nStartPage = 0;
00097         psh.ppsp = psp;
00098 
00099         InitPropSheetPage(&psp[0], IDD_DATETIMEPAGE, (DLGPROC) DateTimePageProc);
00100         InitPropSheetPage(&psp[1], IDD_TIMEZONEPAGE, (DLGPROC) TimeZonePageProc);
00101         InitPropSheetPage(&psp[2], IDD_INETTIMEPAGE, (DLGPROC) InetTimePageProc);
00102 
00103         Ret = (LONG)(PropertySheetW(&psh) != -1);
00104 
00105         UnregisterMonthCalControl(hApplet);
00106         UnregisterClockControl();
00107     }
00108 
00109     return Ret;
00110 }
00111 
00112 
00113 /* Control Panel Callback */
00114 LONG CALLBACK
00115 CPlApplet(HWND hwndCpl,
00116           UINT uMsg,
00117           LPARAM lParam1,
00118           LPARAM lParam2)
00119 {
00120     INT i = (INT)lParam1;
00121 
00122     switch (uMsg)
00123     {
00124         case CPL_INIT:
00125             return TRUE;
00126 
00127         case CPL_GETCOUNT:
00128             return NUM_APPLETS;
00129 
00130         case CPL_INQUIRE:
00131         {
00132             CPLINFO *CPlInfo = (CPLINFO*)lParam2;
00133             CPlInfo->lData = 0;
00134             CPlInfo->idIcon = Applets[i].idIcon;
00135             CPlInfo->idName = Applets[i].idName;
00136             CPlInfo->idInfo = Applets[i].idDescription;
00137         }
00138         break;
00139 
00140         case CPL_DBLCLK:
00141         {
00142             Applets[i].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
00143         }
00144         break;
00145     }
00146     return FALSE;
00147 }
00148 
00149 
00150 BOOL WINAPI
00151 DllMain(HINSTANCE hinstDLL,
00152         DWORD dwReason,
00153         LPVOID lpReserved)
00154 {
00155     UNREFERENCED_PARAMETER(lpReserved);
00156 
00157     switch (dwReason)
00158     {
00159         case DLL_PROCESS_ATTACH:
00160         {
00161             INITCOMMONCONTROLSEX InitControls;
00162 
00163             InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
00164             InitControls.dwICC = ICC_DATE_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS;
00165             InitCommonControlsEx(&InitControls);
00166 
00167             hApplet = hinstDLL;
00168         }
00169         break;
00170     }
00171 
00172     return TRUE;
00173 }

Generated on Sun May 27 2012 04:21:05 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.