resource icon added
[reactos.git] / reactos / lib / cpl / intl / intl.c
1 /*
2 * ReactOS
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * PROJECT: ReactOS International Control Panel
22 * FILE: lib/cpl/intl/intl.c
23 * PURPOSE: Property sheet code
24 * PROGRAMMER: Eric Kohl
25 */
26 #include <windows.h>
27 #include <commctrl.h>
28 #include <cpl.h>
29
30 #include "intl.h"
31 #include "resource.h"
32
33
34 #define NUM_APPLETS (2)
35
36 LONG APIENTRY
37 Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
38
39
40 HINSTANCE hApplet = 0;
41
42
43 /* Applets */
44 APPLET Applets[NUM_APPLETS] =
45 {
46 {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
47 };
48
49
50 VOID
51 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
52 {
53 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
54 psp->dwSize = sizeof(PROPSHEETPAGE);
55 psp->dwFlags = PSP_DEFAULT;
56 psp->hInstance = hApplet;
57 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
58 psp->pfnDlgProc = DlgProc;
59 }
60
61
62 LONG APIENTRY
63 Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
64 {
65 PROPSHEETPAGE psp[6];
66 PROPSHEETHEADER psh;
67 TCHAR Caption[256];
68
69 LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
70
71 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
72 psh.dwSize = sizeof(PROPSHEETHEADER);
73 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
74 psh.hwndParent = NULL;
75 psh.hInstance = hApplet;
76 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
77 psh.pszCaption = Caption;
78 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
79 psh.nStartPage = 0;
80 psh.ppsp = psp;
81
82 InitPropSheetPage(&psp[0], IDD_GENERALPAGE, GeneralPageProc);
83 InitPropSheetPage(&psp[1], IDD_NUMBERSPAGE, NumbersPageProc);
84 InitPropSheetPage(&psp[2], IDD_CURRENCYPAGE, CurrencyPageProc);
85 InitPropSheetPage(&psp[3], IDD_TIMEPAGE, TimePageProc);
86 InitPropSheetPage(&psp[4], IDD_DATEPAGE, DatePageProc);
87 InitPropSheetPage(&psp[5], IDD_LOCALEPAGE, LocalePageProc);
88
89 return (LONG)(PropertySheet(&psh) != -1);
90 }
91
92
93 /* Control Panel Callback */
94 LONG CALLBACK
95 CPlApplet(HWND hwndCpl,
96 UINT uMsg,
97 LPARAM lParam1,
98 LPARAM lParam2)
99 {
100 switch(uMsg)
101 {
102 case CPL_INIT:
103 return TRUE;
104
105 case CPL_GETCOUNT:
106 return NUM_APPLETS;
107
108 case CPL_INQUIRE:
109 {
110 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
111 UINT uAppIndex = (UINT)lParam1;
112
113 CPlInfo->lData = 0;
114 CPlInfo->idIcon = Applets[uAppIndex].idIcon;
115 CPlInfo->idName = Applets[uAppIndex].idName;
116 CPlInfo->idInfo = Applets[uAppIndex].idDescription;
117 break;
118 }
119
120 case CPL_DBLCLK:
121 {
122 UINT uAppIndex = (UINT)lParam1;
123 Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
124 break;
125 }
126 }
127
128 return FALSE;
129 }
130
131
132 BOOL STDCALL
133 DllMain(HINSTANCE hinstDLL,
134 DWORD dwReason,
135 LPVOID lpReserved)
136 {
137 switch(dwReason)
138 {
139 case DLL_PROCESS_ATTACH:
140 case DLL_THREAD_ATTACH:
141 hApplet = hinstDLL;
142 break;
143 }
144
145 return TRUE;
146 }
147