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

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

Accelerator + icon changes

File size: 7.3 KB
Line 
1/* $Id: win32wnd.h,v 1.17 1999-07-20 15:46:54 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
46class Win32Window : private GenericObject, private ChildWindow
47{
48public:
49 DWORD magic;
50
51 Win32Window(DWORD objType);
52 Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
53virtual ~Win32Window();
54
55virtual ULONG MsgCreate(HWND hwndOS2, ULONG initParam);
56 ULONG MsgQuit();
57 ULONG MsgClose();
58 ULONG MsgDestroy();
59 ULONG MsgEnable(BOOL fEnable);
60 ULONG MsgShow(BOOL fShow);
61 ULONG MsgMove(ULONG x, ULONG y);
62 ULONG MsgHitTest(ULONG x, ULONG y);
63 ULONG MsgSize(ULONG width, ULONG height, BOOL fMinimize, BOOL fMaximize);
64 ULONG MsgActivate(BOOL fActivate, HWND hwnd);
65 ULONG MsgSetFocus(HWND hwnd);
66 ULONG MsgKillFocus(HWND hwnd);
67 ULONG MsgCommand(ULONG cmd, ULONG Id, HWND hwnd);
68 ULONG MsgButton(ULONG msg, ULONG x, ULONG y);
69 ULONG MsgMouseMove(ULONG keystate, ULONG x, ULONG y);
70 ULONG MsgPaint(ULONG tmp1, ULONG tmp2);
71 ULONG MsgEraseBackGround(ULONG hps);
72 ULONG MsgSetText(LPSTR lpsz, LONG cch);
73
74virtual LONG SetWindowLongA(int index, ULONG value);
75virtual ULONG GetWindowLongA(int index);
76virtual WORD SetWindowWord(int index, WORD value);
77virtual WORD GetWindowWord(int index);
78
79 DWORD getStyle() { return dwStyle; };
80 DWORD getExStyle() { return dwExStyle; };
81 HWND getWindowHandle() { return Win32Hwnd; };
82 HWND getOS2WindowHandle() { return OS2Hwnd; };
83 Win32Window *getParent() { return (Win32Window *)ChildWindow::GetParent(); };
84 void setParent(Win32Window *pwindow) { ChildWindow::SetParent((ChildWindow *)pwindow); };
85 WNDPROC getWindowProc() { return win32wndproc; };
86 void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
87 DWORD getWindowId() { return windowId; };
88 void setWindowId(DWORD id) { windowId = id; };
89 ULONG getWindowHeight() { return rectClient.bottom - rectClient.top; };
90 BOOL isChild();
91
92 DWORD getFlags() { return flags; };
93 void setFlags(DWORD newflags) { flags = newflags; };
94
95 HACCEL GetAccelTable() { return (HACCEL) acceltableResource; };
96 BOOL SetAccelTable(ULONG hAccel);
97
98 HMENU GetMenu() { return (HMENU) menuResource; };
99 BOOL SetMenu(ULONG hMenu);
100
101 BOOL SetIcon(HICON hIcon);
102 HICON GetIcon() { return (HICON) iconResource; };
103
104 BOOL ShowWindow(ULONG nCmdShow);
105 BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
106 BOOL DestroyWindow();
107 HWND SetActiveWindow();
108 HWND GetParent();
109 HWND SetParent(HWND hwndNewParent);
110 BOOL IsChild(HWND hwndParent);
111 HWND GetTopWindow();
112 BOOL UpdateWindow();
113 BOOL IsIconic();
114 HWND GetWindow(UINT uCmd);
115 BOOL EnableWindow(BOOL fEnable);
116 BOOL CloseWindow();
117 BOOL BringWindowToTop();
118 static HWND GetActiveWindow();
119 BOOL IsWindow();
120 BOOL IsWindowEnabled();
121 BOOL IsWindowVisible();
122 BOOL IsUnicode() { return isUnicode; };
123
124 BOOL GetWindowRect(PRECT pRect);
125 int GetWindowTextLengthA();
126 int GetWindowTextA(LPSTR lpsz, int cch);
127 BOOL SetWindowTextA(LPCSTR lpsz);
128
129 LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
130 LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
131 BOOL PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
132 BOOL PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
133 LRESULT DefWindowProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
134 LRESULT DefWindowProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
135
136 void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
137
138Win32WndClass *getClass() { return windowClass; };
139
140static HWND Win32ToOS2Handle(HWND hwnd)
141{
142 Win32Window *window = GetWindowFromHandle(hwnd);
143
144 if(window) {
145 return window->getOS2WindowHandle();
146 }
147 else return hwnd; //OS/2 window handle
148}
149
150static HWND OS2ToWin32Handle(HWND hwnd)
151{
152 Win32Window *window = GetWindowFromOS2Handle(hwnd);
153
154 if(window) {
155 return window->getWindowHandle();
156 }
157 else return hwnd; //OS/2 window handle
158}
159
160static Win32Window *GetWindowFromHandle(HWND hwnd);
161static Win32Window *GetWindowFromOS2Handle(HWND hwnd);
162
163protected:
164 LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
165 LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
166 void Init();
167
168 HWND OS2Hwnd;
169 HWND OS2HwndFrame;
170 HWND OS2HwndMenu;
171 HWND Win32Hwnd;
172 BOOL isUnicode;
173
174 int posx, posy, width, height;
175
176 // values normally contained in the standard window words
177 ULONG dwExStyle; //GWL_EXSTYLE
178 ULONG dwStyle; //GWL_STYLE
179 WNDPROC win32wndproc; //GWL_WNDPROC
180 ULONG hInstance; //GWL_HINSTANCE
181//Moved in ChildWindow class
182///// Win32Window *parent; //GWL_HWNDPARENT
183 ULONG windowId; //GWL_ID
184 ULONG userData; //GWL_USERDATA
185
186 HWND hwndLinkAfter;
187 DWORD flags;
188 DWORD lastHitTestVal; //Last value returned by WM_NCHITTEST handler
189
190 BOOL isIcon;
191
192 Win32Window *owner;
193
194 Win32Resource *acceltableResource;
195 Win32Resource *menuResource;
196 Win32Resource *iconResource;
197
198 char *windowName;
199 ULONG wndNameLength;
200
201 char *windowText;
202 ULONG wndTextLength;
203
204 ULONG *userWindowLong;
205 ULONG nrUserWindowLong;
206
207 RECT rectWindow;
208 RECT rectClient;
209
210Win32WndClass *windowClass;
211
212static GenericObject *windows;
213
214private:
215#ifndef OS2_INCLUDED
216 BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
217
218 void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
219
220 LONG SendNCCalcSize(BOOL calcValidRect,
221 RECT *newWindowRect, RECT *oldWindowRect,
222 RECT *oldClientRect, WINDOWPOS *winpos,
223 RECT *newClientRect );
224
225 LRESULT SendInternalMessage(ULONG msg, WPARAM wParam, LPARAM lParam)
226 {
227 if(isUnicode)
228 return SendInternalMessageW(msg, wParam, lParam);
229 else return SendInternalMessageA(msg, wParam, lParam);
230 }
231#endif
232};
233
234
235#define BUTTON_LEFTDOWN 0
236#define BUTTON_LEFTUP 1
237#define BUTTON_LEFTDBLCLICK 2
238#define BUTTON_RIGHTUP 3
239#define BUTTON_RIGHTDOWN 4
240#define BUTTON_RIGHTDBLCLICK 5
241#define BUTTON_MIDDLEUP 6
242#define BUTTON_MIDDLEDOWN 7
243#define BUTTON_MIDDLEDBLCLICK 8
244
245#define WMMOVE_LBUTTON 1
246#define WMMOVE_MBUTTON 2
247#define WMMOVE_RBUTTON 4
248#define WMMOVE_CTRL 8
249#define WMMOVE_SHIFT 16
250
251
252#define CMD_MENU 1
253#define CMD_CONTROL 2
254#define CMD_ACCELERATOR 3
255
256#endif //__cplusplus
257
258#endif //__WIN32WND_H__
Note: See TracBrowser for help on using the repository browser.