Alexey Zavyalov: Add functionally Numbers, Currency, Time, Date tabs. Fix some bugs.
[reactos.git] / reactos / dll / cpl / intl_new / intl.c
1 /*
2 * PROJECT: ReactOS International Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/cpl/intl/intl.c
5 * PURPOSE: ReactOS International Control Panel
6 * PROGRAMMERS: Eric Kohl
7 * Alexey Zavyalov (gen_x@mail.ru)
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #include <windows.h>
13 #include <commctrl.h>
14 #include <cpl.h>
15
16 #include "resource.h"
17 #include "intl.h"
18
19 /* GLOBALS ******************************************************************/
20
21 #define NUM_APPLETS (1)
22 #define NUM_SHEETS 3
23
24 LONG APIENTRY Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam);
25
26 HINSTANCE hApplet;
27
28 APPLET Applets[NUM_APPLETS] =
29 {
30 {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, Applet}
31 };
32
33 /* FUNCTIONS ****************************************************************/
34
35 static
36 VOID
37 InitPropSheetPage(PROPSHEETPAGE *PsPage, WORD IdDlg, DLGPROC DlgProc)
38 {
39 ZeroMemory(PsPage, sizeof(PROPSHEETPAGE));
40 PsPage->dwSize = sizeof(PROPSHEETPAGE);
41 PsPage->dwFlags = PSP_DEFAULT;
42 PsPage->hInstance = hApplet;
43 PsPage->pszTemplate = MAKEINTRESOURCE(IdDlg);
44 PsPage->pfnDlgProc = DlgProc;
45 }
46
47 /* Create applets */
48 LONG
49 APIENTRY
50 Applet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
51 {
52
53 PROPSHEETPAGE PsPage[NUM_SHEETS];
54 PROPSHEETHEADER psh;
55 TCHAR Caption[MAX_STR_SIZE];
56
57 UNREFERENCED_PARAMETER(lParam);
58 UNREFERENCED_PARAMETER(wParam);
59 UNREFERENCED_PARAMETER(uMsg);
60 UNREFERENCED_PARAMETER(hwnd);
61
62 LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
63
64 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
65 psh.dwSize = sizeof(PROPSHEETHEADER);
66 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
67 psh.hwndParent = NULL;
68 psh.hInstance = hApplet;
69 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
70 psh.pszCaption = Caption;
71 psh.nPages = sizeof(PsPage) / sizeof(PROPSHEETPAGE);
72 psh.nStartPage = 0;
73 psh.ppsp = PsPage;
74
75 InitPropSheetPage(&PsPage[0], IDD_REGOPTSPAGE, RegOptsProc);
76 InitPropSheetPage(&PsPage[1], IDD_EXTRAOPTSPAGE, ExtraOptsProc);
77 InitPropSheetPage(&PsPage[2], IDD_LANGSOPTSPAGE, LangsOptsProc);
78
79 return (LONG)(PropertySheet(&psh) != -1);
80 }
81
82 /* Control Panel Callback */
83 LONG
84 CALLBACK
85 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
86 {
87 switch(uMsg)
88 {
89 case CPL_INIT:
90 {
91 return TRUE;
92 }
93 case CPL_GETCOUNT:
94 {
95 return NUM_APPLETS;
96 }
97 case CPL_INQUIRE:
98 {
99 CPLINFO *CplInfo = (CPLINFO*)lParam2;
100 UINT uAppIndex = (UINT)lParam1;
101
102 CplInfo->lData = 0;
103 CplInfo->idIcon = Applets[uAppIndex].idIcon;
104 CplInfo->idName = Applets[uAppIndex].idName;
105 CplInfo->idInfo = Applets[uAppIndex].idDescription;
106 break;
107 }
108 case CPL_DBLCLK:
109 {
110 UINT uAppIndex = (UINT)lParam1;
111 Applets[uAppIndex].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
112 break;
113 }
114 }
115
116 return FALSE;
117 }
118
119 /* Standart DLL entry */
120
121 BOOL
122 STDCALL
123 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
124 {
125 INITCOMMONCONTROLSEX InitControls;
126 UNREFERENCED_PARAMETER(lpvReserved);
127 switch(dwReason)
128 {
129 case DLL_PROCESS_ATTACH:
130 case DLL_THREAD_ATTACH:
131 {
132 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
133 InitControls.dwICC = ICC_LISTVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_BAR_CLASSES;
134 InitCommonControlsEx(&InitControls);
135
136 hApplet = hinstDLL;
137 break;
138 }
139 }
140
141
142 return TRUE;
143 }
144
145 /* EOF */