fix bug 838 (Sol.exe is missing it's menubar)
[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 0);
56 }
57
58 /***********************************************************************
59 * ControlsInit
60 *
61 * Register the classes for the builtin controls
62 */
63 BOOL FASTCALL
64 ControlsInit(LPCWSTR ClassName)
65 {
66 static const struct builtin_class_descr *ClassDescriptions[] =
67 {
68 &DIALOG_builtin_class,
69 &POPUPMENU_builtin_class,
70 &COMBO_builtin_class,
71 &COMBOLBOX_builtin_class,
72 #if 0
73 &DESKTOP_builtin_class,
74 #endif
75 &MDICLIENT_builtin_class,
76 #if 0
77 &MENU_builtin_class,
78 #endif
79 &SCROLL_builtin_class,
80 &BUTTON_builtin_class,
81 &LISTBOX_builtin_class,
82 &EDIT_builtin_class,
83 &ICONTITLE_builtin_class,
84 &STATIC_builtin_class
85 };
86 unsigned i;
87 BOOL Register;
88
89 Register = FALSE;
90 if (IS_ATOM(ClassName))
91 {
92 for (i = 0;
93 ! Register && i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]);
94 i++)
95 {
96 if (IS_ATOM(ClassDescriptions[i]->name))
97 {
98 Register = (ClassName == ClassDescriptions[i]->name);
99 }
100 }
101 }
102 else
103 {
104 for (i = 0;
105 ! Register && i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]);
106 i++)
107 {
108 if (! IS_ATOM(ClassDescriptions[i]->name))
109 {
110 Register = (0 == _wcsicmp(ClassName, ClassDescriptions[i]->name));
111 }
112 }
113 }
114
115 if (Register)
116 {
117 for (i = 0; i < sizeof(ClassDescriptions) / sizeof(ClassDescriptions[0]); i++)
118 {
119 RegisterBuiltinClass(ClassDescriptions[i]);
120 }
121 }
122
123 return Register;
124 }