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

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

Lots of changes: Solitaire now displays cards correctly

File size: 8.4 KB
Line 
1/* $Id: win32wnd.h,v 1.21 1999-07-26 20:03:49 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 BOOL isFrameWindow() { return OS2Hwnd != OS2HwndFrame; };
91 Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
92 void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
93 WNDPROC getWindowProc() { return win32wndproc; };
94 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
95 DWORD getWindowId() { return windowId; };
96 void setWindowId(DWORD id) { windowId = id; };
97 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
98 BOOL isChild();
99 PRECT getClientRect() { return &rectClient; };
100 PRECT getWindowRect() { return &rectWindow; };
101
102 DWORD getFlags() { return flags; };
103 void setFlags(DWORD newflags) { flags = newflags; };
104
105 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
106 BOOL SetAccelTable(ULONG hAccel);
107
108 HMENU GetMenu() { return (HMENU) menuResource; };
109 BOOL SetMenu(ULONG hMenu);
110
111 BOOL SetIcon(HICON hIcon);
112 HICON GetIcon() { return (HICON) iconResource; };
113
114 BOOL ShowWindow(ULONG nCmdShow);
115 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
116 BOOL DestroyWindow();
117 HWND SetActiveWindow();
118 HWND GetParent();
119 HWND SetParent(HWND hwndNewParent);
120 BOOL IsChild(HWND hwndParent);
121 HWND GetTopWindow();
122 BOOL UpdateWindow();
123 BOOL IsIconic();
124 HWND GetWindow(UINT uCmd);
125 BOOL EnableWindow(BOOL fEnable);
126 BOOL CloseWindow();
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 BOOL fFirstShow;
202
203 Win32Window *owner;
204
205 Win32Resource *acceltableResource;
206 Win32Resource *menuResource;
207 Win32Resource *iconResource;
208
209 char windowNameA[MAX_WINDOW_NAMELENGTH];
210 WCHAR windowNameW[MAX_WINDOW_NAMELENGTH];
211 ULONG wndNameLength;
212
213 ULONG *userWindowLong;
214 ULONG nrUserWindowLong;
215
216 RECT rectWindow;
217 RECT rectClient;
218
219Win32WndClass *windowClass;
220
221static GenericObject *windows;
222
223private:
224#ifndef OS2_INCLUDED
225 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
226
227 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
228
229 LONG SendNCCalcSize(BOOL calcValidRect,
230 RECT *newWindowRect, RECT *oldWindowRect,
231 RECT *oldClientRect, WINDOWPOS *winpos,
232 RECT *newClientRect );
233
234 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
235 {
236 if(isUnicode)
237 return SendInternalMessageW(msg, wParam, lParam);
238 else return SendInternalMessageA(msg, wParam, lParam);
239 }
240#endif
241};
242
243
244#define BUTTON_LEFTDOWN 0
245#define BUTTON_LEFTUP 1
246#define BUTTON_LEFTDBLCLICK 2
247#define BUTTON_RIGHTUP 3
248#define BUTTON_RIGHTDOWN 4
249#define BUTTON_RIGHTDBLCLICK 5
250#define BUTTON_MIDDLEUP 6
251#define BUTTON_MIDDLEDOWN 7
252#define BUTTON_MIDDLEDBLCLICK 8
253
254#define WMMOVE_LBUTTON 1
255#define WMMOVE_MBUTTON 2
256#define WMMOVE_RBUTTON 4
257#define WMMOVE_CTRL 8
258#define WMMOVE_SHIFT 16
259
260
261#define CMD_MENU 1
262#define CMD_CONTROL 2
263#define CMD_ACCELERATOR 3
264
265#define WIN32SC_SIZE 0xf000
266#define WIN32SC_MOVE 0xf010
267#define WIN32SC_MINIMIZE 0xf020
268#define WIN32SC_MAXIMIZE 0xf030
269#define WIN32SC_NEXTWINDOW 0xf040
270#define WIN32SC_PREVWINDOW 0xf050
271#define WIN32SC_CLOSE 0xf060
272#define WIN32SC_VSCROLL 0xf070
273#define WIN32SC_HSCROLL 0xf080
274#define WIN32SC_MOUSEMENU 0xf090
275#define WIN32SC_KEYMENU 0xf100
276#define WIN32SC_ARRANGE 0xf110
277#define WIN32SC_RESTORE 0xf120
278#define WIN32SC_TASKLIST 0xf130
279#define WIN32SC_SCREENSAVE 0xf140
280#define WIN32SC_HOTKEY 0xf150
281
282#define KEY_ALTDOWN 1
283#define KEY_PREVDOWN 2
284#define KEY_UP 4
285#define KEY_DEADKEY 8
286
287#endif //__cplusplus
288
289#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.