5bb862078ce72dc9b2bbdc276b4c8acce54fb2b6
[reactos.git] / reactos / lib / user32 / controls / regcontrol.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS User32
5 * PURPOSE: Built-in control registration
6 * FILE: lib/user32/controls/regcontrol.c
7 * PROGRAMER: Ge van Geldorp (ge@gse.nl)
8 * REVISION HISTORY: 2003/06/16 GvG Created
9 * NOTES: Adapted from Wine
10 */
11
12 #include <user32.h>
13
14 static void RegisterBuiltinClass(const struct builtin_class_descr *Descr)
15 {
16 WNDCLASSEXW wc;
17 UNICODE_STRING ClassName;
18 UNICODE_STRING MenuName;
19
20 wc.cbSize = sizeof(WNDCLASSEXW);
21 wc.lpszClassName = Descr->name;
22 wc.lpfnWndProc = Descr->procW;
23 wc.style = Descr->style;
24 wc.hInstance = User32Instance;
25 wc.hIcon = NULL;
26 wc.hIconSm = NULL;
27 wc.hCursor = LoadCursorW(NULL, Descr->cursor);
28 wc.hbrBackground = Descr->brush;
29 wc.lpszMenuName = NULL;
30 wc.cbClsExtra = 0;
31 wc.cbWndExtra = Descr->extra;
32
33 MenuName.Length =
34 MenuName.MaximumLength = 0;
35 MenuName.Buffer = NULL;
36
37 if (IS_ATOM(Descr->name))
38 {
39 ClassName.Length =
40 ClassName.MaximumLength = 0;
41 ClassName.Buffer = (LPWSTR)Descr->name;
42 } else
43 {
44 RtlInitUnicodeString(&ClassName, Descr->name);
45 }
46
47 NtUserRegisterClassExWOW(
48 &wc,
49 &ClassName,
50 &ClassName,
51 &MenuName,
52 Descr->procA,
53 REGISTERCLASS_SYSTEM,
54 0);
55 }
56
57 /***********************************************************************
58 * ControlsInit
59 *
60 * Register the classes for the builtin controls
61 */
62 BOOL FASTCALL
63 ControlsInit(LPCWSTR ClassName)
64 {
65 static const struct builtin_class_descr *ClassDescriptions[] =
66 {
67 &DIALOG_builtin_class,
68 &POPUPMENU_builtin_class,
69 &COMBO_builtin_class,
70 &COMBOLBOX_builtin_class,
71 #if 0
72 &DESKTOP_builtin_class,
73 #endif
74 &MDICLIENT_builtin_class,
75 #if 0
76 &MENU_builtin_class,
77 #endif
78 &SCROLL_builtin_class,
79 &BUTTON_builtin_class,
80 &LISTBOX_builtin_class,
81 &EDIT_builtin_class,
82 &ICONTITLE_builtin_class,
83 &STATIC_builtin_class
84 };
85 unsigned i;
86 BOOL Register;
87
88 Register = FALSE;
89 if (IS_ATOM(ClassName))
90 {
91 for (i = 0;
92 ! Register && i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]);
93 i++)
94 {
95 if (IS_ATOM(ClassDescriptions[i]->name))
96 {
97 Register = (ClassName == ClassDescriptions[i]->name);
98 }
99 }
100 }
101 else
102 {
103 for (i = 0;
104 ! Register && i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]);
105 i++)
106 {
107 if (! IS_ATOM(ClassDescriptions[i]->name))
108 {
109 Register = (0 == _wcsicmp(ClassName, ClassDescriptions[i]->name));
110 }
111 }
112 }
113
114 if (Register)
115 {
116 for (i = 0; i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]); i++)
117 {
118 RegisterBuiltinClass(ClassDescriptions[i]);
119 }
120 }
121
122 return Register;
123 }