2f30236e48b9ea269c0a8419cff079919bd19ecb
[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 2
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
78 return (LONG)(PropertySheet(&psh) != -1);
79 }
80
81 /* Control Panel Callback */
82 LONG
83 CALLBACK
84 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
85 {
86 switch(uMsg)
87 {
88 case CPL_INIT:
89 {
90 return TRUE;
91 }
92 case CPL_GETCOUNT:
93 {
94 return NUM_APPLETS;
95 }
96 case CPL_INQUIRE:
97 {
98 CPLINFO *CplInfo = (CPLINFO*)lParam2;
99 UINT uAppIndex = (UINT)lParam1;
100
101 CplInfo->lData = 0;
102 CplInfo->idIcon = Applets[uAppIndex].idIcon;
103 CplInfo->idName = Applets[uAppIndex].idName;
104 CplInfo->idInfo = Applets[uAppIndex].idDescription;
105 break;
106 }
107 case CPL_DBLCLK:
108 {
109 UINT uAppIndex = (UINT)lParam1;
110 Applets[uAppIndex].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
111 break;
112 }
113 }
114
115 return FALSE;
116 }
117
118 /* Standart DLL entry */
119
120 BOOL
121 STDCALL
122 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
123 {
124 INITCOMMONCONTROLSEX InitControls;
125 UNREFERENCED_PARAMETER(lpvReserved);
126 switch(dwReason)
127 {
128 case DLL_PROCESS_ATTACH:
129 case DLL_THREAD_ATTACH:
130 {
131 InitControls.dwSize = sizeof(INITCOMMONCONTROLSEX);
132 InitControls.dwICC = ICC_LISTVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_BAR_CLASSES;
133 InitCommonControlsEx(&InitControls);
134
135 hApplet = hinstDLL;
136 break;
137 }
138 }
139
140
141 return TRUE;
142 }
143
144 /* EOF */