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