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