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