| 1 | /* $Id: oslibwin.cpp,v 1.3 1999-09-21 17:04:26 dengert 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 | #include <os2.h>
|
|---|
| 16 | #include <os2wrap.h>
|
|---|
| 17 | #include <stdlib.h>
|
|---|
| 18 | #include <string.h>
|
|---|
| 19 |
|
|---|
| 20 | #include <misc.h>
|
|---|
| 21 | #include "win32type.h"
|
|---|
| 22 | #include <winconst.h>
|
|---|
| 23 | #include "oslibwin.h"
|
|---|
| 24 | #include "oslibutil.h"
|
|---|
| 25 | #include "oslibmsg.h"
|
|---|
| 26 | #include "oslibgdi.h"
|
|---|
| 27 | #include "pmwindow.h"
|
|---|
| 28 |
|
|---|
| 29 | //******************************************************************************
|
|---|
| 30 | //******************************************************************************
|
|---|
| 31 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
|---|
| 32 | {
|
|---|
| 33 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
|---|
| 34 | {
|
|---|
| 35 | hwndParent = HWND_DESKTOP;
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
|---|
| 39 | }
|
|---|
| 40 | //******************************************************************************
|
|---|
| 41 | //******************************************************************************
|
|---|
| 42 | HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
|
|---|
| 43 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame)
|
|---|
| 44 | {
|
|---|
| 45 | HWND hwndClient;
|
|---|
| 46 |
|
|---|
| 47 | dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, pszName));
|
|---|
| 48 |
|
|---|
| 49 | if(pszName && *pszName == 0) {
|
|---|
| 50 | pszName = NULL;
|
|---|
| 51 | }
|
|---|
| 52 | if(hwndParent == OSLIB_HWND_DESKTOP) {
|
|---|
| 53 | hwndParent = HWND_DESKTOP;
|
|---|
| 54 | }
|
|---|
| 55 | if(Owner == OSLIB_HWND_DESKTOP) {
|
|---|
| 56 | Owner = HWND_DESKTOP;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | if(dwFrameStyle) {
|
|---|
| 60 | ULONG dwClientStyle;
|
|---|
| 61 |
|
|---|
| 62 | dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
|
|---|
| 63 | if(pszName)
|
|---|
| 64 | dwFrameStyle |= FCF_TITLEBAR;
|
|---|
| 65 |
|
|---|
| 66 | dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER | FCF_NOBYTEALIGN;
|
|---|
| 67 | *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
|
|---|
| 68 | &dwFrameStyle, WIN32_STDCLASS,
|
|---|
| 69 | "", dwClientStyle, 0, 0, &hwndClient);
|
|---|
| 70 | if(*hwndFrame) {
|
|---|
| 71 | if(pszName) {
|
|---|
| 72 | WinSetWindowText(*hwndFrame, pszName);
|
|---|
| 73 | }
|
|---|
| 74 | return hwndClient;
|
|---|
| 75 | }
|
|---|
| 76 | dprintf(("OSLibWinCreateWindow: WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
|
|---|
| 77 | return 0;
|
|---|
| 78 | }
|
|---|
| 79 | hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
|
|---|
| 80 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
|
|---|
| 81 | NULL);
|
|---|
| 82 | *hwndFrame = hwndClient;
|
|---|
| 83 | return hwndClient;
|
|---|
| 84 | }
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | //******************************************************************************
|
|---|
| 87 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle)
|
|---|
| 88 | {
|
|---|
| 89 | *OSWinStyle = 0;
|
|---|
| 90 | *OSFrameStyle = 0;
|
|---|
| 91 |
|
|---|
| 92 | /* Window styles */
|
|---|
| 93 | if(dwStyle & WS_MINIMIZE_W)
|
|---|
| 94 | *OSWinStyle |= WS_MINIMIZED;
|
|---|
| 95 | //Done explicitely in CreateWindowExA
|
|---|
| 96 | #if 0
|
|---|
| 97 | if(dwStyle & WS_VISIBLE_W)
|
|---|
| 98 | *OSWinStyle |= WS_VISIBLE;
|
|---|
| 99 | #endif
|
|---|
| 100 | if(dwStyle & WS_DISABLED_W)
|
|---|
| 101 | *OSWinStyle |= WS_DISABLED;
|
|---|
| 102 | if(dwStyle & WS_CLIPSIBLINGS_W)
|
|---|
| 103 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
|---|
| 104 | if(dwStyle & WS_CLIPCHILDREN_W)
|
|---|
| 105 | *OSWinStyle |= WS_CLIPCHILDREN;
|
|---|
| 106 | if(dwStyle & WS_MAXIMIZE_W)
|
|---|
| 107 | *OSWinStyle |= WS_MAXIMIZED;
|
|---|
| 108 | if(dwStyle & WS_GROUP_W)
|
|---|
| 109 | *OSWinStyle |= WS_GROUP;
|
|---|
| 110 | if(dwStyle & WS_TABSTOP_W)
|
|---|
| 111 | *OSWinStyle |= WS_TABSTOP;
|
|---|
| 112 |
|
|---|
| 113 | if(dwStyle & WS_CAPTION_W)
|
|---|
| 114 | *OSFrameStyle |= FCF_TITLEBAR;
|
|---|
| 115 | if(dwStyle & WS_DLGFRAME_W)
|
|---|
| 116 | *OSFrameStyle |= FCF_DLGBORDER;
|
|---|
| 117 | else
|
|---|
| 118 | if(dwStyle & WS_BORDER_W)
|
|---|
| 119 | *OSFrameStyle |= FCF_BORDER;
|
|---|
| 120 |
|
|---|
| 121 | if(dwStyle & WS_VSCROLL_W)
|
|---|
| 122 | *OSFrameStyle |= FCF_VERTSCROLL;
|
|---|
| 123 | if(dwStyle & WS_HSCROLL_W)
|
|---|
| 124 | *OSFrameStyle |= FCF_HORZSCROLL;
|
|---|
| 125 | if(dwStyle & WS_SYSMENU_W)
|
|---|
| 126 | *OSFrameStyle |= FCF_SYSMENU;
|
|---|
| 127 | if(dwStyle & WS_THICKFRAME_W)
|
|---|
| 128 | *OSFrameStyle |= FCF_SIZEBORDER; //??
|
|---|
| 129 | if(dwStyle & WS_MINIMIZEBOX_W)
|
|---|
| 130 | *OSFrameStyle |= FCF_MINBUTTON;
|
|---|
| 131 | if(dwStyle & WS_MAXIMIZEBOX_W)
|
|---|
| 132 | *OSFrameStyle |= FCF_MAXBUTTON;
|
|---|
| 133 |
|
|---|
| 134 | if(dwExStyle & WS_EX_DLGMODALFRAME_W)
|
|---|
| 135 | *OSFrameStyle |= FCF_DLGBORDER;
|
|---|
| 136 |
|
|---|
| 137 | return TRUE;
|
|---|
| 138 | }
|
|---|
| 139 | //******************************************************************************
|
|---|
| 140 | //******************************************************************************
|
|---|
| 141 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
|---|
| 142 | {
|
|---|
| 143 | return WinSetWindowULong(hwnd, offset, value);
|
|---|
| 144 | }
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
|---|
| 148 | {
|
|---|
| 149 | return WinQueryWindowULong(hwnd, offset);
|
|---|
| 150 | }
|
|---|
| 151 | //******************************************************************************
|
|---|
| 152 | //******************************************************************************
|
|---|
| 153 | BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
|
|---|
| 154 | {
|
|---|
| 155 | return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
|
|---|
| 156 | }
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
|
|---|
| 160 | {
|
|---|
| 161 | return (ULONG)WinSendMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
|
|---|
| 162 | }
|
|---|
| 163 | //******************************************************************************
|
|---|
| 164 | //******************************************************************************
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | //******************************************************************************
|
|---|
| 167 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
|
|---|
| 168 | {
|
|---|
| 169 | return WinAlarm(hwndDeskTop,flStyle);
|
|---|
| 170 | }
|
|---|
| 171 | //******************************************************************************
|
|---|
| 172 | //******************************************************************************
|
|---|
| 173 | APIRET OSLibDosBeep(ULONG freg,ULONG dur)
|
|---|
| 174 | {
|
|---|
| 175 | return DosBeep(freg,dur);
|
|---|
| 176 | }
|
|---|
| 177 | //******************************************************************************
|
|---|
| 178 | //******************************************************************************
|
|---|
| 179 | HWND OSLibWinQueryFocus(HWND hwndDeskTop)
|
|---|
| 180 | {
|
|---|
| 181 | return WinQueryFocus(hwndDeskTop);
|
|---|
| 182 | }
|
|---|
| 183 | //******************************************************************************
|
|---|
| 184 | //******************************************************************************
|
|---|
| 185 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
|
|---|
| 186 | {
|
|---|
| 187 | return WinWindowFromID(hwndParent,id);
|
|---|
| 188 | }
|
|---|
| 189 | //******************************************************************************
|
|---|
| 190 | //******************************************************************************
|
|---|
| 191 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
|
|---|
| 192 | {
|
|---|
| 193 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
|
|---|
| 194 | }
|
|---|
| 195 | //******************************************************************************
|
|---|
| 196 | //******************************************************************************
|
|---|
| 197 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
|
|---|
| 198 | {
|
|---|
| 199 | return WinIsChild (hwnd, hwndOf);
|
|---|
| 200 | }
|
|---|
| 201 | //******************************************************************************
|
|---|
| 202 | //******************************************************************************
|
|---|
| 203 | ULONG OSLibGetWindowHeight(HWND hwnd)
|
|---|
| 204 | {
|
|---|
| 205 | RECTL rect;
|
|---|
| 206 |
|
|---|
| 207 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
|
|---|
| 208 | }
|
|---|
| 209 | //******************************************************************************
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
|
|---|
| 212 | {
|
|---|
| 213 | return WinQuerySysValue(hwndDeskTop,iSysValue);
|
|---|
| 214 | }
|
|---|
| 215 | //******************************************************************************
|
|---|
| 216 | //******************************************************************************
|
|---|
| 217 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
|
|---|
| 218 | {
|
|---|
| 219 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
|
|---|
| 220 | }
|
|---|
| 221 | //******************************************************************************
|
|---|
| 222 | //******************************************************************************
|
|---|
| 223 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
|
|---|
| 224 | {
|
|---|
| 225 | return WinSetDlgItemText(hwndDlg,idItem,pszText);
|
|---|
| 226 | }
|
|---|
| 227 | //******************************************************************************
|
|---|
| 228 | //******************************************************************************
|
|---|
| 229 | BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
|
|---|
| 230 | {
|
|---|
| 231 | return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
|
|---|
| 232 | }
|
|---|
| 233 | //******************************************************************************
|
|---|
| 234 | //******************************************************************************
|
|---|
| 235 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
|
|---|
| 236 | {
|
|---|
| 237 | return WinQueryWindow(hwnd, lCode);
|
|---|
| 238 | }
|
|---|
| 239 | //******************************************************************************
|
|---|
| 240 | //******************************************************************************
|
|---|
| 241 | BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
|
|---|
| 242 | LONG cy, ULONG fl)
|
|---|
| 243 | {
|
|---|
| 244 | HWND hwndParent = hwndInsertBehind;
|
|---|
| 245 | BOOL rc;
|
|---|
| 246 |
|
|---|
| 247 | if(fl & SWP_MOVE) {
|
|---|
| 248 | switch(hwndParent)
|
|---|
| 249 | {
|
|---|
| 250 | case HWNDOS_TOP:
|
|---|
| 251 | case HWNDOS_BOTTOM:
|
|---|
| 252 | hwndParent = HWND_DESKTOP;
|
|---|
| 253 | break;
|
|---|
| 254 | }
|
|---|
| 255 | y = MapOS2ToWin32Y(hwndParent, cy, y);
|
|---|
| 256 | }
|
|---|
| 257 | rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
|
|---|
| 258 | dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
|
|---|
| 259 | return rc;
|
|---|
| 260 | }
|
|---|
| 261 | //******************************************************************************
|
|---|
| 262 | //******************************************************************************
|
|---|
| 263 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
|
|---|
| 264 | {
|
|---|
| 265 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
|
|---|
| 266 | }
|
|---|
| 267 | //******************************************************************************
|
|---|
| 268 | //******************************************************************************
|
|---|
| 269 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
|---|
| 270 | {
|
|---|
| 271 | BOOL rc;
|
|---|
| 272 |
|
|---|
| 273 | if(fl & SWP_SHOW) {
|
|---|
| 274 | rc = WinShowWindow(hwnd, TRUE);
|
|---|
| 275 | }
|
|---|
| 276 | if(rc == 0)
|
|---|
| 277 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
|---|
| 278 | rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
|
|---|
| 279 | if(rc == 0)
|
|---|
| 280 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
|---|
| 281 | return rc;
|
|---|
| 282 | }
|
|---|
| 283 | //******************************************************************************
|
|---|
| 284 | //******************************************************************************
|
|---|
| 285 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
|---|
| 286 | {
|
|---|
| 287 | return WinDestroyWindow(hwnd);
|
|---|
| 288 | }
|
|---|
| 289 | //******************************************************************************
|
|---|
| 290 | //******************************************************************************
|
|---|
| 291 | BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
|
|---|
| 292 | {
|
|---|
| 293 | BOOL rc;
|
|---|
| 294 | RECTLOS2 rectl;
|
|---|
| 295 |
|
|---|
| 296 | rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
|
|---|
| 297 | if(rc) {
|
|---|
| 298 | if(RelativeTo == RELATIVE_TO_SCREEN) {
|
|---|
| 299 | MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
|
|---|
| 300 | }
|
|---|
| 301 | else MapOS2ToWin32Rectl(&rectl, pRect);
|
|---|
| 302 | }
|
|---|
| 303 | else memset(pRect, 0, sizeof(RECT));
|
|---|
| 304 | return rc;
|
|---|
| 305 | }
|
|---|
| 306 | //******************************************************************************
|
|---|
| 307 | //******************************************************************************
|
|---|
| 308 | BOOL OSLibWinIsIconic(HWND hwnd)
|
|---|
| 309 | {
|
|---|
| 310 | SWP swp;
|
|---|
| 311 | BOOL rc;
|
|---|
| 312 |
|
|---|
| 313 | rc = WinQueryWindowPos(hwnd, &swp);
|
|---|
| 314 | if(rc == FALSE) {
|
|---|
| 315 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
|---|
| 316 | return FALSE;
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | if(swp.fl & SWP_MINIMIZE)
|
|---|
| 320 | return TRUE;
|
|---|
| 321 | else return FALSE;
|
|---|
| 322 | }
|
|---|
| 323 | //******************************************************************************
|
|---|
| 324 | //******************************************************************************
|
|---|
| 325 | BOOL OSLibWinSetActiveWindow(HWND hwnd)
|
|---|
| 326 | {
|
|---|
| 327 | return WinSetActiveWindow(HWND_DESKTOP, hwnd);
|
|---|
| 328 | }
|
|---|
| 329 | //******************************************************************************
|
|---|
| 330 | //******************************************************************************
|
|---|
| 331 | BOOL OSLibWinSetFocus(HWND hwnd)
|
|---|
| 332 | {
|
|---|
| 333 | return WinSetFocus(HWND_DESKTOP, hwnd);
|
|---|
| 334 | }
|
|---|
| 335 | //******************************************************************************
|
|---|
| 336 | //******************************************************************************
|
|---|
| 337 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
|
|---|
| 338 | {
|
|---|
| 339 | return WinEnableWindow(hwnd, fEnable);
|
|---|
| 340 | }
|
|---|
| 341 | //******************************************************************************
|
|---|
| 342 | //******************************************************************************
|
|---|
| 343 | BOOL OSLibWinIsWindowEnabled(HWND hwnd)
|
|---|
| 344 | {
|
|---|
| 345 | return WinIsWindowEnabled(hwnd);
|
|---|
| 346 | }
|
|---|
| 347 | //******************************************************************************
|
|---|
| 348 | //******************************************************************************
|
|---|
| 349 | BOOL OSLibWinIsWindowVisible(HWND hwnd)
|
|---|
| 350 | {
|
|---|
| 351 | return WinIsWindowVisible(hwnd);
|
|---|
| 352 | }
|
|---|
| 353 | //******************************************************************************
|
|---|
| 354 | //******************************************************************************
|
|---|
| 355 | BOOL OSLibWinQueryActiveWindow()
|
|---|
| 356 | {
|
|---|
| 357 | return WinQueryActiveWindow(HWND_DESKTOP);
|
|---|
| 358 | }
|
|---|
| 359 | //******************************************************************************
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | LONG OSLibWinQueryWindowTextLength(HWND hwnd)
|
|---|
| 362 | {
|
|---|
| 363 | return WinQueryWindowTextLength(hwnd);
|
|---|
| 364 | }
|
|---|
| 365 | //******************************************************************************
|
|---|
| 366 | //******************************************************************************
|
|---|
| 367 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
|
|---|
| 368 | {
|
|---|
| 369 | return WinQueryWindowText(hwnd, length, lpsz);
|
|---|
| 370 | }
|
|---|
| 371 | //******************************************************************************
|
|---|
| 372 | //******************************************************************************
|
|---|
| 373 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
|
|---|
| 374 | {
|
|---|
| 375 | return WinSetWindowText(hwnd, lpsz);
|
|---|
| 376 | }
|
|---|
| 377 | //******************************************************************************
|
|---|
| 378 | //******************************************************************************
|
|---|
| 379 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
|
|---|
| 380 | {
|
|---|
| 381 | return WinFlashWindow(hwnd, fFlash);
|
|---|
| 382 | }
|
|---|
| 383 | //******************************************************************************
|
|---|
| 384 | //******************************************************************************
|
|---|
| 385 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
|
|---|
| 386 | {
|
|---|
| 387 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
|
|---|
| 388 | }
|
|---|
| 389 | //******************************************************************************
|
|---|
| 390 | //******************************************************************************
|
|---|
| 391 | BOOL OSLibWinMinimizeWindow(HWND hwnd)
|
|---|
| 392 | {
|
|---|
| 393 | return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
|
|---|
| 394 | }
|
|---|
| 395 | //******************************************************************************
|
|---|
| 396 | //******************************************************************************
|
|---|
| 397 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
|
|---|
| 398 | {
|
|---|
| 399 | pointl->x = 0;
|
|---|
| 400 | pointl->y = 0;
|
|---|
| 401 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
|
|---|
| 402 | }
|
|---|
| 403 | //******************************************************************************
|
|---|
| 404 | //******************************************************************************
|
|---|
| 405 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
|
|---|
| 406 | {
|
|---|
| 407 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
|
|---|
| 408 | }
|
|---|
| 409 | //******************************************************************************
|
|---|
| 410 | //******************************************************************************
|
|---|
| 411 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
|
|---|
| 412 | {
|
|---|
| 413 | return WinQueryWindowPos(hwnd, pswp);
|
|---|
| 414 | }
|
|---|
| 415 | //******************************************************************************
|
|---|
| 416 | //******************************************************************************
|
|---|
| 417 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
|
|---|
| 418 | {
|
|---|
| 419 | HWND hWindow = pswp->hwnd;
|
|---|
| 420 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
|---|
| 421 | long x = pswp->x;
|
|---|
| 422 | long y = pswp->y;
|
|---|
| 423 | long cx = pswp->cx;
|
|---|
| 424 | long cy = pswp->cy;
|
|---|
| 425 | UINT fuFlags = (UINT)pswp->fl;
|
|---|
| 426 | ULONG parentHeight;
|
|---|
| 427 |
|
|---|
| 428 | HWND hWinAfter;
|
|---|
| 429 | ULONG flags = 0;
|
|---|
| 430 |
|
|---|
| 431 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
|---|
| 432 |
|
|---|
| 433 | if (hWndInsertAfter == HWND_TOP)
|
|---|
| 434 | hWinAfter = HWND_TOP_W;
|
|---|
| 435 | else if (hWndInsertAfter == HWND_BOTTOM)
|
|---|
| 436 | hWinAfter = HWND_BOTTOM_W;
|
|---|
| 437 | else
|
|---|
| 438 | hWinAfter = (HWND) hWndInsertAfter;
|
|---|
| 439 |
|
|---|
| 440 | //***********************************
|
|---|
| 441 | // convert PM flags to Windows flags
|
|---|
| 442 | //***********************************
|
|---|
| 443 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
|---|
| 444 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
|---|
| 445 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
|---|
| 446 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
|---|
| 447 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
|---|
| 448 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
|---|
| 449 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
|---|
| 450 |
|
|---|
| 451 | if (fuFlags & (SWP_MOVE | SWP_SIZE))
|
|---|
| 452 | {
|
|---|
| 453 | if (hParent == NULLHANDLE)
|
|---|
| 454 | {
|
|---|
| 455 | ULONG Offset;
|
|---|
| 456 | POINTL pt = {0, 0};
|
|---|
| 457 |
|
|---|
| 458 | Offset = OSLibGetWindowHeight(hFrame) - cy;
|
|---|
| 459 | parentHeight = ScreenHeight;
|
|---|
| 460 |
|
|---|
| 461 | cx += 2 * x;
|
|---|
| 462 | cy += Offset;
|
|---|
| 463 | WinMapWindowPoints (hFrame, HWND_DESKTOP, &pt, 1);
|
|---|
| 464 | x = pt.x;
|
|---|
| 465 | y = pt.y;
|
|---|
| 466 |
|
|---|
| 467 | pswpOld->cx += 2 * pswpOld->x;
|
|---|
| 468 | pswpOld->cy += Offset;
|
|---|
| 469 | pswpOld->x = pt.x;
|
|---|
| 470 | pswpOld->y = pt.y;
|
|---|
| 471 | }
|
|---|
| 472 | else
|
|---|
| 473 | {
|
|---|
| 474 | parentHeight = OSLibGetWindowHeight(hParent);
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | if (fuFlags & SWP_SIZE)
|
|---|
| 478 | {
|
|---|
| 479 | if (cy != pswpOld->cy)
|
|---|
| 480 | {
|
|---|
| 481 | flags &= ~SWP_NOMOVE_W;
|
|---|
| 482 | }
|
|---|
| 483 | }
|
|---|
| 484 | else
|
|---|
| 485 | {
|
|---|
| 486 | cx = pswpOld->cx;
|
|---|
| 487 | cy = pswpOld->cy;
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | if ((fuFlags & SWP_MOVE) == 0)
|
|---|
| 491 | {
|
|---|
| 492 | x = pswpOld->x;
|
|---|
| 493 | y = pswpOld->y;
|
|---|
| 494 | }
|
|---|
| 495 |
|
|---|
| 496 | y = parentHeight - y - cy;
|
|---|
| 497 | LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
|
|---|
| 498 |
|
|---|
| 499 | if ((pswpOld->x == x) && (oldY == y))
|
|---|
| 500 | flags |= SWP_NOMOVE_W;
|
|---|
| 501 |
|
|---|
| 502 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
|---|
| 503 | flags |= SWP_NOSIZE_W;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | if (hParent == NULLHANDLE)
|
|---|
| 507 | {
|
|---|
| 508 | pswpOld->x = x + pswp->x;
|
|---|
| 509 | pswpOld->y = y + cy - pswp->y - pswp->cy;
|
|---|
| 510 | }
|
|---|
| 511 | else {
|
|---|
| 512 | pswpOld->x = pswp->x;
|
|---|
| 513 | pswpOld->y = parentHeight - pswp->y - cy;
|
|---|
| 514 | }
|
|---|
| 515 | pswpOld->cx = pswp->cx;
|
|---|
| 516 | pswpOld->cy = pswp->cy;
|
|---|
| 517 |
|
|---|
| 518 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
|---|
| 519 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
|---|
| 520 |
|
|---|
| 521 | pwpos->flags = (UINT)flags;
|
|---|
| 522 | pwpos->cy = (int)cy;
|
|---|
| 523 | pwpos->cx = (int)cx;
|
|---|
| 524 | pwpos->x = (int)x;
|
|---|
| 525 | pwpos->y = (int)y;
|
|---|
| 526 | pwpos->hwndInsertAfter = hWinAfter;
|
|---|
| 527 | pwpos->hwnd = hWindow;
|
|---|
| 528 | }
|
|---|
| 529 | //******************************************************************************
|
|---|
| 530 | //******************************************************************************
|
|---|
| 531 | void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
|---|
| 532 | {
|
|---|
| 533 | HWND hWnd = pwpos->hwnd;
|
|---|
| 534 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
|---|
| 535 | long x = pwpos->x;
|
|---|
| 536 | long y = pwpos->y;
|
|---|
| 537 | long cx = pwpos->cx;
|
|---|
| 538 | long cy = pwpos->cy;
|
|---|
| 539 | UINT fuFlags = pwpos->flags;
|
|---|
| 540 | ULONG parentHeight;
|
|---|
| 541 |
|
|---|
| 542 | HWND hWinAfter;
|
|---|
| 543 | ULONG flags = 0;
|
|---|
| 544 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
|---|
| 545 |
|
|---|
| 546 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
|---|
| 547 | // hWinAfter = HWND_TOPMOST;
|
|---|
| 548 | hWinAfter = HWND_TOP;
|
|---|
| 549 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
|---|
| 550 | // hWinAfter = HWND_NOTOPMOST;
|
|---|
| 551 | hWinAfter = HWND_TOP;
|
|---|
| 552 | else if (hWndInsertAfter == HWND_TOP_W)
|
|---|
| 553 | hWinAfter = HWND_TOP;
|
|---|
| 554 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
|---|
| 555 | hWinAfter = HWND_BOTTOM;
|
|---|
| 556 | else
|
|---|
| 557 | hWinAfter = (HWND) hWndInsertAfter;
|
|---|
| 558 |
|
|---|
| 559 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
|---|
| 560 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
|---|
| 561 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
|---|
| 562 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
|---|
| 563 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
|---|
| 564 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
|---|
| 565 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
|---|
| 566 |
|
|---|
| 567 | if (flags & (SWP_MOVE | SWP_SIZE))
|
|---|
| 568 | {
|
|---|
| 569 | if (hParent == NULLHANDLE)
|
|---|
| 570 | parentHeight = ScreenHeight;
|
|---|
| 571 | else
|
|---|
| 572 | parentHeight = OSLibGetWindowHeight(hParent);
|
|---|
| 573 |
|
|---|
| 574 | if ((flags & SWP_MOVE) == 0)
|
|---|
| 575 | {
|
|---|
| 576 | x = pswpOld->x;
|
|---|
| 577 | y = pswpOld->y;
|
|---|
| 578 |
|
|---|
| 579 | if (!((y == 0) && (pswpOld->cy == 0)))
|
|---|
| 580 | {
|
|---|
| 581 | y = parentHeight - y - pswpOld->cy;
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | if (flags & SWP_SIZE)
|
|---|
| 586 | {
|
|---|
| 587 | if (cy != pswpOld->cy)
|
|---|
| 588 | flags |= SWP_MOVE;
|
|---|
| 589 | }
|
|---|
| 590 | else
|
|---|
| 591 | {
|
|---|
| 592 | cx = pswpOld->cx;
|
|---|
| 593 | cy = pswpOld->cy;
|
|---|
| 594 | }
|
|---|
| 595 |
|
|---|
| 596 | y = parentHeight - y - cy;
|
|---|
| 597 |
|
|---|
| 598 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
|---|
| 599 | flags &= ~SWP_MOVE;
|
|---|
| 600 |
|
|---|
| 601 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
|---|
| 602 | flags &= ~SWP_SIZE;
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | pswp->fl = flags;
|
|---|
| 606 | pswp->cy = cy;
|
|---|
| 607 | pswp->cx = cx;
|
|---|
| 608 | pswp->x = x;
|
|---|
| 609 | pswp->y = y;
|
|---|
| 610 | pswp->hwndInsertBehind = hWinAfter;
|
|---|
| 611 | pswp->hwnd = hWindow;
|
|---|
| 612 | pswp->ulReserved1 = 0;
|
|---|
| 613 | pswp->ulReserved2 = 0;
|
|---|
| 614 | }
|
|---|
| 615 | //******************************************************************************
|
|---|
| 616 | //******************************************************************************
|
|---|
| 617 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
|---|
| 618 | {
|
|---|
| 619 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
|---|
| 620 | else
|
|---|
| 621 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
|---|
| 622 |
|
|---|
| 623 | return WinBeginEnumWindows(hwnd);
|
|---|
| 624 | }
|
|---|
| 625 | //******************************************************************************
|
|---|
| 626 | //******************************************************************************
|
|---|
| 627 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
|---|
| 628 | {
|
|---|
| 629 | return WinGetNextWindow(hwndEnum);
|
|---|
| 630 | }
|
|---|
| 631 | //******************************************************************************
|
|---|
| 632 | //******************************************************************************
|
|---|
| 633 | HWND OSLibWinQueryClientWindow(HWND hwndFrame)
|
|---|
| 634 | {
|
|---|
| 635 | HWND hwndClient = 0;
|
|---|
| 636 |
|
|---|
| 637 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
|
|---|
| 638 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
|
|---|
| 639 |
|
|---|
| 640 | return hwndClient;
|
|---|
| 641 | }
|
|---|
| 642 | //******************************************************************************
|
|---|
| 643 | //******************************************************************************
|
|---|
| 644 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
|---|
| 645 | {
|
|---|
| 646 | return WinEndEnumWindows(hwndEnum);
|
|---|
| 647 | }
|
|---|
| 648 | //******************************************************************************
|
|---|
| 649 | //******************************************************************************
|
|---|
| 650 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
|---|
| 651 | {
|
|---|
| 652 | return WinQueryWindowProcess(hwnd, pid, tid);
|
|---|
| 653 | }
|
|---|
| 654 | //******************************************************************************
|
|---|
| 655 | //******************************************************************************
|
|---|