source: trunk/src/user32/new/win32wnd.h@ 715

Last change on this file since 715 was 715, checked in by dengert, 26 years ago

window creation, positioning, sizing

File size: 10.2 KB
Line 
1/* $Id: win32wnd.h,v 1.26 1999-08-27 17:50:57 dengert Exp $ */
2/*
3 * Win32 Window Code 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 __WIN32WND_H__
14#define __WIN32WND_H__
15
16#ifdef __cplusplus
17
18#include <win32class.h>
19#include <gen_object.h>
20#include <win32wndchild.h>
21#include <winres.h>
22
23class Win32Window;
24
25#define OFFSET_WIN32WNDPTR 0
26#define OFFSET_WIN32PM_MAGIC 4
27
28#define WIN32PM_MAGIC 0x12345678
29#define CheckMagicDword(a) (a==WIN32PM_MAGIC)
30
31typedef struct {
32 USHORT cb;
33 Win32Window *win32wnd;
34 ULONG win32CreateStruct; //or dialog create dword
35} CUSTOMWNDDATA;
36
37typedef struct
38{
39 ULONG Msg;
40 ULONG wParam;
41 ULONG lParam;
42} POSTMSG_PACKET;
43
44#define WM_WIN32_POSTMESSAGEA 0x4000
45#define WM_WIN32_POSTMESSAGEW 0x4001
46
47#define MAX_WINDOW_NAMELENGTH 256
48
49class Win32Window : private GenericObject, private ChildWindow
50{
51public:
52 DWORD magic;
53
54 Win32Window(DWORD objType);
55 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
56virtual ~Win32Window();
57
58virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
59 ULONG MsgQuit();
60 ULONG MsgClose();
61 ULONG MsgDestroy();
62 ULONG MsgEnable(BOOL fEnable);
63 ULONG MsgShow(BOOL fShow);
64 ULONG MsgPosChanging(LPARAM lp);
65 ULONG MsgPosChanged(LPARAM lp);
66 ULONG MsgMove(ULONG x, ULONG y);
67 ULONG MsgHitTest(ULONG x, ULONG y);
68 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
69 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
70 ULONG MsgSetFocus(HWND hwnd);
71 ULONG MsgKillFocus(HWND hwnd);
72 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
73 ULONG MsgSysCommand(ULONG win32sc, ULONG x, ULONG y);
74 ULONG MsgChar(ULONG cmd, ULONG repeatcnt, ULONG scancode, ULONG vkey, ULONG keyflags);
75 ULONG MsgButton(ULONG msg, ULONG ncx, ULONG ncy, ULONG clx, ULONG cly);
76 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
77 ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
78 ULONG MsgEraseBackGround(HDC hdc);
79 ULONG MsgSetText(LPSTR lpsz, LONG cch);
80 ULONG MsgGetTextLength();
81 char *MsgGetText();
82
83virtual LONG SetWindowLongA(int index, ULONG value);
84virtual ULONG GetWindowLongA(int index);
85virtual WORD SetWindowWord(int index, WORD value);
86virtual WORD GetWindowWord(int index);
87
88 DWORD getStyle() { return dwStyle; };
89 DWORD getExStyle() { return dwExStyle; };
90 HWND getWindowHandle() { return Win32Hwnd; };
91 HWND getOS2WindowHandle() { return OS2Hwnd; };
92 HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
93 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
94 Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
95 void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
96 WNDPROC getWindowProc() { return win32wndproc; };
97 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
98 DWORD getWindowId() { return windowId; };
99 void setWindowId(DWORD id) { windowId = id; };
100 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
101 BOOL isChild();
102 PRECT getClientRect() { return &rectClient; };
103 PRECT getWindowRect() { return &rectWindow; };
104void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
105{ rectClient.left = left; rectClient.top = top;
106 rectClient.right = right; rectClient.bottom = bottom;
107};
108void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
109{ rectWindow.left = left; rectWindow.top = top;
110 rectWindow.right = right; rectWindow.bottom = bottom;
111};
112 void setWindowRect(PRECT rect) { rectWindow = *rect; };
113
114 DWORD getFlags() { return flags; };
115 void setFlags(DWORD newflags) { flags = newflags; };
116
117 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
118 BOOL SetAccelTable(ULONG hAccel);
119
120 HMENU GetMenu() { return (HMENU) menuResource; };
121 BOOL SetMenu(ULONG hMenu);
122
123 BOOL SetIcon(HICON hIcon);
124 HICON GetIcon() { return (HICON) iconResource; };
125
126 BOOL ShowWindow(ULONG nCmdShow);
127 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
128 BOOL DestroyWindow();
129 HWND SetActiveWindow();
130 HWND GetParent();
131 HWND SetParent(HWND hwndNewParent);
132 BOOL IsChild(HWND hwndParent);
133 HWND GetTopWindow();
134 BOOL UpdateWindow();
135 BOOL IsIconic();
136 HWND GetWindow(UINT uCmd);
137 BOOL EnableWindow(BOOL fEnable);
138 BOOL CloseWindow();
139 static HWND GetActiveWindow();
140 BOOL IsWindow();
141 BOOL IsWindowEnabled();
142 BOOL IsWindowVisible();
143 BOOL IsUnicode() { return isUnicode; };
144
145 BOOL GetWindowRect(PRECT pRect);
146 int GetWindowTextLengthA();
147 int GetWindowTextA(LPSTR lpsz, int cch);
148 BOOL SetWindowTextA(LPCSTR lpsz);
149
150 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
151 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
152 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
153 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
154 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
155 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
156
157 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
158
159Win32WndClass *getClass() { return windowClass; };
160
161static HWND Win32ToOS2Handle(HWND hwnd)
162{
163 Win32Window *window = GetWindowFromHandle(hwnd);
164
165 if(window) {
166 return window->getOS2WindowHandle();
167 }
168 else return hwnd; //OS/2 window handle
169}
170
171static HWND OS2ToWin32Handle(HWND hwnd)
172{
173 Win32Window *window = GetWindowFromOS2Handle(hwnd);
174
175 if(window) {
176 return window->getWindowHandle();
177 }
178 else return hwnd; //OS/2 window handle
179}
180
181static Win32Window *GetWindowFromHandle(HWND hwnd);
182static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
183
184protected:
185 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
186 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
187 void Init();
188
189 HWND OS2Hwnd;
190 HWND OS2HwndFrame;
191 HWND OS2HwndMenu;
192 HWND Win32Hwnd;
193 BOOL isUnicode;
194
195 int posx, posy, width, height;
196
197 // values normally contained in the standard window words
198 ULONG dwExStyle; //GWL_EXSTYLE
199 ULONG dwStyle; //GWL_STYLE
200 WNDPROC win32wndproc; //GWL_WNDPROC
201 ULONG hInstance; //GWL_HINSTANCE
202//Moved in ChildWindow class
203///// Win32Window *parent; //GWL_HWNDPARENT
204 ULONG windowId; //GWL_ID
205 ULONG userData; //GWL_USERDATA
206
207 HWND hwndLinkAfter;
208 DWORD flags;
209 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
210
211 BOOL isIcon;
212 BOOL fCreated;
213 BOOL fFirstShow;
214
215 Win32Window *owner;
216
217 Win32Resource *acceltableResource;
218 Win32Resource *menuResource;
219 Win32Resource *iconResource;
220
221 char windowNameA[MAX_WINDOW_NAMELENGTH];
222 WCHAR windowNameW[MAX_WINDOW_NAMELENGTH];
223 ULONG wndNameLength;
224
225 ULONG *userWindowLong;
226 ULONG nrUserWindowLong;
227
228 RECT rectWindow;
229 RECT rectClient;
230
231Win32WndClass *windowClass;
232
233static GenericObject *windows;
234
235private:
236#ifndef OS2_INCLUDED
237 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
238
239 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
240
241 LONG SendNCCalcSize(BOOL calcValidRect,
242 RECT *newWindowRect, RECT *oldWindowRect,
243 RECT *oldClientRect, WINDOWPOS *winpos,
244 RECT *newClientRect );
245
246 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
247 {
248 if(isUnicode)
249 return SendInternalMessageW(msg, wParam, lParam);
250 else return SendInternalMessageA(msg, wParam, lParam);
251 }
252#endif
253};
254
255
256#define BUTTON_LEFTDOWN 0
257#define BUTTON_LEFTUP 1
258#define BUTTON_LEFTDBLCLICK 2
259#define BUTTON_RIGHTUP 3
260#define BUTTON_RIGHTDOWN 4
261#define BUTTON_RIGHTDBLCLICK 5
262#define BUTTON_MIDDLEUP 6
263#define BUTTON_MIDDLEDOWN 7
264#define BUTTON_MIDDLEDBLCLICK 8
265
266#define WMMOVE_LBUTTON 1
267#define WMMOVE_MBUTTON 2
268#define WMMOVE_RBUTTON 4
269#define WMMOVE_CTRL 8
270#define WMMOVE_SHIFT 16
271
272
273#define CMD_MENU 1
274#define CMD_CONTROL 2
275#define CMD_ACCELERATOR 3
276
277#define WIN32SC_SIZE 0xf000
278#define WIN32SC_MOVE 0xf010
279#define WIN32SC_MINIMIZE 0xf020
280#define WIN32SC_MAXIMIZE 0xf030
281#define WIN32SC_NEXTWINDOW 0xf040
282#define WIN32SC_PREVWINDOW 0xf050
283#define WIN32SC_CLOSE 0xf060
284#define WIN32SC_VSCROLL 0xf070
285#define WIN32SC_HSCROLL 0xf080
286#define WIN32SC_MOUSEMENU 0xf090
287#define WIN32SC_KEYMENU 0xf100
288#define WIN32SC_ARRANGE 0xf110
289#define WIN32SC_RESTORE 0xf120
290#define WIN32SC_TASKLIST 0xf130
291#define WIN32SC_SCREENSAVE 0xf140
292#define WIN32SC_HOTKEY 0xf150
293
294#define KEY_ALTDOWN 1
295#define KEY_PREVDOWN 2
296#define KEY_UP 4
297#define KEY_DEADKEY 8
298
299#endif //__cplusplus
300
301#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.