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

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

* empty log message *

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