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

Last change on this file since 1801 was 1801, checked in by cbratschi, 26 years ago

fixed window text handling

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