[CLB]
[reactos.git] / reactos / base / applications / regedit / clb / clb.c
1 /*
2 * ReactOS Column List Box
3 * Copyright (C) 2005 Thomas Weidenmueller
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 /*
20 * PROJECT: ReactOS Column List Box
21 * FILE: lib/clb/clb.c
22 * PURPOSE: Column List Box
23 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
24 *
25 * UPDATE HISTORY:
26 * 10/29/2005 Created
27 */
28 #include <precomp.h>
29
30 static HINSTANCE hDllInstance;
31
32 static const WCHAR ClbClassName[] = L"ColumnListBox";
33 static const WCHAR ClbColumns[] = L"Column1;Column2;Column3";
34
35 typedef struct _CLB_PRIVATEDATA
36 {
37 HWND hwnd;
38 } CLB_PRIVATEDATA, *PCLB_PRIVATEDATA;
39
40 static const CLBS_INFO ClbsSupportedStyles[] =
41 {
42 {
43 CLBS_NOTIFY,
44 0x0,
45 L"CLBS_NOTIFY"
46 },
47 {
48 CLBS_SORT,
49 0x0,
50 L"CLBS_SORT"
51 },
52 {
53 CLBS_DISABLENOSCROLL,
54 0x0,
55 L"CLBS_DISABLENOSCROLL"
56 },
57 {
58 CLBS_VSCROLL,
59 0x0,
60 L"CLBS_VSCROLL"
61 },
62 {
63 CLBS_BORDER,
64 0x0,
65 L"CLBS_BORDER"
66 },
67 {
68 CLBS_POPOUT_HEADINGS,
69 0x0,
70 L"CLBS_POPOUT_HEADINGS"
71 },
72 {
73 CLBS_SPRINGLY_COLUMNS,
74 0x0,
75 L"CLBS_SPRINGLY_COLUMNS"
76 },
77 {
78 LBS_OWNERDRAWFIXED,
79 0x0,
80 L"LBS_OWNERDRAWFIXED"
81 }
82 };
83
84 /*
85 * @unimplemented
86 */
87 DWORD
88 WINAPI
89 ClbAddData(IN DWORD Unknown1,
90 IN DWORD Unknown2,
91 IN DWORD Unknown3)
92 {
93 DPRINT1("ClbAddData(0x%x, 0x%x, 0x%x)\n", Unknown1, Unknown2, Unknown3);
94 return 0;
95 }
96
97
98 /*
99 * @unimplemented
100 */
101 DWORD
102 WINAPI
103 ClbSetColumnWidths(IN DWORD Unknown1,
104 IN DWORD Unknown2,
105 IN DWORD Unknown3)
106 {
107 DPRINT1("ClbSetColumnWidths(0x%x, 0x%x, 0x%x)\n", Unknown1, Unknown2, Unknown3);
108 return 0;
109 }
110
111
112 /*
113 * @unimplemented
114 */
115 LRESULT
116 CALLBACK
117 ClbWndProc(IN HWND hwnd,
118 IN UINT uMsg,
119 IN WPARAM wParam,
120 IN LPARAM lParam)
121 {
122 PCLB_PRIVATEDATA PrivData;
123 LRESULT Ret = 0;
124
125 DPRINT1("ClbWndProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwnd, uMsg, wParam, lParam);
126
127 PrivData = (PCLB_PRIVATEDATA)GetWindowLongPtr(hwnd,
128 0);
129 if (PrivData == NULL && uMsg != WM_CREATE)
130 {
131 goto HandleDefMsg;
132 }
133
134 switch (uMsg)
135 {
136 case WM_CREATE:
137 PrivData = HeapAlloc(GetProcessHeap(),
138 0,
139 sizeof(CLB_PRIVATEDATA));
140 if (PrivData == NULL)
141 {
142 Ret = (LRESULT)-1;
143 break;
144 }
145 PrivData->hwnd = hwnd;
146 break;
147
148 case WM_DESTROY:
149 HeapFree(GetProcessHeap(),
150 0,
151 PrivData);
152 break;
153
154 default:
155 HandleDefMsg:
156 Ret = DefWindowProc(hwnd,
157 uMsg,
158 wParam,
159 lParam);
160 break;
161 }
162
163 return Ret;
164 }
165
166
167 static INT_PTR CALLBACK
168 ClbpStyleDlgProc(IN HWND hwndDlg,
169 IN UINT uMsg,
170 IN WPARAM wParam,
171 IN LPARAM lParam)
172 {
173 INT_PTR Ret = FALSE;
174
175 DPRINT1("ClbpStyleDlgProc(0x%p, 0x%x, 0x%p, 0x%p)\n", hwndDlg, uMsg, wParam, lParam);
176
177 switch (uMsg)
178 {
179 case WM_COMMAND:
180 switch (LOWORD(wParam))
181 {
182 case IDOK:
183 case IDCANCEL:
184 EndDialog(hwndDlg,
185 (INT_PTR)LOWORD(wParam));
186 break;
187 }
188 break;
189
190 case WM_CLOSE:
191 EndDialog(hwndDlg,
192 IDCANCEL);
193 break;
194
195 case WM_INITDIALOG:
196 Ret = TRUE;
197 break;
198 }
199
200 return Ret;
201 }
202
203
204 /*
205 * @implemented
206 */
207 INT_PTR
208 WINAPI
209 ClbStyleW(IN HWND hWndParent,
210 IN LPARAM dwInitParam)
211 {
212 return DialogBoxParam(hDllInstance,
213 MAKEINTRESOURCE(IDD_COLUMNLISTBOXSTYLES),
214 hWndParent,
215 ClbpStyleDlgProc,
216 dwInitParam);
217 }
218
219
220 /*
221 * @implemented
222 */
223 BOOL
224 WINAPI
225 CustomControlInfoW(OUT LPCUSTOM_CONTROL_INFO CustomControlInfo OPTIONAL)
226 {
227 if (CustomControlInfo != NULL)
228 {
229 wcscpy(CustomControlInfo->ClassName,
230 ClbClassName);
231
232 CustomControlInfo->Zero1 = 0;
233
234 wcscpy(CustomControlInfo->ClassName2,
235 ClbClassName);
236
237 CustomControlInfo->Unknown1 = 0x60; /* FIXME - ??? */
238 CustomControlInfo->Unknown2 = 0x50; /* FIXME - ??? */
239 CustomControlInfo->Unknown3 = 0x50A10013; /* FIXME - ??? */
240
241 CustomControlInfo->Zero2 = 0;
242 CustomControlInfo->Zero3 = 0;
243
244 CustomControlInfo->StylesCount = sizeof(ClbsSupportedStyles) / sizeof(ClbsSupportedStyles[0]);
245 CustomControlInfo->SupportedStyles = ClbsSupportedStyles;
246
247 wcscpy(CustomControlInfo->Columns,
248 ClbColumns);
249
250 CustomControlInfo->ClbStyleW = ClbStyleW;
251
252 CustomControlInfo->Zero4 = 0;
253 CustomControlInfo->Zero5 = 0;
254 CustomControlInfo->Zero6 = 0;
255 }
256
257 return TRUE;
258 }
259
260 BOOL
261 WINAPI
262 DllMain(IN HINSTANCE hinstDLL,
263 IN DWORD dwReason,
264 IN LPVOID lpvReserved)
265 {
266 BOOL Ret = TRUE;
267
268 switch (dwReason)
269 {
270 case DLL_PROCESS_ATTACH:
271 {
272 WNDCLASS ClbWndClass;
273
274 hDllInstance = hinstDLL;
275
276 InitCommonControls();
277
278 /* register the control's window class */
279 ClbWndClass.style = CS_GLOBALCLASS | CS_OWNDC;
280 ClbWndClass.lpfnWndProc = ClbWndProc;
281 ClbWndClass.cbClsExtra = 0;
282 ClbWndClass.cbWndExtra = sizeof(PCLB_PRIVATEDATA);
283 ClbWndClass.hInstance = hinstDLL,
284 ClbWndClass.hIcon = NULL;
285 ClbWndClass.hCursor = LoadCursor(NULL,
286 (LPWSTR)IDC_ARROW);
287 ClbWndClass.hbrBackground = NULL;
288 ClbWndClass.lpszMenuName = NULL;
289 ClbWndClass.lpszClassName = ClbClassName;
290
291 if (!RegisterClass(&ClbWndClass))
292 {
293 Ret = FALSE;
294 break;
295 }
296 break;
297 }
298
299 case DLL_THREAD_ATTACH:
300 case DLL_THREAD_DETACH:
301 break;
302
303 case DLL_PROCESS_DETACH:
304 UnregisterClass(ClbClassName,
305 hinstDLL);
306 break;
307 }
308 return Ret;
309 }
310
311 /* EOF */