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