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

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

Lots of changes; Solitaire now starts

File size: 8.2 KB
Line 
1/* $Id: win32wnd.h,v 1.19 1999-07-25 15:51:56 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
99 DWORD getFlags() { return flags; };
100 void setFlags(DWORD newflags) { flags = newflags; };
101
102 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
103 BOOL SetAccelTable(ULONG hAccel);
104
105 HMENU GetMenu() { return (HMENU) menuResource; };
106 BOOL SetMenu(ULONG hMenu);
107
108 BOOL SetIcon(HICON hIcon);
109 HICON GetIcon() { return (HICON) iconResource; };
110
111 BOOL ShowWindow(ULONG nCmdShow);
112 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
113 BOOL DestroyWindow();
114 HWND SetActiveWindow();
115 HWND GetParent();
116 HWND SetParent(HWND hwndNewParent);
117 BOOL IsChild(HWND hwndParent);
118 HWND GetTopWindow();
119 BOOL UpdateWindow();
120 BOOL IsIconic();
121 HWND GetWindow(UINT uCmd);
122 BOOL EnableWindow(BOOL fEnable);
123 BOOL CloseWindow();
124 BOOL BringWindowToTop();
125 static HWND GetActiveWindow();
126 BOOL IsWindow();
127 BOOL IsWindowEnabled();
128 BOOL IsWindowVisible();
129 BOOL IsUnicode() { return isUnicode; };
130
131 BOOL GetWindowRect(PRECT pRect);
132 int GetWindowTextLengthA();
133 int GetWindowTextA(LPSTR lpsz, int cch);
134 BOOL SetWindowTextA(LPCSTR lpsz);
135
136 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
137 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
138 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
139 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
140 LRESULT DefWindowProcA(UINT msg, WPARAM wParam, LPARAM lParam);
141 LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
142
143 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
144
145Win32WndClass *getClass() { return windowClass; };
146
147static HWND Win32ToOS2Handle(HWND hwnd)
148{
149 Win32Window *window = GetWindowFromHandle(hwnd);
150
151 if(window) {
152 return window->getOS2WindowHandle();
153 }
154 else return hwnd; //OS/2 window handle
155}
156
157static HWND OS2ToWin32Handle(HWND hwnd)
158{
159 Win32Window *window = GetWindowFromOS2Handle(hwnd);
160
161 if(window) {
162 return window->getWindowHandle();
163 }
164 else return hwnd; //OS/2 window handle
165}
166
167static Win32Window *GetWindowFromHandle(HWND hwnd);
168static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
169
170protected:
171 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
172 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
173 void Init();
174
175 HWND OS2Hwnd;
176 HWND OS2HwndFrame;
177 HWND OS2HwndMenu;
178 HWND Win32Hwnd;
179 BOOL isUnicode;
180
181 int posx, posy, width, height;
182
183 // values normally contained in the standard window words
184 ULONG dwExStyle; //GWL_EXSTYLE
185 ULONG dwStyle; //GWL_STYLE
186 WNDPROC win32wndproc; //GWL_WNDPROC
187 ULONG hInstance; //GWL_HINSTANCE
188//Moved in ChildWindow class
189///// Win32Window *parent; //GWL_HWNDPARENT
190 ULONG windowId; //GWL_ID
191 ULONG userData; //GWL_USERDATA
192
193 HWND hwndLinkAfter;
194 DWORD flags;
195 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
196
197 BOOL isIcon;
198 BOOL fCreated;
199
200 Win32Window *owner;
201
202 Win32Resource *acceltableResource;
203 Win32Resource *menuResource;
204 Win32Resource *iconResource;
205
206 char windowNameA[MAX_WINDOW_NAMELENGTH];
207 WCHAR windowNameW[MAX_WINDOW_NAMELENGTH];
208 ULONG wndNameLength;
209
210 ULONG *userWindowLong;
211 ULONG nrUserWindowLong;
212
213 RECT rectWindow;
214 RECT rectClient;
215
216Win32WndClass *windowClass;
217
218static GenericObject *windows;
219
220private:
221#ifndef OS2_INCLUDED
222 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
223
224 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
225
226 LONG SendNCCalcSize(BOOL calcValidRect,
227 RECT *newWindowRect, RECT *oldWindowRect,
228 RECT *oldClientRect, WINDOWPOS *winpos,
229 RECT *newClientRect );
230
231 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
232 {
233 if(isUnicode)
234 return SendInternalMessageW(msg, wParam, lParam);
235 else return SendInternalMessageA(msg, wParam, lParam);
236 }
237#endif
238};
239
240
241#define BUTTON_LEFTDOWN 0
242#define BUTTON_LEFTUP 1
243#define BUTTON_LEFTDBLCLICK 2
244#define BUTTON_RIGHTUP 3
245#define BUTTON_RIGHTDOWN 4
246#define BUTTON_RIGHTDBLCLICK 5
247#define BUTTON_MIDDLEUP 6
248#define BUTTON_MIDDLEDOWN 7
249#define BUTTON_MIDDLEDBLCLICK 8
250
251#define WMMOVE_LBUTTON 1
252#define WMMOVE_MBUTTON 2
253#define WMMOVE_RBUTTON 4
254#define WMMOVE_CTRL 8
255#define WMMOVE_SHIFT 16
256
257
258#define CMD_MENU 1
259#define CMD_CONTROL 2
260#define CMD_ACCELERATOR 3
261
262#define WIN32SC_SIZE 0xf000
263#define WIN32SC_MOVE 0xf010
264#define WIN32SC_MINIMIZE 0xf020
265#define WIN32SC_MAXIMIZE 0xf030
266#define WIN32SC_NEXTWINDOW 0xf040
267#define WIN32SC_PREVWINDOW 0xf050
268#define WIN32SC_CLOSE 0xf060
269#define WIN32SC_VSCROLL 0xf070
270#define WIN32SC_HSCROLL 0xf080
271#define WIN32SC_MOUSEMENU 0xf090
272#define WIN32SC_KEYMENU 0xf100
273#define WIN32SC_ARRANGE 0xf110
274#define WIN32SC_RESTORE 0xf120
275#define WIN32SC_TASKLIST 0xf130
276#define WIN32SC_SCREENSAVE 0xf140
277#define WIN32SC_HOTKEY 0xf150
278
279#define KEY_ALTDOWN 1
280#define KEY_PREVDOWN 2
281#define KEY_UP 4
282#define KEY_DEADKEY 8
283
284#endif //__cplusplus
285
286#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.