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

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

Scrollbar changes

File size: 12.3 KB
Line 
1/* $Id: win32wbase.h,v 1.9 1999-09-29 08:27:16 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 OFFSET_WIN32PM_SHAREDMEM 8
31#define NROF_WIN32WNDBYTES 12
32
33#define WIN32PM_MAGIC 0x12345678
34#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
35
36#define WIN32APP_USERMSGBASE 0x1000
37
38typedef struct {
39 USHORT cb;
40 Win32BaseWindow *win32wnd;
41 ULONG win32CreateStruct; //or dialog create dword
42} CUSTOMWNDDATA;
43
44typedef struct
45{
46 ULONG Msg;
47 ULONG wParam;
48 ULONG lParam;
49} POSTMSG_PACKET;
50
51#define WM_WIN32_POSTMESSAGEA 0x4000
52#define WM_WIN32_POSTMESSAGEW 0x4001
53
54class Win32BaseWindow : public GenericObject, public ChildWindow
55{
56public:
57 DWORD magic;
58
59 Win32BaseWindow(DWORD objType);
60 Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
61virtual ~Win32BaseWindow();
62
63virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
64 ULONG MsgQuit();
65 ULONG MsgClose();
66 ULONG MsgDestroy();
67 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);
74 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
75 ULONG MsgSetFocus(HWND hwnd);
76 ULONG MsgKillFocus(HWND hwnd);
77 ULONG MsgTimer(ULONG TimerID);
78 ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
79 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
80 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
81 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
82 ULONG MsgKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
83 ULONG MsgKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
84 ULONG MsgSysKeyUp (ULONG repeatCount, ULONG scancode, ULONG virtualKey);
85 ULONG MsgSysKeyDown (ULONG repeatCount, ULONG scancode, ULONG virtualKey, BOOL keyWasPressed);
86 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
87 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
88 ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
89 ULONG MsgEraseBackGround(HDC hdc);
90 ULONG MsgSetText(LPSTR lpsz, LONG cch);
91 ULONG MsgGetTextLength();
92 char *MsgGetText();
93
94virtual LONG SetWindowLongA(int index, ULONG value);
95virtual ULONG GetWindowLongA(int index);
96virtual WORD SetWindowWord(int index, WORD value);
97virtual WORD GetWindowWord(int index);
98
99 DWORD getStyle() { return dwStyle; };
100 void setStyle(DWORD newstyle) { dwStyle = newstyle; };
101 DWORD getExStyle() { return dwExStyle; };
102 void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
103 HWND getWindowHandle() { return Win32Hwnd; };
104 HWND getOS2WindowHandle() { return OS2Hwnd; };
105 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
106 Win32WndClass *getWindowClass() { return windowClass; };
107
108 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
109Win32BaseWindow *getParent() { return (Win32BaseWindow *)ChildWindow::GetParent(); };
110 void setParent(Win32BaseWindow *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
111 WNDPROC getWindowProc() { return win32wndproc; };
112 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
113 DWORD getWindowId() { return windowId; };
114 void setWindowId(DWORD id) { windowId = id; };
115 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
116 ULONG getWindowWidth() { return rectClient.right - rectClient.left; };
117 BOOL isChild();
118 PRECT getClientRect() { return &rectClient; };
119 void setClientRect(PRECT rect) { rectClient = *rect; };
120 PRECT getWindowRect() { return &rectWindow; };
121 void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
122 {
123 rectClient.left = left; rectClient.top = top;
124 rectClient.right = right; rectClient.bottom = bottom;
125 };
126 void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
127 {
128 rectWindow.left = left; rectWindow.top = top;
129 rectWindow.right = right; rectWindow.bottom = bottom;
130 };
131 void setWindowRect(PRECT rect) { rectWindow = *rect; };
132 DWORD getFlags() { return flags; };
133 void setFlags(DWORD newflags) { flags = newflags; };
134
135 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
136 BOOL SetAccelTable(ULONG hAccel);
137
138 HMENU GetMenu() { return (HMENU) OS2HwndMenu; };
139 BOOL SetMenu(ULONG hMenu);
140
141 BOOL SetIcon(HICON hIcon);
142 HICON GetIcon() { return (HICON) iconResource; };
143
144 BOOL ShowWindow(ULONG nCmdShow);
145 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
146 BOOL DestroyWindow();
147 HWND SetActiveWindow();
148 HWND GetParent();
149 HWND SetParent(HWND hwndNewParent);
150 BOOL IsChild(HWND hwndParent);
151 HWND GetTopWindow();
152 BOOL UpdateWindow();
153 BOOL IsIconic();
154 HWND GetWindow(UINT uCmd);
155 BOOL EnableWindow(BOOL fEnable);
156 BOOL CloseWindow();
157 static HWND GetActiveWindow();
158 //Window handle has already been verified, so just return true
159 BOOL IsWindow() { return TRUE; };
160 BOOL IsDialog() { return fIsDialog; };
161
162 BOOL IsWindowEnabled();
163 BOOL IsWindowVisible();
164 BOOL IsUnicode() { return isUnicode; };
165 BOOL GetWindowRect(PRECT pRect);
166 int GetWindowTextLength();
167 int GetWindowTextA(LPSTR lpsz, int cch);
168 int GetWindowTextW(LPWSTR lpsz, int cch);
169 BOOL SetWindowTextA(LPSTR lpsz);
170 BOOL SetWindowTextW(LPWSTR lpsz);
171 BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
172Win32WndClass *getClass() { return windowClass; };
173 char *getWindowNameA() { return windowNameA; };
174Win32BaseWindow *getOwner() { return owner; };
175
176Win32BaseWindow *getTopParent();
177 SCROLLBAR_INFO *getScrollInfo(int nBar);
178 LONG setScrollInfo(int nBar, SCROLLINFO *info, int fRedraw);
179
180 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
181 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
182 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
183 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
184 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
185 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
186
187 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
188
189 static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
190 BOOL fUnicode = 0);
191
192 static HWND Win32ToOS2Handle(HWND hwnd);
193 static HWND OS2ToWin32Handle(HWND hwnd);
194
195static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
196static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
197
198protected:
199#ifndef OS2_INCLUDED
200 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
201#endif
202 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
203 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
204 void Init();
205 void setExtendedKey(ULONG virtualkey, ULONG *lParam);
206
207 HWND OS2Hwnd;
208 HWND OS2HwndFrame;
209 HWND OS2HwndMenu;
210 HWND Win32Hwnd;
211 BOOL isUnicode;
212
213 int posx, posy, width, height;
214
215 // values normally contained in the standard window words
216 ULONG dwExStyle; //GWL_EXSTYLE
217 ULONG dwStyle; //GWL_STYLE
218 WNDPROC win32wndproc; //GWL_WNDPROC
219 ULONG hInstance; //GWL_HINSTANCE
220//Moved in ChildWindow class
221///// Win32BaseWindow *parent; //GWL_HWNDPARENT
222 ULONG windowId; //GWL_ID
223 ULONG userData; //GWL_USERDATA
224
225 HWND hwndLinkAfter;
226 DWORD flags;
227 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
228
229 BOOL isIcon;
230 BOOL fCreated;
231 BOOL fFirstShow;
232 BOOL fIsDialog;
233
234 Win32BaseWindow *owner;
235
236 Win32Resource *acceltableResource;
237 Win32Resource *iconResource;
238
239 char *windowNameA;
240 WCHAR *windowNameW;
241 ULONG wndNameLength; //including 0 terminator
242
243 ULONG *userWindowLong;
244 ULONG nrUserWindowLong;
245
246 RECT rectWindow;
247 RECT rectClient;
248
249SCROLLBAR_INFO *vertScrollInfo;
250SCROLLBAR_INFO *horzScrollInfo;
251
252Win32WndClass *windowClass;
253
254static GenericObject *windows;
255
256private:
257#ifndef OS2_INCLUDED
258 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
259
260 LONG SendNCCalcSize(BOOL calcValidRect,
261 RECT *newWindowRect, RECT *oldWindowRect,
262 RECT *oldClientRect, WINDOWPOS *winpos,
263 RECT *newClientRect );
264
265 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
266 {
267 if(isUnicode)
268 return SendInternalMessageW(msg, wParam, lParam);
269 else return SendInternalMessageA(msg, wParam, lParam);
270 }
271#endif
272
273public:
274 void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
275 void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
276
277 fakeOpen32WinBaseClass fakeWinBase;
278
279 BOOL isOwnDC() { return (windowClass->getStyle() & CS_OWNDC_W); }
280 HDC getOwnDC() { return ownDC; }
281 void setOwnDC(HDC hdc) { ownDC = hdc; }
282protected:
283 HDC ownDC;
284
285 ULONG EraseBkgndFlag:1,
286 PSEraseFlag:1,
287 SupressEraseFlag:1,
288 filler:29;
289public:
290 VOID setEraseBkgnd (BOOL erase, BOOL PSErase = FALSE)
291 { EraseBkgndFlag = erase; PSEraseFlag = PSErase; }
292 VOID setSupressErase (BOOL erase = FALSE)
293 { SupressEraseFlag = erase; }
294 BOOL isEraseBkgnd() { return EraseBkgndFlag; }
295 BOOL isPSErase() { return EraseBkgndFlag | PSEraseFlag; }
296 BOOL isSupressErase() { return SupressEraseFlag; }
297};
298
299
300#define BUTTON_LEFTDOWN 0
301#define BUTTON_LEFTUP 1
302#define BUTTON_LEFTDBLCLICK 2
303#define BUTTON_RIGHTUP 3
304#define BUTTON_RIGHTDOWN 4
305#define BUTTON_RIGHTDBLCLICK 5
306#define BUTTON_MIDDLEUP 6
307#define BUTTON_MIDDLEDOWN 7
308#define BUTTON_MIDDLEDBLCLICK 8
309
310#define WMMOVE_LBUTTON 1
311#define WMMOVE_MBUTTON 2
312#define WMMOVE_RBUTTON 4
313#define WMMOVE_CTRL 8
314#define WMMOVE_SHIFT 16
315
316
317#define CMD_MENU 1
318#define CMD_CONTROL 2
319#define CMD_ACCELERATOR 3
320
321#define KEY_ALTDOWN 1
322#define KEY_PREVDOWN 2
323#define KEY_UP 4
324#define KEY_DEADKEY 8
325
326#endif //__cplusplus
327
328#endif //__WIN32WNDBASE_H__
Note: See TracBrowser for help on using the repository browser.