| 1 | /* $Id: oslibwin.cpp,v 1.122 2002-07-11 18:14:20 achimha Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Window API wrappers for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 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 | #define  INCL_WIN | 
|---|
| 14 | #define  INCL_PM | 
|---|
| 15 | #define  INCL_WINSWITCHLIST | 
|---|
| 16 | #include <os2wrap.h> | 
|---|
| 17 | #include <stdlib.h> | 
|---|
| 18 | #include <string.h> | 
|---|
| 19 |  | 
|---|
| 20 | #include <misc.h> | 
|---|
| 21 | #include <win32type.h> | 
|---|
| 22 | #include <winconst.h> | 
|---|
| 23 | #include <winuser32.h> | 
|---|
| 24 | #include <wprocess.h> | 
|---|
| 25 | #include "oslibwin.h" | 
|---|
| 26 | #include "oslibutil.h" | 
|---|
| 27 | #include "oslibmsg.h" | 
|---|
| 28 | #include "oslibgdi.h" | 
|---|
| 29 | #include "pmwindow.h" | 
|---|
| 30 | #include "initterm.h" | 
|---|
| 31 |  | 
|---|
| 32 | #define DBG_LOCALLOG    DBG_oslibwin | 
|---|
| 33 | #include "dbglocal.h" | 
|---|
| 34 |  | 
|---|
| 35 | //****************************************************************************** | 
|---|
| 36 | //****************************************************************************** | 
|---|
| 37 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw) | 
|---|
| 38 | { | 
|---|
| 39 | if(hwndParent == OSLIB_HWND_DESKTOP) | 
|---|
| 40 | { | 
|---|
| 41 | hwndParent = HWND_DESKTOP; | 
|---|
| 42 | } | 
|---|
| 43 | else | 
|---|
| 44 | if(hwndParent == OSLIB_HWND_OBJECT) { | 
|---|
| 45 | hwndParent = HWND_OBJECT; | 
|---|
| 46 | } | 
|---|
| 47 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0); | 
|---|
| 48 | } | 
|---|
| 49 | //****************************************************************************** | 
|---|
| 50 | //****************************************************************************** | 
|---|
| 51 | BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner) | 
|---|
| 52 | { | 
|---|
| 53 | return WinSetOwner(hwnd, hwndOwner); | 
|---|
| 54 | } | 
|---|
| 55 | //****************************************************************************** | 
|---|
| 56 | //****************************************************************************** | 
|---|
| 57 | HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle, ULONG dwOSFrameStyle, | 
|---|
| 58 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM, | 
|---|
| 59 | ULONG id, BOOL fTaskList,BOOL fShellPosition, | 
|---|
| 60 | int classStyle, HWND *hwndFrame) | 
|---|
| 61 | { | 
|---|
| 62 | HWND  hwndClient; | 
|---|
| 63 | ULONG dwFrameStyle = 0; | 
|---|
| 64 |  | 
|---|
| 65 | if(pszName && *pszName == 0) { | 
|---|
| 66 | pszName = NULL; | 
|---|
| 67 | } | 
|---|
| 68 | if(hwndParent == OSLIB_HWND_DESKTOP) { | 
|---|
| 69 | hwndParent = HWND_DESKTOP; | 
|---|
| 70 | } | 
|---|
| 71 | if(Owner == OSLIB_HWND_DESKTOP) { | 
|---|
| 72 | Owner = HWND_DESKTOP; | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS; | 
|---|
| 76 | if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP; | 
|---|
| 77 |  | 
|---|
| 78 | dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP); | 
|---|
| 79 |  | 
|---|
| 80 | if(fTaskList) | 
|---|
| 81 | { | 
|---|
| 82 | dwFrameStyle |= FCF_NOMOVEWITHOWNER; | 
|---|
| 83 | } | 
|---|
| 84 | if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION; | 
|---|
| 85 |  | 
|---|
| 86 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0}; | 
|---|
| 87 | FCData.flCreateFlags = dwFrameStyle; | 
|---|
| 88 |  | 
|---|
| 89 | dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM)); | 
|---|
| 90 |  | 
|---|
| 91 | //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise. | 
|---|
| 92 | //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds | 
|---|
| 93 | //    a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border | 
|---|
| 94 | *hwndFrame = WinCreateWindow(hwndParent, | 
|---|
| 95 | WIN32_STDFRAMECLASS, | 
|---|
| 96 | pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0, | 
|---|
| 97 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP, | 
|---|
| 98 | id, (PVOID)&FCData, NULL); | 
|---|
| 99 | if(fOS2Look && *hwndFrame) { | 
|---|
| 100 | FCData.flCreateFlags = dwOSFrameStyle; | 
|---|
| 101 | //        FCData.flCreateFlags = FCF_TITLEBAR|FCF_SYSMENU|FCF_MINMAX; | 
|---|
| 102 | WinCreateFrameControls(*hwndFrame, &FCData, NULL); | 
|---|
| 103 | } | 
|---|
| 104 | hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS, | 
|---|
| 105 | NULL, dwWinStyle | WS_VISIBLE, 0, 0, 0, 0, | 
|---|
| 106 | *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL); | 
|---|
| 107 |  | 
|---|
| 108 | return hwndClient; | 
|---|
| 109 | } | 
|---|
| 110 | //****************************************************************************** | 
|---|
| 111 | //Note: Also check OSLibSetWindowStyle when changing this!! | 
|---|
| 112 | //****************************************************************************** | 
|---|
| 113 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle) | 
|---|
| 114 | { | 
|---|
| 115 | *OSWinStyle   = 0; | 
|---|
| 116 | *OSFrameStyle = 0; | 
|---|
| 117 |  | 
|---|
| 118 | /* Window styles */ | 
|---|
| 119 | if(dwStyle & WS_DISABLED_W) | 
|---|
| 120 | *OSWinStyle |= WS_DISABLED; | 
|---|
| 121 | if(dwStyle & WS_CLIPSIBLINGS_W) | 
|---|
| 122 | *OSWinStyle |= WS_CLIPSIBLINGS; | 
|---|
| 123 | if(dwStyle & WS_CLIPCHILDREN_W) | 
|---|
| 124 | *OSWinStyle |= WS_CLIPCHILDREN; | 
|---|
| 125 |  | 
|---|
| 126 | if(fOS2Look) { | 
|---|
| 127 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) { | 
|---|
| 128 | *OSFrameStyle = FCF_TITLEBAR; | 
|---|
| 129 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W)) | 
|---|
| 130 | { | 
|---|
| 131 | *OSFrameStyle |= FCF_SYSMENU; | 
|---|
| 132 | } | 
|---|
| 133 | if(dwStyle & WS_MINIMIZEBOX_W) { | 
|---|
| 134 | *OSFrameStyle |= FCF_MINBUTTON; | 
|---|
| 135 | } | 
|---|
| 136 | if(dwStyle & WS_MAXIMIZEBOX_W) { | 
|---|
| 137 | *OSFrameStyle |= FCF_MAXBUTTON; | 
|---|
| 138 | } | 
|---|
| 139 | if(dwStyle & WS_SYSMENU_W) { | 
|---|
| 140 | *OSFrameStyle |= FCF_CLOSEBUTTON; | 
|---|
| 141 | } | 
|---|
| 142 | } | 
|---|
| 143 | } | 
|---|
| 144 | return TRUE; | 
|---|
| 145 | } | 
|---|
| 146 | //****************************************************************************** | 
|---|
| 147 | //****************************************************************************** | 
|---|
| 148 | BOOL OSLibWinPositionFrameControls(HWND hwndFrame, RECTLOS2 *pRect, DWORD dwStyle, | 
|---|
| 149 | DWORD dwExStyle, HICON hSysMenuIcon) | 
|---|
| 150 | { | 
|---|
| 151 | SWP  swp[3]; | 
|---|
| 152 | HWND hwndControl; | 
|---|
| 153 | int  i = 0; | 
|---|
| 154 | static int minmaxwidth  = 0; | 
|---|
| 155 | static int minmaxheight = 0; | 
|---|
| 156 |  | 
|---|
| 157 | if(minmaxwidth == 0) { | 
|---|
| 158 | minmaxwidth  = WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON); | 
|---|
| 159 | minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON); | 
|---|
| 160 | } | 
|---|
| 161 |  | 
|---|
| 162 | if(fOS2Look == OS2_APPEARANCE_SYSMENU) { | 
|---|
| 163 | hwndControl = WinWindowFromID(hwndFrame, FID_SYSMENU); | 
|---|
| 164 | if(hwndControl) { | 
|---|
| 165 | swp[i].hwnd = hwndControl; | 
|---|
| 166 | swp[i].hwndInsertBehind = HWND_TOP; | 
|---|
| 167 | swp[i].x  = pRect->xLeft; | 
|---|
| 168 | swp[i].y  = pRect->yBottom; | 
|---|
| 169 | if(pRect->yTop - pRect->yBottom > minmaxheight) { | 
|---|
| 170 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight; | 
|---|
| 171 | } | 
|---|
| 172 | swp[i].cx = minmaxwidth/2; | 
|---|
| 173 | swp[i].cy = minmaxheight;; | 
|---|
| 174 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW; | 
|---|
| 175 | dprintf(("FID_SYSMENU (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy)); | 
|---|
| 176 | pRect->xLeft += minmaxwidth/2; | 
|---|
| 177 | i++; | 
|---|
| 178 | } | 
|---|
| 179 | } | 
|---|
| 180 | else | 
|---|
| 181 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W) && hSysMenuIcon) { | 
|---|
| 182 | pRect->xLeft += minmaxwidth/2; | 
|---|
| 183 | } | 
|---|
| 184 |  | 
|---|
| 185 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) { | 
|---|
| 186 | hwndControl = WinWindowFromID(hwndFrame, FID_TITLEBAR); | 
|---|
| 187 | if(hwndControl) { | 
|---|
| 188 | swp[i].hwnd = hwndControl; | 
|---|
| 189 | swp[i].hwndInsertBehind = HWND_TOP; | 
|---|
| 190 | swp[i].x  = pRect->xLeft; | 
|---|
| 191 | swp[i].y  = pRect->yBottom; | 
|---|
| 192 | if(pRect->yTop - pRect->yBottom > minmaxheight) { | 
|---|
| 193 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight; | 
|---|
| 194 | } | 
|---|
| 195 | swp[i].cx = pRect->xRight - pRect->xLeft; | 
|---|
| 196 | if((dwStyle & WS_MINIMIZEBOX_W)) { | 
|---|
| 197 | swp[i].cx -= minmaxwidth/2; | 
|---|
| 198 | } | 
|---|
| 199 | if((dwStyle & WS_MAXIMIZEBOX_W)) { | 
|---|
| 200 | swp[i].cx -= minmaxwidth/2; | 
|---|
| 201 | } | 
|---|
| 202 | //there is no close button in warp 3 | 
|---|
| 203 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3) { | 
|---|
| 204 | swp[i].cx -= minmaxwidth/2; | 
|---|
| 205 | } | 
|---|
| 206 | swp[i].cy = minmaxheight; | 
|---|
| 207 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW; | 
|---|
| 208 | dprintf(("FID_TITLEBAR (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy)); | 
|---|
| 209 | pRect->xLeft += swp[i].cx; | 
|---|
| 210 | i++; | 
|---|
| 211 | } | 
|---|
| 212 | else return FALSE; //no titlebar -> no frame controls | 
|---|
| 213 | } | 
|---|
| 214 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W) || (dwStyle & WS_SYSMENU_W)) { | 
|---|
| 215 | hwndControl = WinWindowFromID(hwndFrame, FID_MINMAX); | 
|---|
| 216 | if(hwndControl) { | 
|---|
| 217 | swp[i].hwnd = hwndControl; | 
|---|
| 218 | swp[i].hwndInsertBehind = HWND_TOP; | 
|---|
| 219 | swp[i].x  = pRect->xLeft; | 
|---|
| 220 | swp[i].y  = pRect->yBottom; | 
|---|
| 221 | if(pRect->yTop - pRect->yBottom > minmaxheight) { | 
|---|
| 222 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight; | 
|---|
| 223 | } | 
|---|
| 224 | swp[i].cx = 0; | 
|---|
| 225 | if((dwStyle & WS_MINIMIZEBOX_W)) { | 
|---|
| 226 | swp[i].cx += minmaxwidth/2; | 
|---|
| 227 | } | 
|---|
| 228 | if((dwStyle & WS_MAXIMIZEBOX_W)) { | 
|---|
| 229 | swp[i].cx += minmaxwidth/2; | 
|---|
| 230 | } | 
|---|
| 231 | //there is no close button in warp 3 | 
|---|
| 232 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3) { | 
|---|
| 233 | swp[i].cx += minmaxwidth/2; | 
|---|
| 234 | } | 
|---|
| 235 | swp[i].cy = minmaxheight; | 
|---|
| 236 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW; | 
|---|
| 237 | dprintf(("FID_MINMAX (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy)); | 
|---|
| 238 | pRect->xLeft += swp[i].cx; | 
|---|
| 239 | i++; | 
|---|
| 240 | } | 
|---|
| 241 | } | 
|---|
| 242 | return WinSetMultWindowPos(GetThreadHAB(), swp, i); | 
|---|
| 243 | } | 
|---|
| 244 | //****************************************************************************** | 
|---|
| 245 | //****************************************************************************** | 
|---|
| 246 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value) | 
|---|
| 247 | { | 
|---|
| 248 | if(offset == OSLIB_QWL_USER) | 
|---|
| 249 | offset = QWL_USER; | 
|---|
| 250 |  | 
|---|
| 251 | return WinSetWindowULong(hwnd, offset, value); | 
|---|
| 252 | } | 
|---|
| 253 | //****************************************************************************** | 
|---|
| 254 | //****************************************************************************** | 
|---|
| 255 | BOOL OSLibWinGetMinPosition(HWND hwnd, PSWP pswp, PPOINTL pointl) | 
|---|
| 256 | { | 
|---|
| 257 | return WinGetMinPosition(hwnd, pswp, pointl); | 
|---|
| 258 | } | 
|---|
| 259 |  | 
|---|
| 260 | //****************************************************************************** | 
|---|
| 261 | //****************************************************************************** | 
|---|
| 262 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset) | 
|---|
| 263 | { | 
|---|
| 264 | if(offset == OSLIB_QWL_USER) | 
|---|
| 265 | offset = QWL_USER; | 
|---|
| 266 |  | 
|---|
| 267 | return WinQueryWindowULong(hwnd, offset); | 
|---|
| 268 | } | 
|---|
| 269 | //****************************************************************************** | 
|---|
| 270 | //****************************************************************************** | 
|---|
| 271 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle) | 
|---|
| 272 | { | 
|---|
| 273 | return WinAlarm(hwndDeskTop,flStyle); | 
|---|
| 274 | } | 
|---|
| 275 | //****************************************************************************** | 
|---|
| 276 | HWND OSLibWinQueryFocus(HWND hwndDeskTop) | 
|---|
| 277 | { | 
|---|
| 278 | return WinQueryFocus(hwndDeskTop); | 
|---|
| 279 | } | 
|---|
| 280 | //****************************************************************************** | 
|---|
| 281 | //****************************************************************************** | 
|---|
| 282 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id) | 
|---|
| 283 | { | 
|---|
| 284 | return WinWindowFromID(hwndParent,id); | 
|---|
| 285 | } | 
|---|
| 286 | //****************************************************************************** | 
|---|
| 287 | //****************************************************************************** | 
|---|
| 288 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate) | 
|---|
| 289 | { | 
|---|
| 290 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? 0 : FC_NOSETACTIVE); | 
|---|
| 291 | } | 
|---|
| 292 | //****************************************************************************** | 
|---|
| 293 | //****************************************************************************** | 
|---|
| 294 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf) | 
|---|
| 295 | { | 
|---|
| 296 | return WinIsChild (hwnd, hwndOf); | 
|---|
| 297 | } | 
|---|
| 298 | //****************************************************************************** | 
|---|
| 299 | //****************************************************************************** | 
|---|
| 300 | ULONG OSLibGetWindowHeight(HWND hwnd) | 
|---|
| 301 | { | 
|---|
| 302 | RECTL rect; | 
|---|
| 303 |  | 
|---|
| 304 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0; | 
|---|
| 305 | } | 
|---|
| 306 | //****************************************************************************** | 
|---|
| 307 | //****************************************************************************** | 
|---|
| 308 | LONG OSLibWinQuerySysValue(LONG iSysValue) | 
|---|
| 309 | { | 
|---|
| 310 | return WinQuerySysValue(HWND_DESKTOP,iSysValue); | 
|---|
| 311 | } | 
|---|
| 312 | //****************************************************************************** | 
|---|
| 313 | //****************************************************************************** | 
|---|
| 314 | BOOL OSLibWinSetSysValue(LONG iSysValue, ULONG val) | 
|---|
| 315 | { | 
|---|
| 316 | return WinQuerySysValue(iSysValue, val); | 
|---|
| 317 | } | 
|---|
| 318 | //****************************************************************************** | 
|---|
| 319 | //****************************************************************************** | 
|---|
| 320 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer) | 
|---|
| 321 | { | 
|---|
| 322 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer); | 
|---|
| 323 | } | 
|---|
| 324 | //****************************************************************************** | 
|---|
| 325 | //****************************************************************************** | 
|---|
| 326 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText) | 
|---|
| 327 | { | 
|---|
| 328 | return WinSetDlgItemText(hwndDlg,idItem,pszText); | 
|---|
| 329 | } | 
|---|
| 330 | //****************************************************************************** | 
|---|
| 331 | //****************************************************************************** | 
|---|
| 332 | BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint) | 
|---|
| 333 | { | 
|---|
| 334 | return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint); | 
|---|
| 335 | } | 
|---|
| 336 | //****************************************************************************** | 
|---|
| 337 | //****************************************************************************** | 
|---|
| 338 | BOOL OSLibWinSetPointerPos(int x, int y) | 
|---|
| 339 | { | 
|---|
| 340 | return WinSetPointerPos(HWND_DESKTOP, x, y); | 
|---|
| 341 | } | 
|---|
| 342 | //****************************************************************************** | 
|---|
| 343 | //****************************************************************************** | 
|---|
| 344 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode) | 
|---|
| 345 | { | 
|---|
| 346 | return WinQueryWindow(hwnd, lCode); | 
|---|
| 347 | } | 
|---|
| 348 | //****************************************************************************** | 
|---|
| 349 | //****************************************************************************** | 
|---|
| 350 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num) | 
|---|
| 351 | { | 
|---|
| 352 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num); | 
|---|
| 353 | } | 
|---|
| 354 | //****************************************************************************** | 
|---|
| 355 | //****************************************************************************** | 
|---|
| 356 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl) | 
|---|
| 357 | { | 
|---|
| 358 | BOOL rc = 1; | 
|---|
| 359 |  | 
|---|
| 360 | if(fl & SWP_SHOW) { | 
|---|
| 361 | rc = WinShowWindow(hwnd, TRUE); | 
|---|
| 362 | } | 
|---|
| 363 | if(rc == 0) | 
|---|
| 364 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB()))); | 
|---|
| 365 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl); | 
|---|
| 366 | if(rc == 0) | 
|---|
| 367 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB()))); | 
|---|
| 368 | return rc; | 
|---|
| 369 | } | 
|---|
| 370 | //****************************************************************************** | 
|---|
| 371 | //****************************************************************************** | 
|---|
| 372 | BOOL OSLibWinDestroyWindow(HWND hwnd) | 
|---|
| 373 | { | 
|---|
| 374 | return WinDestroyWindow(hwnd); | 
|---|
| 375 | } | 
|---|
| 376 | //****************************************************************************** | 
|---|
| 377 | //****************************************************************************** | 
|---|
| 378 | BOOL  OSLibWinQueryWindowClientRect(HWND hwndOS2, PRECT pRect) | 
|---|
| 379 | { | 
|---|
| 380 | BOOL     rc; | 
|---|
| 381 | RECTLOS2 rectl; | 
|---|
| 382 |  | 
|---|
| 383 | rc = WinQueryWindowRect(hwndOS2, (PRECTL)&rectl); | 
|---|
| 384 | if(rc) { | 
|---|
| 385 | pRect->left   = 0; | 
|---|
| 386 | pRect->right  = rectl.xRight - rectl.xLeft; | 
|---|
| 387 | pRect->top    = 0; | 
|---|
| 388 | pRect->bottom = rectl.yTop - rectl.yBottom; | 
|---|
| 389 | } | 
|---|
| 390 | else  memset(pRect, 0, sizeof(RECT)); | 
|---|
| 391 | return rc; | 
|---|
| 392 | } | 
|---|
| 393 | //****************************************************************************** | 
|---|
| 394 | //****************************************************************************** | 
|---|
| 395 | BOOL OSLibQueryWindowRectAbsolute (HWND hwndOS2, PRECT pRect) | 
|---|
| 396 | { | 
|---|
| 397 | BOOL     rc; | 
|---|
| 398 | RECTLOS2 rectl; | 
|---|
| 399 |  | 
|---|
| 400 | rc = WinQueryWindowRect (hwndOS2, (RECTL *)&rectl); | 
|---|
| 401 | if (rc) | 
|---|
| 402 | { | 
|---|
| 403 | rc = WinMapWindowPoints (hwndOS2, HWND_DESKTOP, (POINTL *)&rectl, 2); | 
|---|
| 404 | if (rc) | 
|---|
| 405 | { | 
|---|
| 406 | pRect->left   = rectl.xLeft; | 
|---|
| 407 | pRect->right  = rectl.xRight; | 
|---|
| 408 | pRect->top    = mapScreenY (rectl.yTop); | 
|---|
| 409 | pRect->bottom = mapScreenY (rectl.yBottom); | 
|---|
| 410 | } | 
|---|
| 411 | } | 
|---|
| 412 | if (!rc) | 
|---|
| 413 | { | 
|---|
| 414 | memset(pRect, 0, sizeof(*pRect)); | 
|---|
| 415 | } | 
|---|
| 416 | return rc; | 
|---|
| 417 | } | 
|---|
| 418 | //****************************************************************************** | 
|---|
| 419 | //****************************************************************************** | 
|---|
| 420 | #if 0 | 
|---|
| 421 | BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo) | 
|---|
| 422 | { | 
|---|
| 423 | BOOL     rc; | 
|---|
| 424 | RECTLOS2 rectl; | 
|---|
| 425 |  | 
|---|
| 426 | rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl); | 
|---|
| 427 | if(rc) { | 
|---|
| 428 | if(RelativeTo == RELATIVE_TO_SCREEN) { | 
|---|
| 429 | mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect); | 
|---|
| 430 | } | 
|---|
| 431 | else    mapOS2ToWin32RectFrame(window,&rectl,pRect); | 
|---|
| 432 | } | 
|---|
| 433 | else  memset(pRect, 0, sizeof(RECT)); | 
|---|
| 434 | return rc; | 
|---|
| 435 | } | 
|---|
| 436 | #endif | 
|---|
| 437 | //****************************************************************************** | 
|---|
| 438 | //****************************************************************************** | 
|---|
| 439 | BOOL OSLibWinIsIconic(HWND hwnd) | 
|---|
| 440 | { | 
|---|
| 441 | SWP  swp; | 
|---|
| 442 | BOOL rc; | 
|---|
| 443 |  | 
|---|
| 444 | rc = WinQueryWindowPos(hwnd, &swp); | 
|---|
| 445 | if(rc == FALSE) { | 
|---|
| 446 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd)); | 
|---|
| 447 | return FALSE; | 
|---|
| 448 | } | 
|---|
| 449 |  | 
|---|
| 450 | if(swp.fl & SWP_MINIMIZE) | 
|---|
| 451 | return TRUE; | 
|---|
| 452 | else  return FALSE; | 
|---|
| 453 | } | 
|---|
| 454 | //****************************************************************************** | 
|---|
| 455 | //****************************************************************************** | 
|---|
| 456 | BOOL OSLibWinSetActiveWindow(HWND hwnd) | 
|---|
| 457 | { | 
|---|
| 458 | BOOL rc; | 
|---|
| 459 |  | 
|---|
| 460 | rc = WinSetActiveWindow(HWND_DESKTOP, hwnd); | 
|---|
| 461 | if(rc == FALSE) { | 
|---|
| 462 | dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError())); | 
|---|
| 463 | } | 
|---|
| 464 | return rc; | 
|---|
| 465 | } | 
|---|
| 466 | //****************************************************************************** | 
|---|
| 467 | //****************************************************************************** | 
|---|
| 468 | BOOL OSLibWinSetFocus(HWND hwnd) | 
|---|
| 469 | { | 
|---|
| 470 | return WinSetFocus(HWND_DESKTOP, hwnd); | 
|---|
| 471 | } | 
|---|
| 472 | //****************************************************************************** | 
|---|
| 473 | //****************************************************************************** | 
|---|
| 474 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable) | 
|---|
| 475 | { | 
|---|
| 476 | BOOL rc; | 
|---|
| 477 | HWND hwndClient; | 
|---|
| 478 |  | 
|---|
| 479 | rc = WinEnableWindow(hwnd, fEnable); | 
|---|
| 480 | hwndClient = WinWindowFromID(hwnd, FID_CLIENT); | 
|---|
| 481 | if(hwndClient) { | 
|---|
| 482 | WinEnableWindow(hwndClient, fEnable); | 
|---|
| 483 | } | 
|---|
| 484 | return rc; | 
|---|
| 485 | } | 
|---|
| 486 | //****************************************************************************** | 
|---|
| 487 | //****************************************************************************** | 
|---|
| 488 | BOOL OSLibWinIsWindowEnabled(HWND hwnd) | 
|---|
| 489 | { | 
|---|
| 490 | return WinIsWindowEnabled(hwnd); | 
|---|
| 491 | } | 
|---|
| 492 | //****************************************************************************** | 
|---|
| 493 | //****************************************************************************** | 
|---|
| 494 | BOOL OSLibWinIsWindowVisible(HWND hwnd) | 
|---|
| 495 | { | 
|---|
| 496 | return WinIsWindowVisible(hwnd); | 
|---|
| 497 | } | 
|---|
| 498 | //****************************************************************************** | 
|---|
| 499 | //****************************************************************************** | 
|---|
| 500 | HWND OSLibWinQueryActiveWindow() | 
|---|
| 501 | { | 
|---|
| 502 | return WinQueryActiveWindow(HWND_DESKTOP); | 
|---|
| 503 | } | 
|---|
| 504 | //****************************************************************************** | 
|---|
| 505 | //****************************************************************************** | 
|---|
| 506 | LONG OSLibWinQueryWindowTextLength(HWND hwnd) | 
|---|
| 507 | { | 
|---|
| 508 | return WinQueryWindowTextLength(hwnd); | 
|---|
| 509 | } | 
|---|
| 510 | //****************************************************************************** | 
|---|
| 511 | //****************************************************************************** | 
|---|
| 512 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz) | 
|---|
| 513 | { | 
|---|
| 514 | return WinQueryWindowText(hwnd, length, lpsz); | 
|---|
| 515 | } | 
|---|
| 516 | //****************************************************************************** | 
|---|
| 517 | //****************************************************************************** | 
|---|
| 518 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz) | 
|---|
| 519 | { | 
|---|
| 520 | return WinSetWindowText(hwnd, lpsz); | 
|---|
| 521 | } | 
|---|
| 522 | //****************************************************************************** | 
|---|
| 523 | //****************************************************************************** | 
|---|
| 524 | BOOL OSLibWinSetTitleBarText(HWND hwnd, LPSTR lpsz) | 
|---|
| 525 | { | 
|---|
| 526 | return WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), lpsz); | 
|---|
| 527 | } | 
|---|
| 528 | //****************************************************************************** | 
|---|
| 529 | //****************************************************************************** | 
|---|
| 530 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash) | 
|---|
| 531 | { | 
|---|
| 532 | return WinFlashWindow(hwnd, fFlash); | 
|---|
| 533 | } | 
|---|
| 534 | //****************************************************************************** | 
|---|
| 535 | //****************************************************************************** | 
|---|
| 536 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint) | 
|---|
| 537 | { | 
|---|
| 538 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE); | 
|---|
| 539 | } | 
|---|
| 540 | //****************************************************************************** | 
|---|
| 541 | //****************************************************************************** | 
|---|
| 542 | BOOL OSLibWinMinimizeWindow(HWND hwnd) | 
|---|
| 543 | { | 
|---|
| 544 | /* @@PF The reason for this weird minimize algorithm is that we are not fully | 
|---|
| 545 | using PM for minimization. I.e. we respect all PM messages yet we do mess | 
|---|
| 546 | so much with some messages that minimization is based partly on vodoo. | 
|---|
| 547 | That is if you try minimize and deactivate in one call it will fail. | 
|---|
| 548 | Here we deactivate yourselves and give focus to next window that is | 
|---|
| 549 | on desktop, this func also works with MDI */ | 
|---|
| 550 |  | 
|---|
| 551 | BOOL rc; | 
|---|
| 552 | HWND hwndNext; | 
|---|
| 553 |  | 
|---|
| 554 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE); | 
|---|
| 555 | if (rc) { | 
|---|
| 556 | rc = WinSetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE | SWP_ZORDER); | 
|---|
| 557 | if (rc) | 
|---|
| 558 | { | 
|---|
| 559 | HENUM henum; | 
|---|
| 560 | henum = WinBeginEnumWindows(HWND_DESKTOP); | 
|---|
| 561 | while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE) | 
|---|
| 562 | { | 
|---|
| 563 | if (WinIsWindowVisible(hwndNext) && WinIsWindowShowing(hwndNext)) break; | 
|---|
| 564 | } | 
|---|
| 565 | WinEndEnumWindows (henum); | 
|---|
| 566 | rc = WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 567 | } | 
|---|
| 568 | } | 
|---|
| 569 | return (rc); | 
|---|
| 570 | } | 
|---|
| 571 | //****************************************************************************** | 
|---|
| 572 | //****************************************************************************** | 
|---|
| 573 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl) | 
|---|
| 574 | { | 
|---|
| 575 | pointl->x = 0; | 
|---|
| 576 | pointl->y = 0; | 
|---|
| 577 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0); | 
|---|
| 578 | } | 
|---|
| 579 | //****************************************************************************** | 
|---|
| 580 | //****************************************************************************** | 
|---|
| 581 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon) | 
|---|
| 582 | { | 
|---|
| 583 | ULONG hIconOS2 = GetOS2Icon(hIcon); | 
|---|
| 584 | if(hIconOS2) | 
|---|
| 585 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIconOS2, 0); | 
|---|
| 586 | return FALSE; | 
|---|
| 587 | } | 
|---|
| 588 | //****************************************************************************** | 
|---|
| 589 | //****************************************************************************** | 
|---|
| 590 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp) | 
|---|
| 591 | { | 
|---|
| 592 | return WinQueryWindowPos(hwnd, pswp); | 
|---|
| 593 | } | 
|---|
| 594 | //****************************************************************************** | 
|---|
| 595 | //****************************************************************************** | 
|---|
| 596 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, | 
|---|
| 597 | int parentHeight, HWND hwnd) | 
|---|
| 598 | { | 
|---|
| 599 | HWND hWindow            = pswp->hwnd; | 
|---|
| 600 | HWND hWndInsertAfter    = pswp->hwndInsertBehind; | 
|---|
| 601 | long x                  = pswp->x; | 
|---|
| 602 | long y                  = pswp->y; | 
|---|
| 603 | long cx                 = pswp->cx; | 
|---|
| 604 | long cy                 = pswp->cy; | 
|---|
| 605 | UINT fuFlags            = (UINT)pswp->fl; | 
|---|
| 606 |  | 
|---|
| 607 | HWND   hWinAfter; | 
|---|
| 608 | ULONG  flags = 0; | 
|---|
| 609 |  | 
|---|
| 610 | HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow; | 
|---|
| 611 |  | 
|---|
| 612 | if (hWndInsertAfter == HWND_TOP) | 
|---|
| 613 | hWinAfter = HWND_TOP_W; | 
|---|
| 614 | else if (hWndInsertAfter == HWND_BOTTOM) | 
|---|
| 615 | hWinAfter = HWND_BOTTOM_W; | 
|---|
| 616 | else | 
|---|
| 617 | hWinAfter = (HWND) hWndInsertAfter; | 
|---|
| 618 |  | 
|---|
| 619 | //*********************************** | 
|---|
| 620 | // convert PM flags to Windows flags | 
|---|
| 621 | //*********************************** | 
|---|
| 622 | if (!(fuFlags & SWP_SIZE))       flags |= SWP_NOSIZE_W; | 
|---|
| 623 | if (!(fuFlags & SWP_MOVE))       flags |= SWP_NOMOVE_W; | 
|---|
| 624 | if (!(fuFlags & SWP_ZORDER))     flags |= SWP_NOZORDER_W; | 
|---|
| 625 | if (  fuFlags & SWP_NOREDRAW)    flags |= SWP_NOREDRAW_W; | 
|---|
| 626 | if (!(fuFlags & SWP_ACTIVATE))   flags |= SWP_NOACTIVATE_W; | 
|---|
| 627 | if (  fuFlags & SWP_SHOW)        flags |= SWP_SHOWWINDOW_W; | 
|---|
| 628 | if (  fuFlags & SWP_HIDE)        flags |= SWP_HIDEWINDOW_W; | 
|---|
| 629 | if (  fuFlags & SWP_NOADJUST)    flags |= SWP_NOSENDCHANGING_W; | 
|---|
| 630 |  | 
|---|
| 631 | if(fuFlags & (SWP_MOVE | SWP_SIZE)) | 
|---|
| 632 | { | 
|---|
| 633 | y  = parentHeight - y - pswp->cy; | 
|---|
| 634 |  | 
|---|
| 635 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y)) | 
|---|
| 636 | flags |= SWP_NOMOVE_W; | 
|---|
| 637 |  | 
|---|
| 638 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy)) | 
|---|
| 639 | flags |= SWP_NOSIZE_W; | 
|---|
| 640 |  | 
|---|
| 641 | if (fuFlags & SWP_SIZE) | 
|---|
| 642 | { | 
|---|
| 643 | if (pswp->cy != pswpOld->cy) | 
|---|
| 644 | { | 
|---|
| 645 | flags &= ~SWP_NOMOVE_W; | 
|---|
| 646 | } | 
|---|
| 647 | } | 
|---|
| 648 | } | 
|---|
| 649 |  | 
|---|
| 650 | pswpOld->x  = pswp->x; | 
|---|
| 651 | pswpOld->y  = parentHeight-pswp->y-pswp->cy; | 
|---|
| 652 | pswpOld->cx = pswp->cx; | 
|---|
| 653 | pswpOld->cy = pswp->cy; | 
|---|
| 654 |  | 
|---|
| 655 | dprintf(("window (%d,%d)(%d,%d)  client (%d,%d)(%d,%d)", | 
|---|
| 656 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy)); | 
|---|
| 657 |  | 
|---|
| 658 | pwpos->flags            = (UINT)flags; | 
|---|
| 659 | pwpos->cy               = cy; | 
|---|
| 660 | pwpos->cx               = cx; | 
|---|
| 661 | pwpos->x                = x; | 
|---|
| 662 | pwpos->y                = y; | 
|---|
| 663 | pwpos->hwndInsertAfter  = hWinAfter; | 
|---|
| 664 | pwpos->hwnd             = hWindow; | 
|---|
| 665 | } | 
|---|
| 666 | //****************************************************************************** | 
|---|
| 667 | //****************************************************************************** | 
|---|
| 668 | void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, | 
|---|
| 669 | int parentHeight, HWND hFrame) | 
|---|
| 670 | { | 
|---|
| 671 | BOOL fCvt = FALSE; | 
|---|
| 672 |  | 
|---|
| 673 | HWND hWnd            = pwpos->hwnd; | 
|---|
| 674 | HWND hWndInsertAfter = pwpos->hwndInsertAfter; | 
|---|
| 675 | long x               = pwpos->x; | 
|---|
| 676 | long y               = pwpos->y; | 
|---|
| 677 | long cx              = pwpos->cx; | 
|---|
| 678 | long cy              = pwpos->cy; | 
|---|
| 679 | UINT fuFlags         = pwpos->flags; | 
|---|
| 680 |  | 
|---|
| 681 | HWND  hWinAfter; | 
|---|
| 682 | ULONG flags = 0; | 
|---|
| 683 | HWND  hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP; | 
|---|
| 684 |  | 
|---|
| 685 | if (hWndInsertAfter == HWND_TOPMOST_W) | 
|---|
| 686 | //      hWinAfter = HWND_TOPMOST; | 
|---|
| 687 | hWinAfter = HWND_TOP; | 
|---|
| 688 | else if (hWndInsertAfter == HWND_NOTOPMOST_W) | 
|---|
| 689 | //      hWinAfter = HWND_NOTOPMOST; | 
|---|
| 690 | hWinAfter = HWND_TOP; | 
|---|
| 691 | else if (hWndInsertAfter == HWND_TOP_W) | 
|---|
| 692 | hWinAfter = HWND_TOP; | 
|---|
| 693 | else if (hWndInsertAfter == HWND_BOTTOM_W) | 
|---|
| 694 | hWinAfter = HWND_BOTTOM; | 
|---|
| 695 | else | 
|---|
| 696 | hWinAfter = (HWND) hWndInsertAfter; | 
|---|
| 697 |  | 
|---|
| 698 | if (!(fuFlags & SWP_NOSIZE_W    )) flags |= SWP_SIZE; | 
|---|
| 699 | if (!(fuFlags & SWP_NOMOVE_W    )) flags |= SWP_MOVE; | 
|---|
| 700 | if (!(fuFlags & SWP_NOZORDER_W  )) flags |= SWP_ZORDER; | 
|---|
| 701 | if (  fuFlags & SWP_NOREDRAW_W  )  flags |= SWP_NOREDRAW; | 
|---|
| 702 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE; | 
|---|
| 703 | if (  fuFlags & SWP_SHOWWINDOW_W)  flags |= SWP_SHOW; | 
|---|
| 704 | if (  fuFlags & SWP_HIDEWINDOW_W)  flags |= SWP_HIDE; | 
|---|
| 705 | if (  fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST; | 
|---|
| 706 |  | 
|---|
| 707 | if(flags & (SWP_MOVE | SWP_SIZE)) | 
|---|
| 708 | { | 
|---|
| 709 | if((flags & SWP_MOVE) == 0) | 
|---|
| 710 | { | 
|---|
| 711 | x = pswpOld->x; | 
|---|
| 712 | y = pswpOld->y; | 
|---|
| 713 |  | 
|---|
| 714 | y = parentHeight - y - pswpOld->cy; | 
|---|
| 715 | } | 
|---|
| 716 |  | 
|---|
| 717 | if(flags & SWP_SIZE) | 
|---|
| 718 | { | 
|---|
| 719 | if (cy != pswpOld->cy) | 
|---|
| 720 | flags |= SWP_MOVE; | 
|---|
| 721 | } | 
|---|
| 722 | else | 
|---|
| 723 | { | 
|---|
| 724 | cx = pswpOld->cx; | 
|---|
| 725 | cy = pswpOld->cy; | 
|---|
| 726 | } | 
|---|
| 727 | y = parentHeight - y - cy; | 
|---|
| 728 |  | 
|---|
| 729 | if ((pswpOld->x == x) && (pswpOld->y == y)) | 
|---|
| 730 | flags &= ~SWP_MOVE; | 
|---|
| 731 |  | 
|---|
| 732 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy)) | 
|---|
| 733 | flags &= ~SWP_SIZE; | 
|---|
| 734 | } | 
|---|
| 735 |  | 
|---|
| 736 | pswp->fl               = flags; | 
|---|
| 737 | pswp->cy               = cy; | 
|---|
| 738 | pswp->cx               = cx; | 
|---|
| 739 | pswp->x                = x; | 
|---|
| 740 | pswp->y                = y; | 
|---|
| 741 | pswp->hwndInsertBehind = hWinAfter; | 
|---|
| 742 | pswp->hwnd             = hWindow; | 
|---|
| 743 | pswp->ulReserved1      = 0; | 
|---|
| 744 | pswp->ulReserved2      = 0; | 
|---|
| 745 | } | 
|---|
| 746 | //****************************************************************************** | 
|---|
| 747 | //****************************************************************************** | 
|---|
| 748 | void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight) | 
|---|
| 749 | { | 
|---|
| 750 | SWP swp; | 
|---|
| 751 | BOOL rc; | 
|---|
| 752 |  | 
|---|
| 753 | swp.hwnd = hwnd; | 
|---|
| 754 | swp.hwndInsertBehind = 0; | 
|---|
| 755 | swp.x  = x; | 
|---|
| 756 | swp.y  = parentHeight - y - cy; | 
|---|
| 757 | swp.cx = cx; | 
|---|
| 758 | swp.cy = cy; | 
|---|
| 759 | swp.fl = SWP_MOVE | SWP_SIZE; | 
|---|
| 760 |  | 
|---|
| 761 | dprintf(("OSLibWinSetClientPos (%d,%d) (%d,%d) -> (%d,%d) (%d,%d)", x, y, x+cx, y+cy, swp.x, swp.y, swp.x+swp.cx, swp.y+swp.cy)); | 
|---|
| 762 |  | 
|---|
| 763 | rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1); | 
|---|
| 764 | if(rc == FALSE) { | 
|---|
| 765 | dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB()))); | 
|---|
| 766 | } | 
|---|
| 767 | } | 
|---|
| 768 | //****************************************************************************** | 
|---|
| 769 | //****************************************************************************** | 
|---|
| 770 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient) | 
|---|
| 771 | { | 
|---|
| 772 | BOOL rc; | 
|---|
| 773 |  | 
|---|
| 774 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2); | 
|---|
| 775 |  | 
|---|
| 776 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient); | 
|---|
| 777 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2); | 
|---|
| 778 |  | 
|---|
| 779 | return rc; | 
|---|
| 780 | } | 
|---|
| 781 | //****************************************************************************** | 
|---|
| 782 | //****************************************************************************** | 
|---|
| 783 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax) | 
|---|
| 784 | { | 
|---|
| 785 | TRACKINFO tinfo; | 
|---|
| 786 |  | 
|---|
| 787 | memset(&tinfo, 0, sizeof(TRACKINFO)); | 
|---|
| 788 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo); | 
|---|
| 789 |  | 
|---|
| 790 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x; | 
|---|
| 791 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y; | 
|---|
| 792 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x; | 
|---|
| 793 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y; | 
|---|
| 794 | return TRUE; | 
|---|
| 795 | } | 
|---|
| 796 | //****************************************************************************** | 
|---|
| 797 | //****************************************************************************** | 
|---|
| 798 | HWND OSLibWinBeginEnumWindows(HWND hwnd) | 
|---|
| 799 | { | 
|---|
| 800 | if(hwnd == OSLIB_HWND_DESKTOP)       hwnd = HWND_DESKTOP; | 
|---|
| 801 | else | 
|---|
| 802 | if(hwnd == OSLIB_HWND_OBJECT)        hwnd = HWND_OBJECT; | 
|---|
| 803 |  | 
|---|
| 804 | return WinBeginEnumWindows(hwnd); | 
|---|
| 805 | } | 
|---|
| 806 | //****************************************************************************** | 
|---|
| 807 | //****************************************************************************** | 
|---|
| 808 | HWND OSLibWinGetNextWindow(HWND hwndEnum) | 
|---|
| 809 | { | 
|---|
| 810 | return WinGetNextWindow(hwndEnum); | 
|---|
| 811 | } | 
|---|
| 812 | //****************************************************************************** | 
|---|
| 813 | //****************************************************************************** | 
|---|
| 814 | HWND OSLibWinQueryClientWindow(HWND hwndFrame) | 
|---|
| 815 | { | 
|---|
| 816 | HWND hwndClient = 0; | 
|---|
| 817 |  | 
|---|
| 818 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME) | 
|---|
| 819 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT); | 
|---|
| 820 |  | 
|---|
| 821 | return hwndClient; | 
|---|
| 822 | } | 
|---|
| 823 | //****************************************************************************** | 
|---|
| 824 | //****************************************************************************** | 
|---|
| 825 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum) | 
|---|
| 826 | { | 
|---|
| 827 | return WinEndEnumWindows(hwndEnum); | 
|---|
| 828 | } | 
|---|
| 829 | //****************************************************************************** | 
|---|
| 830 | //****************************************************************************** | 
|---|
| 831 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid) | 
|---|
| 832 | { | 
|---|
| 833 | BOOL ret; | 
|---|
| 834 |  | 
|---|
| 835 | ret = WinQueryWindowProcess(hwnd, pid, tid); | 
|---|
| 836 | *tid = MAKE_THREADID(*pid, *tid); | 
|---|
| 837 | return ret; | 
|---|
| 838 | } | 
|---|
| 839 | //****************************************************************************** | 
|---|
| 840 | //****************************************************************************** | 
|---|
| 841 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num) | 
|---|
| 842 | { | 
|---|
| 843 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num); | 
|---|
| 844 | } | 
|---|
| 845 | //****************************************************************************** | 
|---|
| 846 | //****************************************************************************** | 
|---|
| 847 | HWND OSLibWinQueryObjectWindow(VOID) | 
|---|
| 848 | { | 
|---|
| 849 | return WinQueryObjectWindow(HWND_DESKTOP); | 
|---|
| 850 | } | 
|---|
| 851 | //****************************************************************************** | 
|---|
| 852 | //****************************************************************************** | 
|---|
| 853 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID) | 
|---|
| 854 | { | 
|---|
| 855 | HWND   hwndNext, hwndFound=0; | 
|---|
| 856 | HENUM  henum; | 
|---|
| 857 |  | 
|---|
| 858 | henum = WinBeginEnumWindows(HWND_OBJECT); | 
|---|
| 859 | while ((hwndNext = WinGetNextWindow(henum)) != 0) | 
|---|
| 860 | { | 
|---|
| 861 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner && | 
|---|
| 862 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID) | 
|---|
| 863 | { | 
|---|
| 864 | hwndFound = hwndNext; | 
|---|
| 865 | break; | 
|---|
| 866 | } | 
|---|
| 867 | } | 
|---|
| 868 | WinEndEnumWindows(henum); | 
|---|
| 869 | return hwndFound; | 
|---|
| 870 | } | 
|---|
| 871 | //****************************************************************************** | 
|---|
| 872 | //****************************************************************************** | 
|---|
| 873 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value) | 
|---|
| 874 | { | 
|---|
| 875 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value)); | 
|---|
| 876 | return WinSetWindowULong(hwnd, QWS_ID, value); | 
|---|
| 877 | } | 
|---|
| 878 | //****************************************************************************** | 
|---|
| 879 | //****************************************************************************** | 
|---|
| 880 | PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc) | 
|---|
| 881 | { | 
|---|
| 882 | return WinSubclassWindow(hwnd,(PFNWP)newWndProc); | 
|---|
| 883 | } | 
|---|
| 884 | //****************************************************************************** | 
|---|
| 885 | //****************************************************************************** | 
|---|
| 886 | BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect) | 
|---|
| 887 | { | 
|---|
| 888 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 889 |  | 
|---|
| 890 | WinSetWindowUShort(hwnd, QWS_XRESTORE,  (USHORT)pRect->left ); | 
|---|
| 891 | WinSetWindowUShort(hwnd, QWS_YRESTORE,  (USHORT)(yHeight - pRect->top - | 
|---|
| 892 | (pRect->bottom - pRect->top))); | 
|---|
| 893 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left)); | 
|---|
| 894 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top)); | 
|---|
| 895 | return TRUE; | 
|---|
| 896 | } | 
|---|
| 897 | //****************************************************************************** | 
|---|
| 898 | //****************************************************************************** | 
|---|
| 899 | BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y) | 
|---|
| 900 | { | 
|---|
| 901 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT)); | 
|---|
| 902 |  | 
|---|
| 903 | WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x ); | 
|---|
| 904 | WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y - | 
|---|
| 905 | ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) - | 
|---|
| 906 | WinQuerySysValue( HWND_DESKTOP, SV_CYICON))); | 
|---|
| 907 | return TRUE; | 
|---|
| 908 | } | 
|---|
| 909 | //****************************************************************************** | 
|---|
| 910 | //****************************************************************************** | 
|---|
| 911 | BOOL OSLibWinGetKeyboardStateTable(unsigned char *PMKeyState) | 
|---|
| 912 | { | 
|---|
| 913 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, FALSE ); | 
|---|
| 914 | } | 
|---|
| 915 | //****************************************************************************** | 
|---|
| 916 | //****************************************************************************** | 
|---|
| 917 | BOOL OSLibWinSetKeyboardStateTable(unsigned char *PMKeyState) | 
|---|
| 918 | { | 
|---|
| 919 | return WinSetKeyboardStateTable(HWND_DESKTOP, (PBYTE)PMKeyState, TRUE ); | 
|---|
| 920 | } | 
|---|
| 921 | //****************************************************************************** | 
|---|
| 922 | //****************************************************************************** | 
|---|
| 923 | USHORT APIENTRY WinTranslateChar2( USHORT  /* Codepage (currently ignored) */ | 
|---|
| 924 | , PUSHORT /* Ptr to char to translate     */ | 
|---|
| 925 | , PULONG  /* Ptr to deadkey save info     */ | 
|---|
| 926 | , USHORT  /* Translation option (TC_xxx)  */ | 
|---|
| 927 | , PUSHORT /* Ptr to shift state (TCF_xxx) */ | 
|---|
| 928 | ); | 
|---|
| 929 | //****************************************************************************** | 
|---|
| 930 | //****************************************************************************** | 
|---|
| 931 | USHORT OSLibWinTranslateChar(USHORT usScanCode, ULONG type, USHORT shiftstate) | 
|---|
| 932 | { | 
|---|
| 933 | USHORT usResult; | 
|---|
| 934 | USHORT sel = GetFS(); | 
|---|
| 935 |  | 
|---|
| 936 | usResult = WinTranslateChar2(0, &usScanCode, NULL, type, &shiftstate); | 
|---|
| 937 | SetFS(sel); | 
|---|
| 938 | return usScanCode; | 
|---|
| 939 | } | 
|---|
| 940 | //****************************************************************************** | 
|---|
| 941 | //****************************************************************************** | 
|---|
| 942 | BOOL OSLibWinEnableWindowUpdate(HWND hwndFrame, HWND hwndClient ,BOOL fEnable) | 
|---|
| 943 | { | 
|---|
| 944 | WinEnableWindowUpdate(hwndFrame, fEnable); | 
|---|
| 945 | return WinEnableWindowUpdate(hwndClient, fEnable); | 
|---|
| 946 | } | 
|---|
| 947 | //****************************************************************************** | 
|---|
| 948 | //****************************************************************************** | 
|---|
| 949 | ULONG OSLibWinGetLastError() | 
|---|
| 950 | { | 
|---|
| 951 | return WinGetLastError(GetThreadHAB()) & 0xFFFF; | 
|---|
| 952 | } | 
|---|
| 953 | //****************************************************************************** | 
|---|
| 954 | //****************************************************************************** | 
|---|
| 955 | void OSLibWinShowTaskList(HWND hwndFrame) | 
|---|
| 956 | { | 
|---|
| 957 | SWBLOCK swblk; | 
|---|
| 958 | // the first entry returned is always the window list itself | 
|---|
| 959 | if (WinQuerySwitchList(0, &swblk, sizeof(SWBLOCK)) > 0) | 
|---|
| 960 | WinSetActiveWindow(HWND_DESKTOP, swblk.aswentry[0].swctl.hwnd); | 
|---|
| 961 | } | 
|---|
| 962 | //****************************************************************************** | 
|---|
| 963 | //****************************************************************************** | 
|---|
| 964 | void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle) | 
|---|
| 965 | { | 
|---|
| 966 | ULONG dwWinStyle; | 
|---|
| 967 | ULONG dwOldWinStyle; | 
|---|
| 968 |  | 
|---|
| 969 | //client window: | 
|---|
| 970 | dwWinStyle    = WinQueryWindowULong(hwndClient, QWL_STYLE); | 
|---|
| 971 | dwOldWinStyle = dwWinStyle; | 
|---|
| 972 |  | 
|---|
| 973 | if(dwStyle & WS_CLIPCHILDREN_W) { | 
|---|
| 974 | dwWinStyle |= WS_CLIPCHILDREN; | 
|---|
| 975 | } | 
|---|
| 976 | else dwWinStyle &= ~WS_CLIPCHILDREN; | 
|---|
| 977 |  | 
|---|
| 978 | if(dwWinStyle != dwOldWinStyle) { | 
|---|
| 979 | WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle); | 
|---|
| 980 | } | 
|---|
| 981 |  | 
|---|
| 982 | //Frame window | 
|---|
| 983 | dwWinStyle    = WinQueryWindowULong(hwndFrame, QWL_STYLE); | 
|---|
| 984 | dwOldWinStyle = dwWinStyle; | 
|---|
| 985 | if(dwStyle & WS_DISABLED_W) { | 
|---|
| 986 | dwWinStyle |= WS_DISABLED; | 
|---|
| 987 | } | 
|---|
| 988 | else dwWinStyle &= ~WS_DISABLED; | 
|---|
| 989 |  | 
|---|
| 990 | if(dwStyle & WS_CLIPSIBLINGS_W) { | 
|---|
| 991 | dwWinStyle |= WS_CLIPSIBLINGS; | 
|---|
| 992 | } | 
|---|
| 993 | else dwWinStyle &= ~WS_CLIPSIBLINGS; | 
|---|
| 994 |  | 
|---|
| 995 | if(dwStyle & WS_MINIMIZE_W) { | 
|---|
| 996 | dwWinStyle |= WS_MINIMIZED; | 
|---|
| 997 | } | 
|---|
| 998 | else dwWinStyle &= ~WS_MINIMIZED; | 
|---|
| 999 |  | 
|---|
| 1000 | if(dwStyle & WS_MAXIMIZE_W) { | 
|---|
| 1001 | dwWinStyle |= WS_MAXIMIZED; | 
|---|
| 1002 | } | 
|---|
| 1003 | else dwWinStyle &= ~WS_MAXIMIZED; | 
|---|
| 1004 |  | 
|---|
| 1005 | if(dwWinStyle != dwOldWinStyle) { | 
|---|
| 1006 | WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle); | 
|---|
| 1007 | } | 
|---|
| 1008 | if(fOS2Look) { | 
|---|
| 1009 | ULONG OSFrameStyle = 0; | 
|---|
| 1010 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) { | 
|---|
| 1011 | if(WinWindowFromID(hwndFrame, FID_TITLEBAR) == 0) { | 
|---|
| 1012 | OSFrameStyle = FCF_TITLEBAR; | 
|---|
| 1013 | } | 
|---|
| 1014 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W)) | 
|---|
| 1015 | { | 
|---|
| 1016 | if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0) { | 
|---|
| 1017 | OSFrameStyle |= FCF_SYSMENU; | 
|---|
| 1018 | } | 
|---|
| 1019 | } | 
|---|
| 1020 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W)) { | 
|---|
| 1021 | if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) { | 
|---|
| 1022 | OSFrameStyle |= FCF_MINMAX; | 
|---|
| 1023 | } | 
|---|
| 1024 | } | 
|---|
| 1025 | else | 
|---|
| 1026 | if(dwStyle & WS_SYSMENU_W) { | 
|---|
| 1027 | if(WinWindowFromID(hwndFrame, FID_MINMAX) == 0) { | 
|---|
| 1028 | OSFrameStyle |= FCF_CLOSEBUTTON; | 
|---|
| 1029 | } | 
|---|
| 1030 | } | 
|---|
| 1031 | } | 
|---|
| 1032 | if(OSFrameStyle) { | 
|---|
| 1033 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0}; | 
|---|
| 1034 |  | 
|---|
| 1035 | FCData.flCreateFlags = OSFrameStyle; | 
|---|
| 1036 | WinCreateFrameControls(hwndFrame, &FCData, NULL); | 
|---|
| 1037 | } | 
|---|
| 1038 | } | 
|---|
| 1039 | } | 
|---|
| 1040 | //****************************************************************************** | 
|---|
| 1041 | //****************************************************************************** | 
|---|
| 1042 | DWORD OSLibQueryWindowStyle(HWND hwnd) | 
|---|
| 1043 | { | 
|---|
| 1044 | return WinQueryWindowULong(hwnd, QWL_STYLE); | 
|---|
| 1045 | } | 
|---|
| 1046 | //****************************************************************************** | 
|---|
| 1047 | //****************************************************************************** | 
|---|
| 1048 | void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify) | 
|---|
| 1049 | { | 
|---|
| 1050 | WinSetVisibleRegionNotify(hwnd, fNotify); | 
|---|
| 1051 | } | 
|---|
| 1052 | //****************************************************************************** | 
|---|
| 1053 | //****************************************************************************** | 
|---|
| 1054 | HWND OSLibWinQueryCapture() | 
|---|
| 1055 | { | 
|---|
| 1056 | return WinQueryCapture(HWND_DESKTOP); | 
|---|
| 1057 | } | 
|---|
| 1058 | //****************************************************************************** | 
|---|
| 1059 | //****************************************************************************** | 
|---|
| 1060 | BOOL OSLibWinSetCapture(HWND hwnd) | 
|---|
| 1061 | { | 
|---|
| 1062 | return WinSetCapture(HWND_DESKTOP, hwnd); | 
|---|
| 1063 | } | 
|---|
| 1064 | //****************************************************************************** | 
|---|
| 1065 | //****************************************************************************** | 
|---|
| 1066 | BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList) | 
|---|
| 1067 | { | 
|---|
| 1068 | return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE; | 
|---|
| 1069 | } | 
|---|
| 1070 | //****************************************************************************** | 
|---|
| 1071 | //****************************************************************************** | 
|---|
| 1072 | HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible) | 
|---|
| 1073 | { | 
|---|
| 1074 | SWCNTRL swctrl; | 
|---|
| 1075 | ULONG   tid; | 
|---|
| 1076 |  | 
|---|
| 1077 | swctrl.hwnd          = hwndFrame; | 
|---|
| 1078 | swctrl.hwndIcon      = 0; | 
|---|
| 1079 | swctrl.hprog         = 0; | 
|---|
| 1080 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid); | 
|---|
| 1081 | swctrl.idSession     = 0; | 
|---|
| 1082 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE; | 
|---|
| 1083 | swctrl.fbJump        = SWL_JUMPABLE; | 
|---|
| 1084 | swctrl.bProgType     = PROG_PM; | 
|---|
| 1085 | if(title) { | 
|---|
| 1086 | //        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4); | 
|---|
| 1087 | CharToOemBuffA( title, swctrl.szSwtitle, MAXNAMEL+4 ); | 
|---|
| 1088 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0; | 
|---|
| 1089 | } | 
|---|
| 1090 | else { | 
|---|
| 1091 | swctrl.szSwtitle[0] = 0; | 
|---|
| 1092 | swctrl.uchVisibility    = SWL_INVISIBLE; | 
|---|
| 1093 | } | 
|---|
| 1094 | return WinAddSwitchEntry(&swctrl); | 
|---|
| 1095 | } | 
|---|
| 1096 | //****************************************************************************** | 
|---|
| 1097 | //****************************************************************************** | 
|---|
| 1098 | BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible) | 
|---|
| 1099 | { | 
|---|
| 1100 | SWCNTRL swctrl; | 
|---|
| 1101 | ULONG   tid; | 
|---|
| 1102 |  | 
|---|
| 1103 | swctrl.hwnd          = hwndFrame; | 
|---|
| 1104 | swctrl.hwndIcon      = 0; | 
|---|
| 1105 | swctrl.hprog         = 0; | 
|---|
| 1106 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid); | 
|---|
| 1107 | swctrl.idSession     = 0; | 
|---|
| 1108 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE; | 
|---|
| 1109 | swctrl.fbJump        = SWL_JUMPABLE; | 
|---|
| 1110 | swctrl.bProgType     = PROG_PM; | 
|---|
| 1111 | if(title) { | 
|---|
| 1112 | //        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4); | 
|---|
| 1113 | CharToOemBuffA( title, swctrl.szSwtitle, MAXNAMEL+4 ); | 
|---|
| 1114 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0; | 
|---|
| 1115 | } | 
|---|
| 1116 | else { | 
|---|
| 1117 | swctrl.szSwtitle[0] = 0; | 
|---|
| 1118 | swctrl.uchVisibility    = SWL_INVISIBLE; | 
|---|
| 1119 | } | 
|---|
| 1120 | return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE; | 
|---|
| 1121 | } | 
|---|
| 1122 | //****************************************************************************** | 
|---|
| 1123 | //****************************************************************************** | 
|---|
| 1124 | BOOL OSLibWinLockWindowUpdate(HWND hwnd) | 
|---|
| 1125 | { | 
|---|
| 1126 | return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd); | 
|---|
| 1127 | } | 
|---|
| 1128 | //****************************************************************************** | 
|---|
| 1129 | //****************************************************************************** | 
|---|
| 1130 | ULONG OSLibGetScreenHeight() | 
|---|
| 1131 | { | 
|---|
| 1132 | return ScreenHeight; | 
|---|
| 1133 | } | 
|---|
| 1134 | //****************************************************************************** | 
|---|
| 1135 | //****************************************************************************** | 
|---|
| 1136 | ULONG OSLibGetScreenWidth() | 
|---|
| 1137 | { | 
|---|
| 1138 | return ScreenWidth; | 
|---|
| 1139 | } | 
|---|
| 1140 | //****************************************************************************** | 
|---|
| 1141 | //Returns the maximum position for a window | 
|---|
| 1142 | //Should only be used from toplevel windows | 
|---|
| 1143 | //****************************************************************************** | 
|---|
| 1144 | BOOL OSLibWinGetMaxPosition(HWND hwndOS2, RECT *rect) | 
|---|
| 1145 | { | 
|---|
| 1146 | SWP  swp; | 
|---|
| 1147 |  | 
|---|
| 1148 | if(!WinGetMaxPosition(hwndOS2, &swp)) { | 
|---|
| 1149 | dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2)); | 
|---|
| 1150 | return FALSE; | 
|---|
| 1151 | } | 
|---|
| 1152 | rect->left   = swp.x; | 
|---|
| 1153 | rect->right  = swp.x + swp.cx; | 
|---|
| 1154 | rect->top    = ScreenHeight - (swp.y + swp.cy); | 
|---|
| 1155 | rect->bottom = ScreenHeight - swp.y; | 
|---|
| 1156 | return TRUE; | 
|---|
| 1157 | } | 
|---|
| 1158 | //****************************************************************************** | 
|---|
| 1159 | //****************************************************************************** | 
|---|
| 1160 | BOOL OSLibWinShowPointer(BOOL fShow) | 
|---|
| 1161 | { | 
|---|
| 1162 | return WinShowPointer(HWND_DESKTOP, fShow); | 
|---|
| 1163 | } | 
|---|
| 1164 | //****************************************************************************** | 
|---|
| 1165 | //****************************************************************************** | 
|---|
| 1166 | ULONG  OSLibWinQuerySysColor(int index) | 
|---|
| 1167 | { | 
|---|
| 1168 | return CONVERT_RGB(WinQuerySysColor(HWND_DESKTOP, index, 0)); | 
|---|
| 1169 | } | 
|---|
| 1170 | //****************************************************************************** | 
|---|
| 1171 | //****************************************************************************** | 
|---|