[USER32]
[reactos.git] / reactos / dll / win32 / user32 / include / user32p.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS System Libraries
4 * FILE: lib/user32/include/user32p.h
5 * PURPOSE: Win32 User Library Private Headers
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #pragma once
12
13 /* Private User32 Headers */
14 #include "accel.h"
15 #include "cursor.h"
16 #include "controls.h"
17 #include "draw.h"
18 #include "dde_private.h"
19 #include "menu.h"
20 #include "message.h"
21 #include "regcontrol.h"
22 #include "resource.h"
23 #include "scroll.h"
24 #include "window.h"
25 #include "winpos.h"
26 #include "winsta.h"
27 #include "ntwrapper.h"
28
29 #define IS_ATOM(x) \
30 (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
31
32 /* One/Two Param Functions */
33 #define NtUserMsqSetWakeMask(dwWaitMask) \
34 (HANDLE)NtUserCallOneParam(dwWaitMask, ONEPARAM_ROUTINE_GETINPUTEVENT)
35
36 #define NtUserMsqClearWakeMask() \
37 NtUserCallNoParam(NOPARAM_ROUTINE_MSQCLEARWAKEMASK)
38
39 #define NtUserValidateRgn(hWnd, hRgn) \
40 (BOOL)NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)hRgn, TWOPARAM_ROUTINE_VALIDATERGN)
41
42 #define NtUserSetWindowContextHelpId(hWnd, dwContextHelpId) \
43 (BOOL)NtUserCallHwndParam(hWnd, dwContextHelpId, HWNDPARAM_ROUTINE_SETWNDCONTEXTHLPID)
44
45 #define NtUserSetCaretPos(X, Y) \
46 (BOOL)NtUserCallTwoParam((DWORD_PTR)X, (DWORD_PTR)Y, TWOPARAM_ROUTINE_SETCARETPOS)
47
48 #define NtUserSetGUIThreadHandle(field, hwnd) \
49 (BOOL)NtUserCallTwoParam((DWORD_PTR)field, (DWORD_PTR)hwnd, TWOPARAM_ROUTINE_SETGUITHRDHANDLE)
50
51 #define NtUserSetMenuBarHeight(menu, height) \
52 (BOOL)NtUserCallTwoParam((DWORD_PTR)menu, (DWORD_PTR)height, TWOPARAM_ROUTINE_SETMENUBARHEIGHT)
53
54 #define NtUserRegisterLogonProcess(hproc, x) \
55 (BOOL)NtUserCallTwoParam((DWORD_PTR)hproc, (DWORD_PTR)x, TWOPARAM_ROUTINE_REGISTERLOGONPROC)
56
57 #define NtUserGetSysColorBrushes(HBrushes, count) \
58 (BOOL)NtUserCallTwoParam((DWORD_PTR)(HBrushes), (DWORD_PTR)(count), TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES)
59
60 #define NtUserGetSysColors(ColorRefs, count) \
61 (BOOL)NtUserCallTwoParam((DWORD_PTR)(ColorRefs), (DWORD_PTR)(count), TWOPARAM_ROUTINE_GETSYSCOLORS)
62
63 #define NtUserSetCaretBlinkTime(uMSeconds) \
64 (BOOL)NtUserCallOneParam((DWORD_PTR)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
65
66 /*
67 #define NtUserEnumClipboardFormats(format) \
68 (UINT)NtUserCallOneParam(format, ONEPARAM_ROUTINE_ENUMCLIPBOARDFORMATS)
69 */
70
71 #define NtUserWindowFromDC(hDC) \
72 (HWND)NtUserCallOneParam((DWORD_PTR)hDC, ONEPARAM_ROUTINE_WINDOWFROMDC)
73
74 #define NtUserSwitchCaretShowing(CaretInfo) \
75 (BOOL)NtUserCallOneParam((DWORD_PTR)CaretInfo, ONEPARAM_ROUTINE_SWITCHCARETSHOWING)
76
77 #define NtUserSwapMouseButton(fSwap) \
78 (BOOL)NtUserCallOneParam((DWORD_PTR)fSwap, ONEPARAM_ROUTINE_SWAPMOUSEBUTTON)
79
80 #define NtUserSetMessageExtraInfo(lParam) \
81 (LPARAM)NtUserCallOneParam((DWORD_PTR)lParam, ONEPARAM_ROUTINE_SETMESSAGEEXTRAINFO)
82
83 #define NtUserGetWindowContextHelpId(hwnd) \
84 NtUserCallOneParam((DWORD_PTR)hwnd, ONEPARAM_ROUTINE_GETWNDCONTEXTHLPID)
85
86 #define NtUserGetCursorPos(lpPoint) \
87 (BOOL)NtUserCallOneParam((DWORD_PTR)lpPoint, ONEPARAM_ROUTINE_GETCURSORPOSITION)
88
89 #define NtUserEnableProcessWindowGhosting(bEnable) \
90 NtUserCallOneParam((DWORD_PTR)bEnable, ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING)
91
92 #define NtUserShowCursor(bShow) \
93 NtUserCallOneParam((DWORD_PTR)bShow, ONEPARAM_ROUTINE_SHOWCURSOR)
94
95 #define NtUserGetDesktopMapping(Ptr) \
96 (PVOID)NtUserCallOneParam((DWORD_PTR)Ptr, ONEPARAM_ROUTINE_GETDESKTOPMAPPING)
97
98 #define NtUserSetCursorPos(x, y) \
99 (BOOL)NtUserCallTwoParam((DWORD)x, (DWORD)y, TWOPARAM_ROUTINE_SETCURSORPOS)
100
101 #define ShowCaret(hwnd) \
102 NtUserShowCaret(hwnd)
103
104 #define HideCaret(hwnd) \
105 NtUserHideCaret(hwnd)
106
107 /* Internal Thread Data */
108 extern HINSTANCE User32Instance;
109 #define user32_module User32Instance
110 extern HINSTANCE hImmInstance;
111
112 /* Critical Section*/
113 extern RTL_CRITICAL_SECTION User32Crit;
114
115 typedef struct _USER32_TRACKINGLIST {
116 TRACKMOUSEEVENT tme;
117 POINT pos; /* center of hover rectangle */
118 UINT_PTR timer;
119 } USER32_TRACKINGLIST,*PUSER32_TRACKINGLIST;
120
121 typedef struct _USER32_THREAD_DATA
122 {
123 USER32_TRACKINGLIST tracking_info; /* TrackMouseEvent stuff */
124 } USER32_THREAD_DATA, *PUSER32_THREAD_DATA;
125
126 PUSER32_THREAD_DATA User32GetThreadData();
127
128 /* FIXME: Belongs to some header. */
129 BOOL WINAPI GdiDllInitialize(HANDLE, DWORD, LPVOID);
130 void InitStockObjects(void);
131 VOID DeleteFrameBrushes(VOID);
132
133 /* message spy definitions */
134 #define SPY_DISPATCHMESSAGE 0x0101
135 #define SPY_SENDMESSAGE 0x0103
136 #define SPY_DEFWNDPROC 0x0105
137
138 #define SPY_RESULT_OK 0x0001
139 #define SPY_RESULT_INVALIDHWND 0x0003
140 #define SPY_RESULT_DEFWND 0x0005
141
142
143 extern const char *SPY_GetMsgName(UINT msg, HWND hWnd);
144 extern const char *SPY_GetVKeyName(WPARAM wParam);
145 extern void SPY_EnterMessage(INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
146 extern void SPY_ExitMessage(INT iFlag, HWND hwnd, UINT msg,
147 LRESULT lReturn, WPARAM wParam, LPARAM lParam);
148 extern int SPY_Init(void);
149
150
151 /* Validate window handle types */
152 #define VALIDATE_TYPE_FREE 0
153 #define VALIDATE_TYPE_WIN 1
154 #define VALIDATE_TYPE_MENU 2
155 #define VALIDATE_TYPE_CURSOR 3
156 #define VALIDATE_TYPE_MWPOS 4
157 #define VALIDATE_TYPE_HOOK 5
158 #define VALIDATE_TYPE_CALLPROC 7
159 #define VALIDATE_TYPE_ACCEL 8
160 #define VALIDATE_TYPE_MONITOR 12
161 #define VALIDATE_TYPE_EVENT 15
162 #define VALIDATE_TYPE_TIMER 16
163
164 #define FIRST_USER_HANDLE 0x0020 /* first possible value for low word of user handle */
165 #define LAST_USER_HANDLE 0xffef /* last possible value for low word of user handle */
166 #define NB_USER_HANDLES ((LAST_USER_HANDLE - FIRST_USER_HANDLE + 1) >> 1)
167 #define USER_HANDLE_TO_INDEX(hwnd) ((LOWORD(hwnd) - FIRST_USER_HANDLE) >> 1)
168
169 #define USER_HEADER_TO_BODY(ObjectHeader) \
170 ((PVOID)(((PUSER_OBJECT_HEADER)ObjectHeader) + 1))
171
172 #define USER_BODY_TO_HEADER(ObjectBody) \
173 ((PUSER_OBJECT_HEADER)(((PUSER_OBJECT_HEADER)ObjectBody) - 1))
174
175 #define HANDLEENTRY_INDESTROY 1
176
177 typedef struct _USER_HANDLE_ENTRY
178 {
179 void *ptr; /* pointer to object */
180 union
181 {
182 PVOID pi;
183 PTHREADINFO pti; // pointer to Win32ThreadInfo
184 PPROCESSINFO ppi; // pointer to W32ProcessInfo
185 };
186 unsigned char type; /* object type (0 if free) */
187 unsigned char flags;
188 unsigned short generation; /* generation counter */
189 } USER_HANDLE_ENTRY, * PUSER_HANDLE_ENTRY;
190
191 typedef struct _USER_HANDLE_TABLE
192 {
193 PUSER_HANDLE_ENTRY handles;
194 PUSER_HANDLE_ENTRY freelist;
195 int nb_handles;
196 int allocated_handles;
197 } USER_HANDLE_TABLE, * PUSER_HANDLE_TABLE;
198
199 extern PUSER_HANDLE_TABLE gHandleTable;
200 extern PUSER_HANDLE_ENTRY gHandleEntries;
201
202 PUSER_HANDLE_ENTRY FASTCALL GetUser32Handle(HANDLE);
203 PVOID FASTCALL ValidateHandle(HANDLE, UINT);
204
205 #define WIN_GetFullHandle(h) ((HWND)(h))
206
207 #ifndef __ms_va_list
208 # if defined(__x86_64__) && defined (__GNUC__)
209 # define __ms_va_list __builtin_ms_va_list
210 # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
211 # define __ms_va_end(list) __builtin_ms_va_end(list)
212 # else
213 # define __ms_va_list va_list
214 # define __ms_va_start(list,arg) va_start(list,arg)
215 # define __ms_va_end(list) va_end(list)
216 # endif
217 #endif
218
219 #ifdef _MSC_VER
220 #ifndef inline
221 #define inline __inline
222 #endif
223 #endif
224
225 /* Hack away wine hack */
226 #define __TRY if(1)
227 #define __EXCEPT_PAGE_FAULT else
228 #define __ENDTRY
229
230 /* EOF */