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