source: trunk/src/user32/win32wbase.h@ 2013

Last change on this file since 2013 was 2006, checked in by sandervl, 26 years ago

Misc fixes for repaint problems

File size: 16.5 KB
Line 
1/* $Id: win32wbase.h,v 1.50 1999-12-07 12:26:59 sandervl Exp $ */
2/*
3 * Win32 Window Base Class for OS/2
4 *
5 *
6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 * Copyright 1999 Daniela Engert (dani@ngrt.de)
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13#ifndef __WIN32WNDBASE_H__
14#define __WIN32WNDBASE_H__
15
16#ifdef __cplusplus
17
18#include <win32class.h>
19#include "open32wbase.h"
20#include <gen_object.h>
21#include <win32wndchild.h>
22#include <winres.h>
23#include <winconst.h>
24#include <scroll.h>
25
26class Win32BaseWindow;
27
28#define OFFSET_WIN32WNDPTR 0
29#define OFFSET_WIN32PM_MAGIC 4
30#define NROF_WIN32WNDBYTES 8
31
32#define WIN32PM_MAGIC 0x12345678
33#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
34
35typedef struct {
36 USHORT cb;
37 Win32BaseWindow *win32wnd;
38 ULONG win32CreateStruct; //or dialog create dword
39} CUSTOMWNDDATA;
40
41#define WIN32APP_USERMSGBASE 0x1000
42#define WIN32APP_POSTMSG 0x6666
43
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49 ULONG fUnicode;
50} POSTMSG_PACKET;
51
52#define WM_WIN32_POSTMESSAGEA 0x4000
53#define WM_WIN32_POSTMESSAGEW 0x4001
54
55#define BROADCAST_SEND 0
56#define BROADCAST_POST 1
57
58class Win32BaseWindow : public GenericObject, public ChildWindow
59{
60public:
61 DWORD magic;
62
63 Win32BaseWindow(DWORD objType);
64 Win32BaseWindow(HWND os2Handle,VOID* win32WndProc);
65 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
66virtual ~Win32BaseWindow();
67
68virtual ULONG MsgCreate(HWND hwndFrame, HWND hwndClient);
69 ULONG MsgQuit();
70 ULONG MsgClose();
71 ULONG MsgDestroy();
72virtual ULONG MsgEnable(BOOL fEnable);
73 ULONG MsgShow(BOOL fShow);
74 ULONG MsgPosChanging(LPARAM lp);
75 ULONG MsgPosChanged(LPARAM lp);
76 ULONG MsgMove(ULONG x, ULONG y);
77 ULONG MsgHitTest(ULONG x, ULONG y);
78 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
79virtual ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd);
80 ULONG MsgSetFocus(HWND hwnd);
81 ULONG MsgKillFocus(HWND hwnd);
82 ULONG MsgTimer(ULONG TimerID);
83 ULONG MsgSysTimer(ULONG TimerID);
84 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
85 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
86 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
87 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
88 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
89 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
90 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
91 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
92 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
93 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
94 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
95 ULONG MsgEraseBackGround(HDC hdc);
96 ULONG MsgSetText(LPSTR lpsz, LONG cch);
97 ULONG MsgGetTextLength();
98 char *MsgGetText();
99 ULONG MsgContextMenu(ULONG x,ULONG y);
100
101 VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
102
103virtual LONG SetWindowLongA(int index, ULONG value);
104virtual ULONG GetWindowLongA(int index);
105virtual WORD SetWindowWord(int index, WORD value);
106virtual WORD GetWindowWord(int index);
107
108 DWORD getStyle() { return dwStyle; };
109 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
110 DWORD getExStyle() { return dwExStyle; };
111 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
112 HWND getWindowHandle() { return Win32Hwnd; };
113 HWND getOS2WindowHandle() { return OS2Hwnd; };
114 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
115 Win32WndClass *getWindowClass() { return windowClass; };
116
117 DWORD getWindowContextHelpId() { return contextHelpId; };
118 void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
119
120 BOOL isFrameWindow();
121virtual BOOL isMDIClient();
122virtual BOOL isMDIChild();
123
124Win32BaseWindow *getParent();
125 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
126 WNDPROC getWindowProc() { return win32wndproc; };
127 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
128 DWORD getWindowId() { return windowId; };
129 void setWindowId(DWORD id);
130 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
131 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
132 BOOL isChild();
133 PRECT getClientRect() { return &rectClient; };
134 void setClientRect(PRECT rect) { rectClient = *rect; };
135 PRECT getWindowRect() { return &rectWindow; };
136 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
137 {
138 rectClient.left = left; rectClient.top = top;
139 rectClient.right = right; rectClient.bottom = bottom;
140 };
141 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
142 {
143 rectWindow.left = left; rectWindow.top = top;
144 rectWindow.right = right; rectWindow.bottom = bottom;
145 };
146 void setWindowRect(PRECT rect) { rectWindow = *rect; };
147 DWORD getFlags() { return flags; };
148 void setFlags(DWORD newflags) { flags = newflags; };
149
150 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
151 BOOL SetAccelTable(ULONG hAccel);
152
153 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
154 BOOL SetMenu(ULONG hMenu);
155
156 BOOL SetIcon(HICON hIcon);
157 HICON GetIcon() { return (HICON) iconResource; };
158
159 BOOL ShowWindow(ULONG nCmdShow);
160 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
161 BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
162 BOOL DestroyWindow();
163 HWND SetActiveWindow();
164 HWND GetParent();
165 HWND SetParent(HWND hwndNewParent);
166 BOOL IsChild(HWND hwndParent);
167 HWND GetTopWindow();
168Win32BaseWindow *GetTopParent();
169 BOOL UpdateWindow();
170 BOOL IsIconic();
171 HWND GetWindow(UINT uCmd);
172 virtual BOOL EnableWindow(BOOL fEnable);
173 BOOL CloseWindow();
174 static HWND GetActiveWindow();
175 //Window handle has already been verified, so just return true
176 BOOL IsWindow() { return TRUE; };
177 BOOL IsDialog() { return fIsDialog; };
178 BOOL IsModalDialog() { return fIsModalDialog; };
179 BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
180 VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
181 VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
182 HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
183 BOOL CanReceiveSizeMsgs() { return !fNoSizeMsg; };
184 BOOL IsWindowDestroyed() { return fIsDestroyed; };
185 BOOL IsWindowEnabled();
186 BOOL IsWindowVisible();
187 BOOL IsUnicode() { return isUnicode; };
188 BOOL GetWindowRect(PRECT pRect);
189 int GetWindowTextLength();
190 int GetWindowTextA(LPSTR lpsz, int cch);
191 int GetWindowTextW(LPWSTR lpsz, int cch);
192 BOOL SetWindowTextA(LPSTR lpsz);
193 BOOL SetWindowTextW(LPWSTR lpsz);
194 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
195Win32WndClass *getClass() { return windowClass; };
196 char *getWindowNameA() { return windowNameA; };
197Win32BaseWindow *getOwner() { return owner; };
198
199 SCROLLBAR_INFO *getScrollInfo(int nBar);
200 HWND getVertScrollHandle() { return hwndVertScroll; };
201 VOID setVertScrollHandle(HWND newHandle) { hwndVertScroll = newHandle; }
202 HWND getHorzScrollHandle() { return hwndHorzScroll; };
203 VOID setHorzScrollHandle(HWND newHandle) { hwndHorzScroll = newHandle; }
204 VOID subclassScrollBars(BOOL subHorz,BOOL subVert);
205 BOOL showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow);
206
207 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
208 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
209 LRESULT SendMessageToProcess(UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode);
210 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
211 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
212 void PostMessage(POSTMSG_PACKET *packet);
213static BOOL PostThreadMessageA(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam);
214static BOOL PostThreadMessageW(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam);
215static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
216static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
217
218 LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam, BOOL fReentered = FALSE);
219 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
220
221 LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
222
223 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
224
225Win32BaseWindow *FindWindowById(int id);
226
227 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
228 BOOL fUnicode = 0);
229
230 BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
231 BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
232 BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
233
234 HWND getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious);
235 HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
236
237 static HWND Win32ToOS2Handle(HWND hwnd);
238 static HWND Win32ToOS2FrameHandle(HWND hwnd);
239 static HWND OS2ToWin32Handle(HWND hwnd);
240
241static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
242static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
243static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
244
245 static void DestroyAll();
246
247 PVOID getOldFrameProc() { return pOldFrameProc; };
248 VOID setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
249 ULONG getBorderWidth() { return borderWidth; };
250 ULONG getBorderHeight() { return borderHeight; };
251
252static void NC_AdjustRectInner(LPRECT rect, DWORD style, DWORD exStyle);
253static void NC_AdjustRectOuter(LPRECT rect, DWORD style, BOOL menu, DWORD exStyle);
254static BOOL WindowNeedsWMBorder( DWORD style, DWORD exStyle );
255
256 PVOID getOldWndProc() { return pOldWndProc; }
257 VOID setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
258 BOOL isSubclassedOS2Wnd() { return fIsSubclassedOS2Wnd; };
259
260protected:
261#ifndef OS2_INCLUDED
262 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
263#endif
264 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
265 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
266 void Init();
267 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
268
269 HWND OS2Hwnd;
270 HWND OS2HwndFrame;
271 HWND OS2HwndMenu;
272 HWND Win32Hwnd;
273 BOOL isUnicode;
274
275 int posx, posy, width, height;
276
277 // values normally contained in the standard window words
278 ULONG dwExStyle; //GWL_EXSTYLE
279 ULONG dwStyle; //GWL_STYLE
280 WNDPROC win32wndproc; //GWL_WNDPROC
281 ULONG hInstance; //GWL_HINSTANCE
282//Moved in ChildWindow class
283///// Win32BaseWindow *parent; //GWL_HWNDPARENT
284 ULONG windowId; //GWL_ID
285 ULONG userData; //GWL_USERDATA
286
287 HWND hwndLinkAfter;
288 DWORD flags;
289 DWORD contextHelpId;
290 LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
291
292 BOOL isIcon;
293 BOOL fFirstShow;
294 BOOL fIsDialog;
295 BOOL fIsModalDialog;
296 BOOL fIsModalDialogOwner;
297 HWND OS2HwndModalDialog;
298 BOOL fInternalMsg; //Used to distinguish between messages
299 //sent by PM and those sent by apps
300 BOOL fNoSizeMsg;
301 BOOL fIsDestroyed;
302 BOOL fCreated;
303 BOOL fTaskList; //should be listed in PM tasklist or not
304
305 PVOID pOldFrameProc;
306 ULONG borderWidth;
307 ULONG borderHeight;
308
309 PVOID pOldWndProc;
310 BOOL fIsSubclassedOS2Wnd; //subclassed OS/2 window: Netscape plug-in/scrollbar
311
312 Win32BaseWindow *owner;
313
314 Win32Resource *acceltableResource;
315 Win32Resource *iconResource;
316
317 char *windowNameA;
318 WCHAR *windowNameW;
319 ULONG wndNameLength; //including 0 terminator
320
321 ULONG *userWindowLong;
322 ULONG nrUserWindowLong;
323
324 RECT rectWindow;
325 RECT rectClient;
326
327CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
328 ULONG sw; //set in CreateWindowExA, used in MsgCreate method
329
330SCROLLBAR_INFO *vertScrollInfo;
331SCROLLBAR_INFO *horzScrollInfo;
332 HWND hwndHorzScroll; //os/2 handle
333 HWND hwndVertScroll; //os/2 handle
334
335Win32WndClass *windowClass;
336
337static GenericObject *windows;
338
339private:
340#ifndef OS2_INCLUDED
341 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
342 LONG HandleWindowPosChanging(WINDOWPOS *winpos);
343 LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
344
345 LONG SendNCCalcSize(BOOL calcValidRect,
346 RECT *newWindowRect, RECT *oldWindowRect,
347 RECT *oldClientRect, WINDOWPOS *winpos,
348 RECT *newClientRect );
349
350 LONG NCHandleCalcSize(WPARAM wParam, NCCALCSIZE_PARAMS *ncsize);
351
352 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
353 {
354 if(isUnicode)
355 return SendInternalMessageW(msg, wParam, lParam);
356 else return SendInternalMessageA(msg, wParam, lParam);
357 }
358#endif
359
360public:
361 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
362 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
363
364 fakeOpen32WinBaseClass fakeWinBase;
365
366// BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
367 BOOL isOwnDC() { return FALSE; }
368 HDC getOwnDC() { return ownDC; }
369 void setOwnDC(HDC hdc) { ownDC = hdc; }
370protected:
371 HDC ownDC;
372
373 ULONG EraseBkgndFlag:1,
374 PSEraseFlag:1,
375 SupressEraseFlag:1,
376 filler:29;
377public:
378 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
379 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
380 VOID setSupressErase (BOOL erase = FALSE)
381 { SupressEraseFlag = erase; }
382 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
383 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
384 BOOL isSupressErase() { return SupressEraseFlag; }
385};
386
387
388#define BUTTON_LEFTDOWN 0
389#define BUTTON_LEFTUP 1
390#define BUTTON_LEFTDBLCLICK 2
391#define BUTTON_RIGHTUP 3
392#define BUTTON_RIGHTDOWN 4
393#define BUTTON_RIGHTDBLCLICK 5
394#define BUTTON_MIDDLEUP 6
395#define BUTTON_MIDDLEDOWN 7
396#define BUTTON_MIDDLEDBLCLICK 8
397
398#define WMMOVE_LBUTTON 1
399#define WMMOVE_MBUTTON 2
400#define WMMOVE_RBUTTON 4
401#define WMMOVE_CTRL 8
402#define WMMOVE_SHIFT 16
403
404
405#define CMD_MENU 1
406#define CMD_CONTROL 2
407#define CMD_ACCELERATOR 3
408
409#define KEY_ALTDOWN 1
410#define KEY_PREVDOWN 2
411#define KEY_UP 4
412#define KEY_DEADKEY 8
413
414#endif //__cplusplus
415
416#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.