| 1 | /* $Id: win32wbase.h,v 1.126 2001-09-22 18:21:00 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Win32 Window Base Class 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 __WIN32WNDBASE_H__
|
|---|
| 14 | #define __WIN32WNDBASE_H__
|
|---|
| 15 |
|
|---|
| 16 | #ifdef __cplusplus
|
|---|
| 17 |
|
|---|
| 18 | #include <win32class.h>
|
|---|
| 19 | #include "open32wbase.h"
|
|---|
| 20 | #include <gen_object.h>
|
|---|
| 21 | #include <win32wndchild.h>
|
|---|
| 22 | #include <winres.h>
|
|---|
| 23 | #include <scroll.h>
|
|---|
| 24 |
|
|---|
| 25 | class Win32BaseWindow;
|
|---|
| 26 |
|
|---|
| 27 | #define OFFSET_RESERVED 0 //reserved for odin apps (such as Opera)
|
|---|
| 28 | #define OFFSET_WIN32WNDPTR 4
|
|---|
| 29 | #define OFFSET_WIN32PM_MAGIC 8
|
|---|
| 30 | #define OFFSET_WIN32FLAGS 12
|
|---|
| 31 | #define NROF_WIN32WNDBYTES 16
|
|---|
| 32 |
|
|---|
| 33 | #define WINDOWFLAG_ACTIVE 1
|
|---|
| 34 |
|
|---|
| 35 | #define WIN32PM_MAGIC 0x12345678
|
|---|
| 36 | #define CheckMagicDword(a) (a==WIN32PM_MAGIC)
|
|---|
| 37 |
|
|---|
| 38 | #ifdef DEBUG
|
|---|
| 39 | #define RELEASE_WNDOBJ(a) { a->release(__FUNCTION__, __LINE__); a = NULL; }
|
|---|
| 40 | #else
|
|---|
| 41 | #define RELEASE_WNDOBJ(a) { a->release(); a = NULL; }
|
|---|
| 42 | #endif
|
|---|
| 43 |
|
|---|
| 44 | typedef struct {
|
|---|
| 45 | USHORT cb;
|
|---|
| 46 | Win32BaseWindow *win32wnd;
|
|---|
| 47 | ULONG win32CreateStruct; //or dialog create dword
|
|---|
| 48 | } CUSTOMWNDDATA;
|
|---|
| 49 |
|
|---|
| 50 | typedef struct tagPROPERTY
|
|---|
| 51 | {
|
|---|
| 52 | struct tagPROPERTY *next; /* Next property in window list */
|
|---|
| 53 | HANDLE handle; /* User's data */
|
|---|
| 54 | LPSTR string; /* Property string (or atom) */
|
|---|
| 55 | } PROPERTY;
|
|---|
| 56 |
|
|---|
| 57 | //PostThreadMessage is done through Open32; which means the message id will be translated
|
|---|
| 58 | //(0xc00 added)
|
|---|
| 59 | #define OPEN32_MSGDIFF 0xC00
|
|---|
| 60 | #define WIN32APP_POSTMSG (0x1000+OPEN32_MSGDIFF)
|
|---|
| 61 |
|
|---|
| 62 | //PM doesn't allow SetFocus during WM_SETFOCUS message processing; must delay
|
|---|
| 63 | //this by posting a message
|
|---|
| 64 | //NOTE Must be smaller than WIN32APP_POSTMSG!
|
|---|
| 65 | #define WIN32APP_SETFOCUSMSG (WIN32APP_POSTMSG-1)
|
|---|
| 66 |
|
|---|
| 67 | #define WIN32MSG_MAGICA 0x12345678
|
|---|
| 68 | #define WIN32MSG_MAGICW 0x12345679
|
|---|
| 69 |
|
|---|
| 70 | typedef struct
|
|---|
| 71 | {
|
|---|
| 72 | ULONG wParam;
|
|---|
| 73 | ULONG lParam;
|
|---|
| 74 | } POSTMSG_PACKET;
|
|---|
| 75 |
|
|---|
| 76 | #define BROADCAST_SEND 0
|
|---|
| 77 | #define BROADCAST_POST 1
|
|---|
| 78 |
|
|---|
| 79 | #define HAS_DLGFRAME(style,exStyle) \
|
|---|
| 80 | (((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 81 | (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
|
|---|
| 82 |
|
|---|
| 83 | #define HAS_THICKFRAME(style,exStyle) \
|
|---|
| 84 | (((style) & WS_THICKFRAME) && \
|
|---|
| 85 | !(((style) & (WS_DLGFRAME|WS_BORDER)) == WS_DLGFRAME))
|
|---|
| 86 | #if 0
|
|---|
| 87 | (((style) & WS_THICKFRAME) && \
|
|---|
| 88 | !((exStyle) & WS_EX_DLGMODALFRAME) && \
|
|---|
| 89 | !((style) & WS_CHILD))
|
|---|
| 90 | #endif
|
|---|
| 91 |
|
|---|
| 92 | #define HAS_THINFRAME(style) \
|
|---|
| 93 | (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
|
|---|
| 94 |
|
|---|
| 95 | #define HAS_BIGFRAME(style,exStyle) \
|
|---|
| 96 | (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
|
|---|
| 97 | ((exStyle) & WS_EX_DLGMODALFRAME))
|
|---|
| 98 |
|
|---|
| 99 | #define HAS_ANYFRAME(style,exStyle) \
|
|---|
| 100 | (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
|
|---|
| 101 | ((exStyle) & WS_EX_DLGMODALFRAME) || \
|
|---|
| 102 | !((style) & (WS_CHILD | WS_POPUP)))
|
|---|
| 103 |
|
|---|
| 104 | #define HAS_3DFRAME(exStyle) \
|
|---|
| 105 | ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
|
|---|
| 106 |
|
|---|
| 107 | #define HAS_BORDER(style, exStyle) \
|
|---|
| 108 | ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
|
|---|
| 109 |
|
|---|
| 110 | #define IS_OVERLAPPED(style) \
|
|---|
| 111 | !(style & (WS_CHILD | WS_POPUP))
|
|---|
| 112 |
|
|---|
| 113 | #define HAS_MENU() (!(getStyle() & WS_CHILD) && (GetMenu() != 0))
|
|---|
| 114 |
|
|---|
| 115 | #define STATE_INIT 0 //initial state
|
|---|
| 116 | #define STATE_PRE_WMNCCREATE 1 //before WM_NCCREATE
|
|---|
| 117 | #define STATE_POST_WMNCCREATE 2 //after WM_NCCREATE
|
|---|
| 118 | #define STATE_PRE_WMCREATE 3 //before WM_CREATE
|
|---|
| 119 | #define STATE_POST_WMCREATE 4 //after WM_CREATE
|
|---|
| 120 | #define STATE_CREATED 5 //after successful return of WinCreateWindow
|
|---|
| 121 | #define STATE_DESTROYED 6 //DestroyWindow called for window
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | class Win32BaseWindow : public GenericObject, public ChildWindow
|
|---|
| 125 | {
|
|---|
| 126 | public:
|
|---|
| 127 | Win32BaseWindow();
|
|---|
| 128 | Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
|
|---|
| 129 | Win32BaseWindow(HWND hwndOS2, ULONG reserved);
|
|---|
| 130 |
|
|---|
| 131 | virtual ~Win32BaseWindow();
|
|---|
| 132 |
|
|---|
| 133 | virtual ULONG MsgCreate(HWND hwndOS2);
|
|---|
| 134 | ULONG MsgQuit();
|
|---|
| 135 | ULONG MsgClose();
|
|---|
| 136 | ULONG MsgDestroy();
|
|---|
| 137 | virtual ULONG MsgEnable(BOOL fEnable);
|
|---|
| 138 | ULONG MsgShow(BOOL fShow);
|
|---|
| 139 | ULONG MsgPosChanging(LPARAM lp);
|
|---|
| 140 | ULONG MsgPosChanged(LPARAM lp);
|
|---|
| 141 | ULONG MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win);
|
|---|
| 142 | ULONG MsgChildActivate(BOOL fActivate);
|
|---|
| 143 | ULONG MsgSetFocus(HWND hwnd);
|
|---|
| 144 | ULONG MsgKillFocus(HWND hwnd);
|
|---|
| 145 | ULONG MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos);
|
|---|
| 146 | ULONG MsgButton(MSG *msg);
|
|---|
| 147 | ULONG MsgMouseMove(MSG *msg);
|
|---|
| 148 | ULONG MsgChar(MSG *msg);
|
|---|
| 149 | ULONG MsgPaint(ULONG tmp1, BOOL select = TRUE);
|
|---|
| 150 | ULONG MsgEraseBackGround(HDC hdc);
|
|---|
| 151 | ULONG MsgNCPaint(PRECT pUpdateRect);
|
|---|
| 152 | ULONG MsgFormatFrame(WINDOWPOS *lpWndPos);
|
|---|
| 153 | ULONG DispatchMsgA(MSG *msg);
|
|---|
| 154 | ULONG DispatchMsgW(MSG *msg);
|
|---|
| 155 |
|
|---|
| 156 | ULONG MsgSetText(LPSTR lpsz, LONG cch);
|
|---|
| 157 | ULONG MsgGetTextLength();
|
|---|
| 158 | void MsgGetText(char *wndtext, ULONG textlength);
|
|---|
| 159 | VOID updateWindowStyle(DWORD oldExStyle,DWORD oldStyle);
|
|---|
| 160 |
|
|---|
| 161 | virtual LONG SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
|
|---|
| 162 | virtual ULONG GetWindowLongA(int index, BOOL fUnicode = FALSE);
|
|---|
| 163 | virtual WORD SetWindowWord(int index, WORD value);
|
|---|
| 164 | virtual WORD GetWindowWord(int index);
|
|---|
| 165 |
|
|---|
| 166 | DWORD getStyle() { return dwStyle; };
|
|---|
| 167 | DWORD getOldStyle() { return dwOldStyle; };
|
|---|
| 168 | void setStyle(DWORD newstyle) { dwStyle = newstyle; };
|
|---|
| 169 | DWORD getExStyle() { return dwExStyle; };
|
|---|
| 170 | void setExStyle(DWORD newexstyle) { dwExStyle = newexstyle; };
|
|---|
| 171 | ULONG getInstance() { return hInstance; };
|
|---|
| 172 | void setInstance(ULONG newinstance) { hInstance = newinstance; };
|
|---|
| 173 | HWND getWindowHandle() { return Win32Hwnd; };
|
|---|
| 174 | HWND getOS2WindowHandle() { return OS2Hwnd; };
|
|---|
| 175 | HWND getOS2FrameWindowHandle() { return OS2HwndFrame; };
|
|---|
| 176 |
|
|---|
| 177 | Win32WndClass *getWindowClass() { return windowClass; };
|
|---|
| 178 |
|
|---|
| 179 | LONG getLastHitTestVal() { return lastHitTestVal; }
|
|---|
| 180 |
|
|---|
| 181 | DWORD getWindowContextHelpId() { return contextHelpId; };
|
|---|
| 182 | void setWindowContextHelpId(DWORD id){ contextHelpId = id; };
|
|---|
| 183 |
|
|---|
| 184 | BOOL isFrameWindow();
|
|---|
| 185 | virtual BOOL isMDIClient();
|
|---|
| 186 | virtual BOOL isMDIChild();
|
|---|
| 187 | virtual BOOL isDesktopWindow();
|
|---|
| 188 |
|
|---|
| 189 | BOOL fHasParentDC() { return fParentDC; };
|
|---|
| 190 |
|
|---|
| 191 | Win32BaseWindow *getParent();
|
|---|
| 192 | void setParent(Win32BaseWindow *pwindow) { setParentOfChild((ChildWindow *)pwindow); };
|
|---|
| 193 | WNDPROC getWindowProc() { return win32wndproc; };
|
|---|
| 194 | void setWindowProc(WNDPROC newproc) { win32wndproc = newproc; };
|
|---|
| 195 | DWORD getWindowId() { return dwIDMenu; };
|
|---|
| 196 | void setWindowId(DWORD id);
|
|---|
| 197 | ULONG getWindowHeight() { return rectWindow.bottom - rectWindow.top; };
|
|---|
| 198 | ULONG getWindowWidth() { return rectWindow.right - rectWindow.left; };
|
|---|
| 199 | ULONG getClientHeight() { return rectClient.bottom - rectClient.top; };
|
|---|
| 200 | ULONG getClientWidth() { return rectClient.right - rectClient.left; };
|
|---|
| 201 | BOOL isChild();
|
|---|
| 202 | PRECT getClientRectPtr() { return &rectClient; };
|
|---|
| 203 | void getClientRect(PRECT rect)
|
|---|
| 204 | {
|
|---|
| 205 | *rect = rectClient;
|
|---|
| 206 | rect->right -= rect->left;
|
|---|
| 207 | rect->bottom -= rect->top;
|
|---|
| 208 | rect->left = rect->top = 0;
|
|---|
| 209 | }
|
|---|
| 210 | void setClientRect(PRECT rect) { rectClient = *rect; };
|
|---|
| 211 | PRECT getWindowRect() { return &rectWindow; };
|
|---|
| 212 | void setClientRect(LONG left, LONG top, LONG right, LONG bottom)
|
|---|
| 213 | {
|
|---|
| 214 | rectClient.left = left; rectClient.top = top;
|
|---|
| 215 | rectClient.right = right; rectClient.bottom = bottom;
|
|---|
| 216 | };
|
|---|
| 217 | void setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
|
|---|
| 218 | {
|
|---|
| 219 | rectWindow.left = left; rectWindow.top = top;
|
|---|
| 220 | rectWindow.right = right; rectWindow.bottom = bottom;
|
|---|
| 221 | };
|
|---|
| 222 | void setWindowRect(PRECT rect) { rectWindow = *rect; };
|
|---|
| 223 | DWORD getFlags() { return flags; };
|
|---|
| 224 | void setFlags(DWORD newflags) { flags = newflags; };
|
|---|
| 225 |
|
|---|
| 226 | DWORD getCBExtra() { return cbExtra; };
|
|---|
| 227 | PVOID getExtraPtr() { return pExtra; };
|
|---|
| 228 |
|
|---|
| 229 | HMENU GetMenu() { return dwIDMenu; };
|
|---|
| 230 | VOID SetMenu(HMENU newMenu) { dwIDMenu = newMenu; };
|
|---|
| 231 | void SetSysMenu(HMENU hSystemMenu) { hSysMenu = hSystemMenu; };
|
|---|
| 232 | HMENU GetSysMenu() { return hSysMenu; }
|
|---|
| 233 |
|
|---|
| 234 | HICON IconForWindow(WPARAM fType);
|
|---|
| 235 |
|
|---|
| 236 | void SetWindowRegion(HRGN hRegion) { hWindowRegion = hRegion; };
|
|---|
| 237 | HRGN GetWindowRegion() { return hWindowRegion; };
|
|---|
| 238 |
|
|---|
| 239 | //Save old clip region for CS_OWNDC windows (in BeginPaint)
|
|---|
| 240 | HRGN GetClipRegion() { return hClipRegion; };
|
|---|
| 241 | void SetClipRegion(HRGN hRegion) { hClipRegion = hRegion; };
|
|---|
| 242 |
|
|---|
| 243 | BOOL ShowWindow(ULONG nCmdShow);
|
|---|
| 244 | BOOL SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
|
|---|
| 245 | BOOL SetWindowPlacement(WINDOWPLACEMENT *winpos);
|
|---|
| 246 | BOOL GetWindowPlacement(LPWINDOWPLACEMENT winpos);
|
|---|
| 247 | BOOL ScrollWindow(int dx, int dy);
|
|---|
| 248 | virtual BOOL DestroyWindow();
|
|---|
| 249 | HWND SetActiveWindow();
|
|---|
| 250 | BOOL DeactivateChildWindow();
|
|---|
| 251 | HWND GetParent();
|
|---|
| 252 | HWND SetParent(HWND hwndNewParent);
|
|---|
| 253 |
|
|---|
| 254 | BOOL IsChild(HWND hwndParent);
|
|---|
| 255 |
|
|---|
| 256 | HWND GetTopWindow();
|
|---|
| 257 | HWND GetTopParent();
|
|---|
| 258 |
|
|---|
| 259 | HWND GetWindow(UINT uCmd);
|
|---|
| 260 | virtual BOOL EnableWindow(BOOL fEnable);
|
|---|
| 261 | BOOL CloseWindow();
|
|---|
| 262 | static HWND GetActiveWindow();
|
|---|
| 263 | //Window handle has already been verified, so just return true
|
|---|
| 264 | BOOL IsWindow() { return TRUE; };
|
|---|
| 265 | BOOL IsDialog() { return fIsDialog; };
|
|---|
| 266 | BOOL IsModalDialog() { return fIsModalDialog; };
|
|---|
| 267 | BOOL IsModalDialogOwner() { return fIsModalDialogOwner; };
|
|---|
| 268 | VOID setModalDialogOwner(BOOL fMDO) { fIsModalDialogOwner = fMDO; };
|
|---|
| 269 | VOID setOS2HwndModalDialog(HWND aHwnd) { OS2HwndModalDialog = aHwnd; };
|
|---|
| 270 | HWND getOS2HwndModalDialog() { return OS2HwndModalDialog; };
|
|---|
| 271 | BOOL CanReceiveSizeMsgs() { return state >= STATE_PRE_WMCREATE; };
|
|---|
| 272 | BOOL IsParentChanging() { return fParentChange; };
|
|---|
| 273 | BOOL IsWindowCreated() { return state >= STATE_PRE_WMNCCREATE; }
|
|---|
| 274 | BOOL IsWindowDestroyed() { return state >= STATE_DESTROYED; };
|
|---|
| 275 | BOOL IsWindowIconic();
|
|---|
| 276 | //Window procedure type
|
|---|
| 277 | BOOL IsWindowUnicode();
|
|---|
| 278 | BOOL IsMixMaxStateChanging() { return fMinMaxChange; };
|
|---|
| 279 |
|
|---|
| 280 | void SetVisibleRegionChanged(BOOL changed) { fVisibleRegionChanged = changed; };
|
|---|
| 281 | BOOL IsVisibleRegionChanged() { return fVisibleRegionChanged; };
|
|---|
| 282 |
|
|---|
| 283 | int GetWindowTextLength(BOOL fUnicode);
|
|---|
| 284 | int GetWindowTextLengthA() { return GetWindowTextLength(FALSE); };
|
|---|
| 285 | int GetWindowTextLengthW() { return GetWindowTextLength(TRUE); };
|
|---|
| 286 |
|
|---|
| 287 | int GetWindowTextA(LPSTR lpsz, int cch);
|
|---|
| 288 | int GetWindowTextW(LPWSTR lpsz, int cch);
|
|---|
| 289 | BOOL SetWindowTextA(LPSTR lpsz);
|
|---|
| 290 | BOOL SetWindowTextW(LPWSTR lpsz);
|
|---|
| 291 | BOOL hasWindowName(LPSTR wndname, BOOL fUnicode = 0);
|
|---|
| 292 | CHAR *getWindowNamePtrA();
|
|---|
| 293 | WCHAR *getWindowNamePtrW();
|
|---|
| 294 | VOID freeWindowNamePtr(PVOID namePtr);
|
|---|
| 295 | CHAR *getWindowNameA() { return windowNameA; }; //only for MDI windows!
|
|---|
| 296 | WCHAR *getWindowNameW() { return windowNameW; }; //only for MDI windows!
|
|---|
| 297 | Win32WndClass *getClass() { return windowClass; };
|
|---|
| 298 | Win32BaseWindow *getOwner() { return owner; };
|
|---|
| 299 | void setOwner(Win32BaseWindow *newOwner) { owner = newOwner; };
|
|---|
| 300 |
|
|---|
| 301 | SCROLLBAR_INFO *getScrollInfo(int nBar);
|
|---|
| 302 |
|
|---|
| 303 | LRESULT SendMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 304 | LRESULT SendMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 305 | static LRESULT BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 306 | static LRESULT BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 307 | void CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode = FALSE);
|
|---|
| 308 |
|
|---|
| 309 | LRESULT DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 310 | LRESULT DefWindowProcW(UINT msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 311 |
|
|---|
| 312 | LRESULT DefWndControlColor(UINT ctlType, HDC hdc);
|
|---|
| 313 | LRESULT DefWndPrint(HDC hdc,ULONG uFlags);
|
|---|
| 314 |
|
|---|
| 315 | void NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 316 |
|
|---|
| 317 | HWND FindWindowById(int id);
|
|---|
| 318 |
|
|---|
| 319 | static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow);
|
|---|
| 320 |
|
|---|
| 321 | BOOL EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam);
|
|---|
| 322 | BOOL EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam);
|
|---|
| 323 | BOOL EnumWindows(WNDENUMPROC lpfn, LPARAM lParam);
|
|---|
| 324 |
|
|---|
| 325 | HWND getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious);
|
|---|
| 326 |
|
|---|
| 327 | BOOL isComingToTop() { return fComingToTop; };
|
|---|
| 328 | void setComingToTop(BOOL fTop) { fComingToTop = fTop; };
|
|---|
| 329 | BOOL isInTasklist() { return fTaskList; };
|
|---|
| 330 |
|
|---|
| 331 | //window property methods
|
|---|
| 332 | HANDLE getProp(LPCSTR str);
|
|---|
| 333 | BOOL setProp(LPCSTR str, HANDLE handle);
|
|---|
| 334 | HANDLE removeProp(LPCSTR str);
|
|---|
| 335 | INT enumPropsExA(PROPENUMPROCEXA func, LPARAM lParam);
|
|---|
| 336 | INT enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam);
|
|---|
| 337 |
|
|---|
| 338 | #ifdef DEBUG
|
|---|
| 339 | LONG addRef();
|
|---|
| 340 | LONG release(char *function = __FUNCTION__, int line = __LINE__ );
|
|---|
| 341 | #endif
|
|---|
| 342 |
|
|---|
| 343 | //Locates window in linked list and increases reference count (if found)
|
|---|
| 344 | //Window object must be unreferenced after usage
|
|---|
| 345 | static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
|
|---|
| 346 | static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
|
|---|
| 347 | static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
|
|---|
| 348 |
|
|---|
| 349 | static void DestroyAll();
|
|---|
| 350 |
|
|---|
| 351 | protected:
|
|---|
| 352 | #ifndef OS2_INCLUDED
|
|---|
| 353 | BOOL CreateWindowExA(CREATESTRUCTA *lpCreateStruct, ATOM classAtom);
|
|---|
| 354 | #endif
|
|---|
| 355 | LRESULT SendInternalMessageA(ULONG msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 356 | LRESULT SendInternalMessageW(ULONG msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 357 | void Init();
|
|---|
| 358 |
|
|---|
| 359 | void NotifyFrameChanged(WINDOWPOS *wpos, RECT *oldClientRect);
|
|---|
| 360 |
|
|---|
| 361 | //called in destructor to remove all (if any) window properties
|
|---|
| 362 | void removeWindowProps();
|
|---|
| 363 | PROPERTY *findWindowProperty(LPCSTR str);
|
|---|
| 364 |
|
|---|
| 365 | HWND OS2Hwnd, OS2HwndFrame;
|
|---|
| 366 | HMENU hSysMenu;
|
|---|
| 367 | HWND Win32Hwnd;
|
|---|
| 368 |
|
|---|
| 369 | int posx, posy, width, height;
|
|---|
| 370 |
|
|---|
| 371 | // values normally contained in the standard window words
|
|---|
| 372 | ULONG dwExStyle; //GWL_EXSTYLE
|
|---|
| 373 | ULONG dwStyle; //GWL_STYLE
|
|---|
| 374 | ULONG dwOldStyle; //Used to determine which frame control buttons to change (OS/2 mode)
|
|---|
| 375 | WNDPROC win32wndproc; //GWL_WNDPROC
|
|---|
| 376 | ULONG hInstance; //GWL_HINSTANCE
|
|---|
| 377 | //Moved in ChildWindow class
|
|---|
| 378 | ///// Win32BaseWindow *parent; //GWL_HWNDPARENT
|
|---|
| 379 | ULONG dwIDMenu; //GWL_ID
|
|---|
| 380 | ULONG userData; //GWL_USERDATA
|
|---|
| 381 |
|
|---|
| 382 | ULONG cbExtra;
|
|---|
| 383 | PVOID pExtra;
|
|---|
| 384 |
|
|---|
| 385 | HWND hwndLinkAfter;
|
|---|
| 386 | DWORD flags;
|
|---|
| 387 | DWORD contextHelpId;
|
|---|
| 388 | DWORD hotkey;
|
|---|
| 389 | LONG lastHitTestVal; //Last value returned by WM_NCHITTEST handler
|
|---|
| 390 |
|
|---|
| 391 | HWND OS2HwndModalDialog;
|
|---|
| 392 |
|
|---|
| 393 | ULONG fFirstShow:1,
|
|---|
| 394 | fIsDialog:1,
|
|---|
| 395 | fIsModalDialog:1,
|
|---|
| 396 | fIsModalDialogOwner:1,
|
|---|
| 397 | fInternalMsg:1, //Used to distinguish between messages
|
|---|
| 398 | //sent by PM and those sent by apps
|
|---|
| 399 | fParentChange:1,
|
|---|
| 400 | fDestroyWindowCalled:1, //DestroyWindow was called for this window
|
|---|
| 401 | fTaskList:1, //should be listed in PM tasklist or not
|
|---|
| 402 | fXDefault:1,
|
|---|
| 403 | fCXDefault:1,
|
|---|
| 404 | fParentDC:1,
|
|---|
| 405 | fComingToTop:1,
|
|---|
| 406 | isUnicode:1,
|
|---|
| 407 | fMinMaxChange:1, //set when switching between min/max/restored state
|
|---|
| 408 | fVisibleRegionChanged:1, //set when visible region has changed -> erase background must be sent during next BeginPaint
|
|---|
| 409 | fEraseBkgndFlag:1;
|
|---|
| 410 |
|
|---|
| 411 | ULONG state;
|
|---|
| 412 | HRGN hWindowRegion;
|
|---|
| 413 | HRGN hClipRegion;
|
|---|
| 414 |
|
|---|
| 415 | DWORD dwThreadId; //id of thread that created this window
|
|---|
| 416 | DWORD dwProcessId; //id of process that created this window
|
|---|
| 417 |
|
|---|
| 418 | Win32BaseWindow *owner;
|
|---|
| 419 | HICON hIcon,hIconSm;
|
|---|
| 420 |
|
|---|
| 421 | char *windowNameA;
|
|---|
| 422 | WCHAR *windowNameW;
|
|---|
| 423 |
|
|---|
| 424 | char *userWindowBytes;
|
|---|
| 425 | ULONG nrUserWindowBytes;
|
|---|
| 426 |
|
|---|
| 427 | RECT rectWindow; //relative to parent
|
|---|
| 428 | RECT rectClient; //relative to frame
|
|---|
| 429 | WINDOWPLACEMENT windowpos;
|
|---|
| 430 |
|
|---|
| 431 | PROPERTY *propertyList;
|
|---|
| 432 |
|
|---|
| 433 | HANDLE hTaskList; //PM specific (switchentry handle)
|
|---|
| 434 |
|
|---|
| 435 | CREATESTRUCTA *tmpcs; //temporary pointer to CREATESTRUCT used in CreateWindowEx
|
|---|
| 436 | ULONG sw; //set in CreateWindowExA, used in MsgCreate method
|
|---|
| 437 |
|
|---|
| 438 | SCROLLBAR_INFO *vertScrollInfo;
|
|---|
| 439 | SCROLLBAR_INFO *horzScrollInfo;
|
|---|
| 440 |
|
|---|
| 441 | Win32WndClass *windowClass;
|
|---|
| 442 |
|
|---|
| 443 | static GenericObject *windows;
|
|---|
| 444 | static CRITICAL_SECTION critsect;
|
|---|
| 445 |
|
|---|
| 446 | private:
|
|---|
| 447 | #ifndef OS2_INCLUDED
|
|---|
| 448 | void GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
|
|---|
| 449 | UINT MinMaximize(UINT cmd, LPRECT lpRect);
|
|---|
| 450 | LONG HandleWindowPosChanging(WINDOWPOS *winpos);
|
|---|
| 451 | LONG HandleNCActivate(WPARAM wParam);
|
|---|
| 452 | VOID TrackMinMaxHelpBox(WORD wParam);
|
|---|
| 453 | VOID TrackCloseButton(WORD wParam);
|
|---|
| 454 | VOID TrackScrollBar(WPARAM wParam,POINT pt);
|
|---|
| 455 | LONG HandleNCLButtonDown(WPARAM wParam,LPARAM lParam);
|
|---|
| 456 | LONG HandleNCLButtonDblClk(WPARAM wParam,LPARAM lParam);
|
|---|
| 457 | LONG HandleNCRButtonUp(WPARAM wParam,LPARAM lParam);
|
|---|
| 458 | VOID AdjustRectOuter(LPRECT rect,BOOL menu);
|
|---|
| 459 | VOID AdjustRectInner(LPRECT rect);
|
|---|
| 460 | LONG HandleNCCalcSize(BOOL calcValidRects,RECT *winRect);
|
|---|
| 461 | VOID GetInsideRect(RECT *rect);
|
|---|
| 462 | VOID DrawFrame(HDC hdc,RECT *rect,BOOL dlgFrame,BOOL active);
|
|---|
| 463 | public:
|
|---|
| 464 | LONG HandleNCHitTest(POINT pt);
|
|---|
| 465 | BOOL GetSysPopupPos(RECT* rect);
|
|---|
| 466 | private:
|
|---|
| 467 | BOOL DrawSysButton(HDC hdc,RECT *rect);
|
|---|
| 468 | BOOL DrawGrayButton(HDC hdc,int x,int y);
|
|---|
| 469 | VOID DrawCloseButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
|
|---|
| 470 | VOID DrawMaxButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
|
|---|
| 471 | VOID DrawMinButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
|
|---|
| 472 | VOID DrawContextHelpButton(HDC hdc,RECT *rect,BOOL down,BOOL bGrayed);
|
|---|
| 473 | VOID DrawCaption(HDC hdc,RECT *rect,BOOL active);
|
|---|
| 474 | VOID DoNCPaint(HRGN clip,BOOL suppress_menupaint);
|
|---|
| 475 | LONG HandleNCPaint(HRGN clip);
|
|---|
| 476 | LONG HandleSysCommand(WPARAM wParam, POINT *pt32);
|
|---|
| 477 |
|
|---|
| 478 | LONG SendNCCalcSize(BOOL calcValidRect,
|
|---|
| 479 | RECT *newWindowRect, RECT *oldWindowRect,
|
|---|
| 480 | RECT *oldClientRect, WINDOWPOS *winpos,
|
|---|
| 481 | RECT *newClientRect );
|
|---|
| 482 |
|
|---|
| 483 | #else
|
|---|
| 484 | friend BOOL OS2ToWinMsgTranslate(void *pThdb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fTranslateExtraMsgs);
|
|---|
| 485 | #endif
|
|---|
| 486 |
|
|---|
| 487 | public:
|
|---|
| 488 | void SetFakeOpen32() { WinSetDAXData (OS2Hwnd, &fakeWinBase); }
|
|---|
| 489 | void RemoveFakeOpen32() { WinSetDAXData (OS2Hwnd, NULL); }
|
|---|
| 490 |
|
|---|
| 491 | fakeOpen32WinBaseClass fakeWinBase;
|
|---|
| 492 |
|
|---|
| 493 | VOID AdjustMaximizedRect(LPRECT rect);
|
|---|
| 494 | VOID AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize);
|
|---|
| 495 |
|
|---|
| 496 | //Temporary hack for CS_CLASSDC style (do the same as for CS_OWNDC)
|
|---|
| 497 | #ifndef OS2_INCLUDED
|
|---|
| 498 | BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & (CS_OWNDC|CS_CLASSDC)); }
|
|---|
| 499 | #else
|
|---|
| 500 | BOOL isOwnDC() { return (windowClass && windowClass->getStyle() & (CS_OWNDC_W|CS_CLASSDC_W)); }
|
|---|
| 501 | #endif
|
|---|
| 502 |
|
|---|
| 503 | HDC getOwnDC() { return ownDC; }
|
|---|
| 504 | void setOwnDC(HDC hdc) { ownDC = hdc; }
|
|---|
| 505 | protected:
|
|---|
| 506 | HDC ownDC;
|
|---|
| 507 |
|
|---|
| 508 | public:
|
|---|
| 509 | VOID setEraseBkgnd (BOOL erase) { fEraseBkgndFlag = erase; }
|
|---|
| 510 | BOOL needsEraseBkgnd() { return fEraseBkgndFlag; }
|
|---|
| 511 | };
|
|---|
| 512 |
|
|---|
| 513 | #endif //__cplusplus
|
|---|
| 514 |
|
|---|
| 515 | #endif //__WIN32WNDBASE_H__
|
|---|