| 1 | /* $Id: oslibwin.cpp,v 1.29 1999-10-14 19:31:30 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 | #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 | #define HAS_3DFRAME(exStyle) \
|
|---|
| 30 | ((exStyle & WS_EX_CLIENTEDGE_W) || (exStyle & WS_EX_STATICEDGE_W) || (exStyle & WS_EX_WINDOWEDGE_W))
|
|---|
| 31 |
|
|---|
| 32 | //******************************************************************************
|
|---|
| 33 | //******************************************************************************
|
|---|
| 34 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
|---|
| 35 | {
|
|---|
| 36 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
|---|
| 37 | {
|
|---|
| 38 | hwndParent = HWND_DESKTOP;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
|---|
| 42 | }
|
|---|
| 43 | //******************************************************************************
|
|---|
| 44 | //******************************************************************************
|
|---|
| 45 | BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
|
|---|
| 46 | {
|
|---|
| 47 | return WinSetOwner(hwnd, hwndOwner);
|
|---|
| 48 | }
|
|---|
| 49 | //******************************************************************************
|
|---|
| 50 | //******************************************************************************
|
|---|
| 51 | HWND OSLibWinCreateWindow(HWND hwndParent, ULONG dwWinStyle, ULONG dwFrameStyle,
|
|---|
| 52 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM, HWND *hwndFrame,
|
|---|
| 53 | ULONG id)
|
|---|
| 54 | {
|
|---|
| 55 | HWND hwndClient;
|
|---|
| 56 |
|
|---|
| 57 | dprintf(("WinCreateWindow %x %x %x %s", hwndParent, dwWinStyle, dwFrameStyle, pszName));
|
|---|
| 58 |
|
|---|
| 59 | if(pszName && *pszName == 0) {
|
|---|
| 60 | pszName = NULL;
|
|---|
| 61 | }
|
|---|
| 62 | if(hwndParent == OSLIB_HWND_DESKTOP) {
|
|---|
| 63 | hwndParent = HWND_DESKTOP;
|
|---|
| 64 | }
|
|---|
| 65 | if(Owner == OSLIB_HWND_DESKTOP) {
|
|---|
| 66 | Owner = HWND_DESKTOP;
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | ULONG dwClientStyle;
|
|---|
| 70 |
|
|---|
| 71 | // if(dwFrameStyle || hwndParent == HWND_DESKTOP) {
|
|---|
| 72 | dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
|
|---|
| 73 |
|
|---|
| 74 | dwFrameStyle |= FCF_NOBYTEALIGN;
|
|---|
| 75 | if (hwndParent == HWND_DESKTOP && dwFrameStyle & FCF_TITLEBAR)
|
|---|
| 76 | dwFrameStyle |= FCF_TASKLIST | FCF_NOMOVEWITHOWNER;
|
|---|
| 77 |
|
|---|
| 78 | dwWinStyle &= ~WS_CLIPCHILDREN;
|
|---|
| 79 |
|
|---|
| 80 | *hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
|
|---|
| 81 | &dwFrameStyle, WIN32_STDCLASS,
|
|---|
| 82 | "", dwClientStyle, 0, id, &hwndClient);
|
|---|
| 83 | if(*hwndFrame) {
|
|---|
| 84 | if(pszName) {
|
|---|
| 85 | WinSetWindowText(*hwndFrame, pszName);
|
|---|
| 86 | }
|
|---|
| 87 | return hwndClient;
|
|---|
| 88 | }
|
|---|
| 89 | dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
|
|---|
| 90 | return 0;
|
|---|
| 91 | #if 0
|
|---|
| 92 | }
|
|---|
| 93 | hwndClient = WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, 0, 0, 0, 0,
|
|---|
| 94 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
|
|---|
| 95 | NULL);
|
|---|
| 96 | *hwndFrame = hwndClient;
|
|---|
| 97 | return hwndClient;
|
|---|
| 98 | #endif
|
|---|
| 99 | }
|
|---|
| 100 | //******************************************************************************
|
|---|
| 101 | //******************************************************************************
|
|---|
| 102 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG *dwExStyle, ULONG *OSWinStyle, ULONG *OSFrameStyle, ULONG *borderWidth, ULONG *borderHeight)
|
|---|
| 103 | {
|
|---|
| 104 | *OSWinStyle = 0;
|
|---|
| 105 | *OSFrameStyle = 0;
|
|---|
| 106 | *borderWidth = 0;
|
|---|
| 107 | *borderHeight = 0;
|
|---|
| 108 |
|
|---|
| 109 | /* Window styles */
|
|---|
| 110 | if(dwStyle & WS_MINIMIZE_W)
|
|---|
| 111 | *OSWinStyle |= WS_MINIMIZED;
|
|---|
| 112 | //Done explicitely in CreateWindowExA
|
|---|
| 113 | #if 1
|
|---|
| 114 | if(dwStyle & WS_VISIBLE_W)
|
|---|
| 115 | *OSWinStyle |= WS_VISIBLE;
|
|---|
| 116 | #endif
|
|---|
| 117 | if(dwStyle & WS_DISABLED_W)
|
|---|
| 118 | *OSWinStyle |= WS_DISABLED;
|
|---|
| 119 | if(dwStyle & WS_CLIPSIBLINGS_W)
|
|---|
| 120 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
|---|
| 121 | if(dwStyle & WS_CLIPCHILDREN_W)
|
|---|
| 122 | *OSWinStyle |= WS_CLIPCHILDREN;
|
|---|
| 123 | if(dwStyle & WS_MAXIMIZE_W)
|
|---|
| 124 | *OSWinStyle |= WS_MAXIMIZED;
|
|---|
| 125 | if(dwStyle & WS_GROUP_W)
|
|---|
| 126 | *OSWinStyle |= WS_GROUP;
|
|---|
| 127 | if(dwStyle & WS_TABSTOP_W)
|
|---|
| 128 | *OSWinStyle |= WS_TABSTOP;
|
|---|
| 129 |
|
|---|
| 130 | if(dwStyle & WS_CHILD_W && !((dwStyle & WS_CAPTION_W) == WS_CAPTION_W))
|
|---|
| 131 | {
|
|---|
| 132 | //SvL: Causes crash in VPBuddy if enabled -> find bug
|
|---|
| 133 | #if 0
|
|---|
| 134 | if (!HAS_3DFRAME(*dwExStyle) && (dwStyle & (WS_DLGFRAME_W | WS_THICKFRAME_W))) *dwExStyle |= WS_EX_DLGMODALFRAME_W;
|
|---|
| 135 | #endif
|
|---|
| 136 |
|
|---|
| 137 | if (*dwExStyle & WS_EX_CLIENTEDGE_W)
|
|---|
| 138 | {
|
|---|
| 139 | *OSFrameStyle |= FCF_SIZEBORDER;
|
|---|
| 140 | *borderHeight = *borderWidth = 2;
|
|---|
| 141 | } else if (*dwExStyle & WS_EX_DLGMODALFRAME_W)
|
|---|
| 142 | {
|
|---|
| 143 | *OSFrameStyle |= FCF_SIZEBORDER;
|
|---|
| 144 | *borderHeight = *borderWidth = 3;
|
|---|
| 145 | } else if (*dwExStyle & WS_EX_STATICEDGE_W)
|
|---|
| 146 | {
|
|---|
| 147 | *OSFrameStyle |= FCF_SIZEBORDER;
|
|---|
| 148 | *borderHeight = *borderWidth = 2;
|
|---|
| 149 | }
|
|---|
| 150 | else
|
|---|
| 151 | if(dwStyle & WS_BORDER_W)
|
|---|
| 152 | {
|
|---|
| 153 | *OSFrameStyle |= FCF_BORDER;
|
|---|
| 154 | *borderHeight = *borderWidth = 1;
|
|---|
| 155 | }
|
|---|
| 156 | else if (*dwExStyle & WS_EX_WINDOWEDGE_W); //no border
|
|---|
| 157 |
|
|---|
| 158 | if(dwStyle & WS_VSCROLL_W)
|
|---|
| 159 | *OSFrameStyle |= FCF_VERTSCROLL;
|
|---|
| 160 | if(dwStyle & WS_HSCROLL_W)
|
|---|
| 161 | *OSFrameStyle |= FCF_HORZSCROLL;
|
|---|
| 162 | }
|
|---|
| 163 | else
|
|---|
| 164 | {
|
|---|
| 165 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
|
|---|
| 166 | *OSFrameStyle |= FCF_TITLEBAR;
|
|---|
| 167 | if(dwStyle & WS_DLGFRAME_W)
|
|---|
| 168 | *OSFrameStyle |= FCF_DLGBORDER;
|
|---|
| 169 | else
|
|---|
| 170 | if(dwStyle & WS_BORDER_W)
|
|---|
| 171 | *OSFrameStyle |= FCF_BORDER;
|
|---|
| 172 |
|
|---|
| 173 | if(dwStyle & WS_VSCROLL_W)
|
|---|
| 174 | *OSFrameStyle |= FCF_VERTSCROLL;
|
|---|
| 175 | if(dwStyle & WS_HSCROLL_W)
|
|---|
| 176 | *OSFrameStyle |= FCF_HORZSCROLL;
|
|---|
| 177 |
|
|---|
| 178 | if(dwStyle & WS_SYSMENU_W)
|
|---|
| 179 | *OSFrameStyle |= FCF_SYSMENU;
|
|---|
| 180 | if(dwStyle & WS_THICKFRAME_W)
|
|---|
| 181 | *OSFrameStyle |= FCF_SIZEBORDER; //??
|
|---|
| 182 | if(dwStyle & WS_MINIMIZEBOX_W)
|
|---|
| 183 | *OSFrameStyle |= FCF_MINBUTTON;
|
|---|
| 184 | if(dwStyle & WS_MAXIMIZEBOX_W)
|
|---|
| 185 | *OSFrameStyle |= FCF_MAXBUTTON;
|
|---|
| 186 |
|
|---|
| 187 | if(*dwExStyle & WS_EX_DLGMODALFRAME_W)
|
|---|
| 188 | *OSFrameStyle |= FCF_DLGBORDER;
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | //Clear certain frame bits when the window doesn't have a titlebar
|
|---|
| 192 | if(!(*OSFrameStyle & FCF_TITLEBAR)) {
|
|---|
| 193 | *OSFrameStyle &= ~(FCF_MINBUTTON|FCF_MAXBUTTON|FCF_SYSMENU);
|
|---|
| 194 | }
|
|---|
| 195 | return TRUE;
|
|---|
| 196 | }
|
|---|
| 197 | //******************************************************************************
|
|---|
| 198 | //******************************************************************************
|
|---|
| 199 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
|---|
| 200 | {
|
|---|
| 201 | return WinSetWindowULong(hwnd, offset, value);
|
|---|
| 202 | }
|
|---|
| 203 | //******************************************************************************
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
|---|
| 206 | {
|
|---|
| 207 | return WinQueryWindowULong(hwnd, offset);
|
|---|
| 208 | }
|
|---|
| 209 | //******************************************************************************
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | BOOL OSLibPostMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
|
|---|
| 212 | {
|
|---|
| 213 | return WinPostMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
|
|---|
| 214 | }
|
|---|
| 215 | //******************************************************************************
|
|---|
| 216 | //******************************************************************************
|
|---|
| 217 | ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam)
|
|---|
| 218 | {
|
|---|
| 219 | return (ULONG)WinSendMsg(hwnd, msg, (MPARAM)wParam, (MPARAM)lParam);
|
|---|
| 220 | }
|
|---|
| 221 | //******************************************************************************
|
|---|
| 222 | //******************************************************************************
|
|---|
| 223 | //******************************************************************************
|
|---|
| 224 | //******************************************************************************
|
|---|
| 225 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
|
|---|
| 226 | {
|
|---|
| 227 | return WinAlarm(hwndDeskTop,flStyle);
|
|---|
| 228 | }
|
|---|
| 229 | //******************************************************************************
|
|---|
| 230 | //******************************************************************************
|
|---|
| 231 | APIRET OSLibDosBeep(ULONG freg,ULONG dur)
|
|---|
| 232 | {
|
|---|
| 233 | return DosBeep(freg,dur);
|
|---|
| 234 | }
|
|---|
| 235 | //******************************************************************************
|
|---|
| 236 | //******************************************************************************
|
|---|
| 237 | HWND OSLibWinQueryFocus(HWND hwndDeskTop)
|
|---|
| 238 | {
|
|---|
| 239 | return WinQueryFocus(hwndDeskTop);
|
|---|
| 240 | }
|
|---|
| 241 | //******************************************************************************
|
|---|
| 242 | //******************************************************************************
|
|---|
| 243 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
|
|---|
| 244 | {
|
|---|
| 245 | return WinWindowFromID(hwndParent,id);
|
|---|
| 246 | }
|
|---|
| 247 | //******************************************************************************
|
|---|
| 248 | //******************************************************************************
|
|---|
| 249 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
|
|---|
| 250 | {
|
|---|
| 251 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
|
|---|
| 252 | }
|
|---|
| 253 | //******************************************************************************
|
|---|
| 254 | //******************************************************************************
|
|---|
| 255 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
|
|---|
| 256 | {
|
|---|
| 257 | return WinIsChild (hwnd, hwndOf);
|
|---|
| 258 | }
|
|---|
| 259 | //******************************************************************************
|
|---|
| 260 | //******************************************************************************
|
|---|
| 261 | ULONG OSLibGetWindowHeight(HWND hwnd)
|
|---|
| 262 | {
|
|---|
| 263 | RECTL rect;
|
|---|
| 264 |
|
|---|
| 265 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
|
|---|
| 266 | }
|
|---|
| 267 | //******************************************************************************
|
|---|
| 268 | //******************************************************************************
|
|---|
| 269 | LONG OSLibWinQuerySysValue(HWND hwndDeskTop,LONG iSysValue)
|
|---|
| 270 | {
|
|---|
| 271 | return WinQuerySysValue(hwndDeskTop,iSysValue);
|
|---|
| 272 | }
|
|---|
| 273 | //******************************************************************************
|
|---|
| 274 | //******************************************************************************
|
|---|
| 275 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
|
|---|
| 276 | {
|
|---|
| 277 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
|
|---|
| 278 | }
|
|---|
| 279 | //******************************************************************************
|
|---|
| 280 | //******************************************************************************
|
|---|
| 281 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
|
|---|
| 282 | {
|
|---|
| 283 | return WinSetDlgItemText(hwndDlg,idItem,pszText);
|
|---|
| 284 | }
|
|---|
| 285 | //******************************************************************************
|
|---|
| 286 | //******************************************************************************
|
|---|
| 287 | BOOL OSLibWinQueryPointerPos(HWND hwndDeskTop,PPOINT pptlPoint)
|
|---|
| 288 | {
|
|---|
| 289 | return WinQueryPointerPos(hwndDeskTop,(PPOINTL)pptlPoint);
|
|---|
| 290 | }
|
|---|
| 291 | //******************************************************************************
|
|---|
| 292 | //******************************************************************************
|
|---|
| 293 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
|
|---|
| 294 | {
|
|---|
| 295 | return WinQueryWindow(hwnd, lCode);
|
|---|
| 296 | }
|
|---|
| 297 | //******************************************************************************
|
|---|
| 298 | //******************************************************************************
|
|---|
| 299 | BOOL OSLibWinSetWindowPos(HWND hwnd, HWND hwndInsertBehind, LONG x, LONG y, LONG cx,
|
|---|
| 300 | LONG cy, ULONG fl)
|
|---|
| 301 | {
|
|---|
| 302 | HWND hwndParent = hwndInsertBehind;
|
|---|
| 303 | BOOL rc;
|
|---|
| 304 |
|
|---|
| 305 | if(fl & SWP_MOVE) {
|
|---|
| 306 | switch(hwndParent)
|
|---|
| 307 | {
|
|---|
| 308 | case HWNDOS_TOP:
|
|---|
| 309 | case HWNDOS_BOTTOM:
|
|---|
| 310 | hwndParent = HWND_DESKTOP;
|
|---|
| 311 | break;
|
|---|
| 312 | }
|
|---|
| 313 | y = MapOS2ToWin32Y(hwndParent, cy, y);
|
|---|
| 314 | }
|
|---|
| 315 | rc = WinSetWindowPos(hwnd, hwndInsertBehind, x, y, cx, cy, fl);
|
|---|
| 316 | dprintf(("WinSetWindowPos %x %x %d %d %d %d %x returned %d (%x)", hwnd, hwndInsertBehind, x, y, cx, cy, fl, rc, WinGetLastError(GetThreadHAB())));
|
|---|
| 317 | return rc;
|
|---|
| 318 | }
|
|---|
| 319 | //******************************************************************************
|
|---|
| 320 | //******************************************************************************
|
|---|
| 321 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
|
|---|
| 322 | {
|
|---|
| 323 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
|
|---|
| 324 | }
|
|---|
| 325 | //******************************************************************************
|
|---|
| 326 | //******************************************************************************
|
|---|
| 327 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
|---|
| 328 | {
|
|---|
| 329 | BOOL rc = 1;
|
|---|
| 330 |
|
|---|
| 331 | if(fl & SWP_SHOW) {
|
|---|
| 332 | rc = WinShowWindow(hwnd, TRUE);
|
|---|
| 333 | }
|
|---|
| 334 | if(rc == 0)
|
|---|
| 335 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
|---|
| 336 | rc = WinSetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, fl);
|
|---|
| 337 | if(rc == 0)
|
|---|
| 338 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
|---|
| 339 | return rc;
|
|---|
| 340 | }
|
|---|
| 341 | //******************************************************************************
|
|---|
| 342 | //******************************************************************************
|
|---|
| 343 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
|---|
| 344 | {
|
|---|
| 345 | return WinDestroyWindow(hwnd);
|
|---|
| 346 | }
|
|---|
| 347 | //******************************************************************************
|
|---|
| 348 | //******************************************************************************
|
|---|
| 349 | BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
|
|---|
| 350 | {
|
|---|
| 351 | BOOL rc;
|
|---|
| 352 | RECTLOS2 rectl;
|
|---|
| 353 |
|
|---|
| 354 | rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
|
|---|
| 355 | if(rc) {
|
|---|
| 356 | if(RelativeTo == RELATIVE_TO_SCREEN) {
|
|---|
| 357 | MapOS2ToWin32Rectl(OSLIB_HWND_DESKTOP, hwnd, &rectl, pRect);
|
|---|
| 358 | }
|
|---|
| 359 | else MapOS2ToWin32Rectl(&rectl, pRect);
|
|---|
| 360 | }
|
|---|
| 361 | else memset(pRect, 0, sizeof(RECT));
|
|---|
| 362 | return rc;
|
|---|
| 363 | }
|
|---|
| 364 | //******************************************************************************
|
|---|
| 365 | //******************************************************************************
|
|---|
| 366 | BOOL OSLibWinIsIconic(HWND hwnd)
|
|---|
| 367 | {
|
|---|
| 368 | SWP swp;
|
|---|
| 369 | BOOL rc;
|
|---|
| 370 |
|
|---|
| 371 | rc = WinQueryWindowPos(hwnd, &swp);
|
|---|
| 372 | if(rc == FALSE) {
|
|---|
| 373 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
|---|
| 374 | return FALSE;
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | if(swp.fl & SWP_MINIMIZE)
|
|---|
| 378 | return TRUE;
|
|---|
| 379 | else return FALSE;
|
|---|
| 380 | }
|
|---|
| 381 | //******************************************************************************
|
|---|
| 382 | //******************************************************************************
|
|---|
| 383 | BOOL OSLibWinSetActiveWindow(HWND hwnd)
|
|---|
| 384 | {
|
|---|
| 385 | return WinSetActiveWindow(HWND_DESKTOP, hwnd);
|
|---|
| 386 | }
|
|---|
| 387 | //******************************************************************************
|
|---|
| 388 | //******************************************************************************
|
|---|
| 389 | BOOL OSLibWinSetFocus(HWND hwnd)
|
|---|
| 390 | {
|
|---|
| 391 | return WinSetFocus(HWND_DESKTOP, hwnd);
|
|---|
| 392 | }
|
|---|
| 393 | //******************************************************************************
|
|---|
| 394 | //******************************************************************************
|
|---|
| 395 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
|
|---|
| 396 | {
|
|---|
| 397 | return WinEnableWindow(hwnd, fEnable);
|
|---|
| 398 | }
|
|---|
| 399 | //******************************************************************************
|
|---|
| 400 | //******************************************************************************
|
|---|
| 401 | BOOL OSLibWinIsWindowEnabled(HWND hwnd)
|
|---|
| 402 | {
|
|---|
| 403 | return WinIsWindowEnabled(hwnd);
|
|---|
| 404 | }
|
|---|
| 405 | //******************************************************************************
|
|---|
| 406 | //******************************************************************************
|
|---|
| 407 | BOOL OSLibWinIsWindowVisible(HWND hwnd)
|
|---|
| 408 | {
|
|---|
| 409 | return WinIsWindowVisible(hwnd);
|
|---|
| 410 | }
|
|---|
| 411 | //******************************************************************************
|
|---|
| 412 | //******************************************************************************
|
|---|
| 413 | BOOL OSLibWinQueryActiveWindow()
|
|---|
| 414 | {
|
|---|
| 415 | return WinQueryActiveWindow(HWND_DESKTOP);
|
|---|
| 416 | }
|
|---|
| 417 | //******************************************************************************
|
|---|
| 418 | //******************************************************************************
|
|---|
| 419 | LONG OSLibWinQueryWindowTextLength(HWND hwnd)
|
|---|
| 420 | {
|
|---|
| 421 | return WinQueryWindowTextLength(hwnd);
|
|---|
| 422 | }
|
|---|
| 423 | //******************************************************************************
|
|---|
| 424 | //******************************************************************************
|
|---|
| 425 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
|
|---|
| 426 | {
|
|---|
| 427 | return WinQueryWindowText(hwnd, length, lpsz);
|
|---|
| 428 | }
|
|---|
| 429 | //******************************************************************************
|
|---|
| 430 | //******************************************************************************
|
|---|
| 431 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
|
|---|
| 432 | {
|
|---|
| 433 | return WinSetWindowText(hwnd, lpsz);
|
|---|
| 434 | }
|
|---|
| 435 | //******************************************************************************
|
|---|
| 436 | //******************************************************************************
|
|---|
| 437 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
|
|---|
| 438 | {
|
|---|
| 439 | return WinFlashWindow(hwnd, fFlash);
|
|---|
| 440 | }
|
|---|
| 441 | //******************************************************************************
|
|---|
| 442 | //******************************************************************************
|
|---|
| 443 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
|
|---|
| 444 | {
|
|---|
| 445 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
|
|---|
| 446 | }
|
|---|
| 447 | //******************************************************************************
|
|---|
| 448 | //******************************************************************************
|
|---|
| 449 | BOOL OSLibWinMinimizeWindow(HWND hwnd)
|
|---|
| 450 | {
|
|---|
| 451 | return WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
|
|---|
| 452 | }
|
|---|
| 453 | //******************************************************************************
|
|---|
| 454 | //******************************************************************************
|
|---|
| 455 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
|
|---|
| 456 | {
|
|---|
| 457 | pointl->x = 0;
|
|---|
| 458 | pointl->y = 0;
|
|---|
| 459 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
|
|---|
| 460 | }
|
|---|
| 461 | //******************************************************************************
|
|---|
| 462 | //******************************************************************************
|
|---|
| 463 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
|
|---|
| 464 | {
|
|---|
| 465 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIcon, 0);
|
|---|
| 466 | }
|
|---|
| 467 | //******************************************************************************
|
|---|
| 468 | //******************************************************************************
|
|---|
| 469 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
|
|---|
| 470 | {
|
|---|
| 471 | return WinQueryWindowPos(hwnd, pswp);
|
|---|
| 472 | }
|
|---|
| 473 | //******************************************************************************
|
|---|
| 474 | //******************************************************************************
|
|---|
| 475 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
|
|---|
| 476 | {
|
|---|
| 477 | HWND hWindow = pswp->hwnd;
|
|---|
| 478 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
|---|
| 479 | long x = pswp->x;
|
|---|
| 480 | long y = pswp->y;
|
|---|
| 481 | long cx = pswp->cx;
|
|---|
| 482 | long cy = pswp->cy;
|
|---|
| 483 | UINT fuFlags = (UINT)pswp->fl;
|
|---|
| 484 | ULONG parentHeight;
|
|---|
| 485 |
|
|---|
| 486 | HWND hWinAfter;
|
|---|
| 487 | ULONG flags = 0;
|
|---|
| 488 |
|
|---|
| 489 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
|---|
| 490 |
|
|---|
| 491 | if (hWndInsertAfter == HWND_TOP)
|
|---|
| 492 | hWinAfter = HWND_TOP_W;
|
|---|
| 493 | else if (hWndInsertAfter == HWND_BOTTOM)
|
|---|
| 494 | hWinAfter = HWND_BOTTOM_W;
|
|---|
| 495 | else
|
|---|
| 496 | hWinAfter = (HWND) hWndInsertAfter;
|
|---|
| 497 |
|
|---|
| 498 | //***********************************
|
|---|
| 499 | // convert PM flags to Windows flags
|
|---|
| 500 | //***********************************
|
|---|
| 501 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
|---|
| 502 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
|---|
| 503 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
|---|
| 504 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
|---|
| 505 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
|---|
| 506 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
|---|
| 507 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
|---|
| 508 |
|
|---|
| 509 | if (fuFlags & (SWP_MOVE | SWP_SIZE))
|
|---|
| 510 | {
|
|---|
| 511 | if (hParent == NULLHANDLE)
|
|---|
| 512 | {
|
|---|
| 513 | ULONG Offset;
|
|---|
| 514 | POINTL pt = {0, 0};
|
|---|
| 515 |
|
|---|
| 516 | Offset = OSLibGetWindowHeight(hFrame) - cy;
|
|---|
| 517 | parentHeight = ScreenHeight;
|
|---|
| 518 |
|
|---|
| 519 | cx += 2 * x;
|
|---|
| 520 | cy += Offset;
|
|---|
| 521 | WinMapWindowPoints (hFrame, HWND_DESKTOP, &pt, 1);
|
|---|
| 522 | x = pt.x;
|
|---|
| 523 | y = pt.y;
|
|---|
| 524 |
|
|---|
| 525 | pswpOld->cx += 2 * pswpOld->x;
|
|---|
| 526 | pswpOld->cy += Offset;
|
|---|
| 527 | pswpOld->x = pt.x;
|
|---|
| 528 | pswpOld->y = pt.y;
|
|---|
| 529 | }
|
|---|
| 530 | else
|
|---|
| 531 | {
|
|---|
| 532 | parentHeight = OSLibGetWindowHeight(hParent);
|
|---|
| 533 | }
|
|---|
| 534 |
|
|---|
| 535 | if (fuFlags & SWP_SIZE)
|
|---|
| 536 | {
|
|---|
| 537 | if (cy != pswpOld->cy)
|
|---|
| 538 | {
|
|---|
| 539 | flags &= ~SWP_NOMOVE_W;
|
|---|
| 540 | }
|
|---|
| 541 | }
|
|---|
| 542 | else
|
|---|
| 543 | {
|
|---|
| 544 | cx = pswpOld->cx;
|
|---|
| 545 | cy = pswpOld->cy;
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | if ((fuFlags & SWP_MOVE) == 0)
|
|---|
| 549 | {
|
|---|
| 550 | x = pswpOld->x;
|
|---|
| 551 | y = pswpOld->y;
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | y = parentHeight - y - cy;
|
|---|
| 555 | LONG oldY = parentHeight - pswpOld->y - pswpOld->cy;
|
|---|
| 556 |
|
|---|
| 557 | if ((pswpOld->x == x) && (oldY == y))
|
|---|
| 558 | flags |= SWP_NOMOVE_W;
|
|---|
| 559 |
|
|---|
| 560 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
|---|
| 561 | flags |= SWP_NOSIZE_W;
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | if (hParent == NULLHANDLE)
|
|---|
| 565 | {
|
|---|
| 566 | pswpOld->x = x + pswp->x;
|
|---|
| 567 | pswpOld->y = y + cy - pswp->y - pswp->cy;
|
|---|
| 568 | }
|
|---|
| 569 | else {
|
|---|
| 570 | pswpOld->x = pswp->x;
|
|---|
| 571 | pswpOld->y = parentHeight - pswp->y - cy;
|
|---|
| 572 | }
|
|---|
| 573 | pswpOld->cx = pswp->cx;
|
|---|
| 574 | pswpOld->cy = pswp->cy;
|
|---|
| 575 |
|
|---|
| 576 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
|---|
| 577 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
|---|
| 578 |
|
|---|
| 579 | pwpos->flags = (UINT)flags;
|
|---|
| 580 | pwpos->cy = (int)cy;
|
|---|
| 581 | pwpos->cx = (int)cx;
|
|---|
| 582 | pwpos->x = (int)x;
|
|---|
| 583 | pwpos->y = (int)y;
|
|---|
| 584 | pwpos->hwndInsertAfter = hWinAfter;
|
|---|
| 585 | pwpos->hwnd = hWindow;
|
|---|
| 586 | }
|
|---|
| 587 | //******************************************************************************
|
|---|
| 588 | //******************************************************************************
|
|---|
| 589 | void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
|
|---|
| 590 | {
|
|---|
| 591 | BOOL fCvt = FALSE;
|
|---|
| 592 |
|
|---|
| 593 | HWND hWnd = pwpos->hwnd;
|
|---|
| 594 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
|---|
| 595 | long x = pwpos->x;
|
|---|
| 596 | long y = pwpos->y;
|
|---|
| 597 | long cx = pwpos->cx;
|
|---|
| 598 | long cy = pwpos->cy;
|
|---|
| 599 | UINT fuFlags = pwpos->flags;
|
|---|
| 600 | ULONG parentHeight;
|
|---|
| 601 |
|
|---|
| 602 | HWND hWinAfter;
|
|---|
| 603 | ULONG flags = 0;
|
|---|
| 604 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
|---|
| 605 |
|
|---|
| 606 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
|---|
| 607 | // hWinAfter = HWND_TOPMOST;
|
|---|
| 608 | hWinAfter = HWND_TOP;
|
|---|
| 609 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
|---|
| 610 | // hWinAfter = HWND_NOTOPMOST;
|
|---|
| 611 | hWinAfter = HWND_TOP;
|
|---|
| 612 | else if (hWndInsertAfter == HWND_TOP_W)
|
|---|
| 613 | hWinAfter = HWND_TOP;
|
|---|
| 614 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
|---|
| 615 | hWinAfter = HWND_BOTTOM;
|
|---|
| 616 | else
|
|---|
| 617 | hWinAfter = (HWND) hWndInsertAfter;
|
|---|
| 618 |
|
|---|
| 619 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
|---|
| 620 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
|---|
| 621 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
|---|
| 622 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
|---|
| 623 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
|---|
| 624 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
|---|
| 625 | if ( fuFlags & SWP_HIDEWINDOW_W) flags |= SWP_HIDE;
|
|---|
| 626 |
|
|---|
| 627 | if (flags & (SWP_MOVE | SWP_SIZE))
|
|---|
| 628 | {
|
|---|
| 629 | if (hParent == NULLHANDLE)
|
|---|
| 630 | parentHeight = ScreenHeight;
|
|---|
| 631 | else
|
|---|
| 632 | parentHeight = OSLibGetWindowHeight(hParent);
|
|---|
| 633 |
|
|---|
| 634 | if ((flags & SWP_MOVE) == 0)
|
|---|
| 635 | {
|
|---|
| 636 | x = pswpOld->x;
|
|---|
| 637 | y = pswpOld->y;
|
|---|
| 638 |
|
|---|
| 639 | if (!((y == 0) && (pswpOld->cy == 0)))
|
|---|
| 640 | {
|
|---|
| 641 | y = parentHeight - y - pswpOld->cy;
|
|---|
| 642 | }
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | if (flags & SWP_SIZE)
|
|---|
| 646 | {
|
|---|
| 647 | if (cy != pswpOld->cy)
|
|---|
| 648 | flags |= SWP_MOVE;
|
|---|
| 649 | }
|
|---|
| 650 | else
|
|---|
| 651 | {
|
|---|
| 652 | cx = pswpOld->cx;
|
|---|
| 653 | cy = pswpOld->cy;
|
|---|
| 654 | }
|
|---|
| 655 | y = parentHeight - y - cy;
|
|---|
| 656 |
|
|---|
| 657 |
|
|---|
| 658 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
|---|
| 659 | flags &= ~SWP_MOVE;
|
|---|
| 660 |
|
|---|
| 661 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
|---|
| 662 | flags &= ~SWP_SIZE;
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | pswp->fl = flags;
|
|---|
| 666 | pswp->cy = cy;
|
|---|
| 667 | pswp->cx = cx;
|
|---|
| 668 | pswp->x = x;
|
|---|
| 669 | pswp->y = y;
|
|---|
| 670 | pswp->hwndInsertBehind = hWinAfter;
|
|---|
| 671 | pswp->hwnd = hWindow;
|
|---|
| 672 | pswp->ulReserved1 = 0;
|
|---|
| 673 | pswp->ulReserved2 = 0;
|
|---|
| 674 | }
|
|---|
| 675 | //******************************************************************************
|
|---|
| 676 | //******************************************************************************
|
|---|
| 677 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
|
|---|
| 678 | {
|
|---|
| 679 | BOOL rc;
|
|---|
| 680 |
|
|---|
| 681 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
|
|---|
| 682 |
|
|---|
| 683 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
|
|---|
| 684 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
|
|---|
| 685 |
|
|---|
| 686 | return rc;
|
|---|
| 687 | }
|
|---|
| 688 | //******************************************************************************
|
|---|
| 689 | //******************************************************************************
|
|---|
| 690 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
|
|---|
| 691 | {
|
|---|
| 692 | TRACKINFO tinfo;
|
|---|
| 693 |
|
|---|
| 694 | memset(&tinfo, 0, sizeof(TRACKINFO));
|
|---|
| 695 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
|
|---|
| 696 |
|
|---|
| 697 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
|
|---|
| 698 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
|
|---|
| 699 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
|
|---|
| 700 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
|
|---|
| 701 | return TRUE;
|
|---|
| 702 | }
|
|---|
| 703 | //******************************************************************************
|
|---|
| 704 | //******************************************************************************
|
|---|
| 705 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
|---|
| 706 | {
|
|---|
| 707 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
|---|
| 708 | else
|
|---|
| 709 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
|---|
| 710 |
|
|---|
| 711 | return WinBeginEnumWindows(hwnd);
|
|---|
| 712 | }
|
|---|
| 713 | //******************************************************************************
|
|---|
| 714 | //******************************************************************************
|
|---|
| 715 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
|---|
| 716 | {
|
|---|
| 717 | return WinGetNextWindow(hwndEnum);
|
|---|
| 718 | }
|
|---|
| 719 | //******************************************************************************
|
|---|
| 720 | //******************************************************************************
|
|---|
| 721 | HWND OSLibWinQueryClientWindow(HWND hwndFrame)
|
|---|
| 722 | {
|
|---|
| 723 | HWND hwndClient = 0;
|
|---|
| 724 |
|
|---|
| 725 | if(((ULONG)WinSendMsg(hwndFrame, WM_QUERYFRAMEINFO, NULL, NULL)) & FI_FRAME)
|
|---|
| 726 | hwndClient = WinWindowFromID(hwndFrame, FID_CLIENT);
|
|---|
| 727 |
|
|---|
| 728 | return hwndClient;
|
|---|
| 729 | }
|
|---|
| 730 | //******************************************************************************
|
|---|
| 731 | //******************************************************************************
|
|---|
| 732 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
|---|
| 733 | {
|
|---|
| 734 | return WinEndEnumWindows(hwndEnum);
|
|---|
| 735 | }
|
|---|
| 736 | //******************************************************************************
|
|---|
| 737 | //******************************************************************************
|
|---|
| 738 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
|---|
| 739 | {
|
|---|
| 740 | return WinQueryWindowProcess(hwnd, pid, tid);
|
|---|
| 741 | }
|
|---|
| 742 | //******************************************************************************
|
|---|
| 743 | //******************************************************************************
|
|---|
| 744 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
|
|---|
| 745 | {
|
|---|
| 746 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
|
|---|
| 747 | }
|
|---|
| 748 | //******************************************************************************
|
|---|
| 749 | //******************************************************************************
|
|---|
| 750 | BOOL OSLibWinEnableScrollBar(HWND hwndParent, int scrollBar, BOOL fEnable)
|
|---|
| 751 | {
|
|---|
| 752 | HWND hwndScroll;
|
|---|
| 753 |
|
|---|
| 754 | if(scrollBar == OSLIB_VSCROLL) {
|
|---|
| 755 | hwndScroll = WinWindowFromID(hwndParent, FID_VERTSCROLL);
|
|---|
| 756 | }
|
|---|
| 757 | else hwndScroll = WinWindowFromID(hwndParent, FID_HORZSCROLL);
|
|---|
| 758 |
|
|---|
| 759 | if(hwndScroll == NULL)
|
|---|
| 760 | return FALSE;
|
|---|
| 761 |
|
|---|
| 762 | return WinEnableWindow(hwndScroll, fEnable);
|
|---|
| 763 | }
|
|---|
| 764 | //******************************************************************************
|
|---|
| 765 | //******************************************************************************
|
|---|
| 766 | BOOL OSLibWinShowScrollBar(HWND hwndParent, HWND hwndScroll, int scrollBar,
|
|---|
| 767 | BOOL fShow, BOOL fForceChange)
|
|---|
| 768 | {
|
|---|
| 769 | if(hwndScroll == NULL) {
|
|---|
| 770 | dprintf(("OSLibWinShowScrollBar: scrollbar %d (parent %x) not found!", scrollBar, hwndParent));
|
|---|
| 771 | return FALSE;
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 | if(fShow != WinIsWindowVisible(hwndScroll) || fForceChange)
|
|---|
| 775 | {
|
|---|
| 776 | WinSetParent(hwndScroll, fShow ? hwndParent : HWND_OBJECT, FALSE);
|
|---|
| 777 | WinSendMsg(hwndParent, WM_UPDATEFRAME,
|
|---|
| 778 | MPFROMLONG( ( scrollBar == OSLIB_VSCROLL ) ? FCF_VERTSCROLL
|
|---|
| 779 | : FCF_HORZSCROLL),
|
|---|
| 780 | MPVOID );
|
|---|
| 781 |
|
|---|
| 782 | WinShowWindow(hwndScroll, fShow);
|
|---|
| 783 | }
|
|---|
| 784 | return TRUE;
|
|---|
| 785 | }
|
|---|
| 786 | //******************************************************************************
|
|---|
| 787 | //******************************************************************************
|
|---|
| 788 | HWND OSLibWinQueryScrollBarHandle(HWND hwndParent, int scrollBar)
|
|---|
| 789 | {
|
|---|
| 790 | if(scrollBar == OSLIB_VSCROLL) {
|
|---|
| 791 | return WinWindowFromID(hwndParent, FID_VERTSCROLL);
|
|---|
| 792 | }
|
|---|
| 793 | else return WinWindowFromID(hwndParent, FID_HORZSCROLL);
|
|---|
| 794 | }
|
|---|
| 795 | //******************************************************************************
|
|---|
| 796 | //******************************************************************************
|
|---|
| 797 | ULONG OSLibWinGetScrollPos(HWND hwndParent, HWND hwndScroll)
|
|---|
| 798 | {
|
|---|
| 799 | if(hwndScroll == NULL)
|
|---|
| 800 | return 0;
|
|---|
| 801 |
|
|---|
| 802 | return (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
|
|---|
| 803 | }
|
|---|
| 804 | //******************************************************************************
|
|---|
| 805 | //******************************************************************************
|
|---|
| 806 | ULONG OSLibWinSetScrollPos(HWND hwndParent, HWND hwndScroll, int pos, int fRedraw)
|
|---|
| 807 | {
|
|---|
| 808 | ULONG oldPos;
|
|---|
| 809 |
|
|---|
| 810 | if(hwndScroll == NULL)
|
|---|
| 811 | return 0;
|
|---|
| 812 |
|
|---|
| 813 | oldPos = (ULONG)WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0);
|
|---|
| 814 |
|
|---|
| 815 | if(WinSendMsg(hwndScroll, SBM_SETPOS, MPFROMSHORT(pos), MPFROMLONG(fRedraw)) == FALSE)
|
|---|
| 816 | return 0;
|
|---|
| 817 |
|
|---|
| 818 | return oldPos;
|
|---|
| 819 | }
|
|---|
| 820 | //******************************************************************************
|
|---|
| 821 | //******************************************************************************
|
|---|
| 822 | BOOL OSLibWinSetScrollRange(HWND hwndParent, HWND hwndScroll, int minpos,
|
|---|
| 823 | int maxpos, int fRedraw)
|
|---|
| 824 | {
|
|---|
| 825 | if(hwndScroll == NULL)
|
|---|
| 826 | return 0;
|
|---|
| 827 |
|
|---|
| 828 | return (BOOL)WinSendMsg( hwndScroll, SBM_SETSCROLLBAR,
|
|---|
| 829 | MPFROMLONG(WinSendMsg(hwndScroll, SBM_QUERYPOS, 0, 0)),
|
|---|
| 830 | MPFROM2SHORT( minpos ,maxpos ) );
|
|---|
| 831 | }
|
|---|
| 832 | //******************************************************************************
|
|---|
| 833 | //******************************************************************************
|
|---|
| 834 | BOOL OSLibWinSetScrollPageSize(HWND hwndParent, HWND hwndScroll, int pagesize,
|
|---|
| 835 | int totalsize, int fRedraw)
|
|---|
| 836 | {
|
|---|
| 837 | if(hwndScroll == NULL)
|
|---|
| 838 | return 0;
|
|---|
| 839 |
|
|---|
| 840 | return (BOOL)WinSendMsg( hwndScroll, SBM_SETTHUMBSIZE,
|
|---|
| 841 | MPFROM2SHORT(pagesize, totalsize),
|
|---|
| 842 | 0);
|
|---|
| 843 | }
|
|---|
| 844 | //******************************************************************************
|
|---|
| 845 | //******************************************************************************
|
|---|
| 846 | void OSLibTranslateScrollCmdAndMsg(ULONG *msg, ULONG *scrollcmd)
|
|---|
| 847 | {
|
|---|
| 848 | switch(*scrollcmd)
|
|---|
| 849 | {
|
|---|
| 850 | case SB_LINEUP:
|
|---|
| 851 | *scrollcmd = SB_LINEUP_W;
|
|---|
| 852 | break;
|
|---|
| 853 | case SB_LINEDOWN:
|
|---|
| 854 | *scrollcmd = SB_LINEDOWN_W;
|
|---|
| 855 | break;
|
|---|
| 856 | case SB_PAGEUP:
|
|---|
| 857 | *scrollcmd = SB_PAGEUP_W;
|
|---|
| 858 | break;
|
|---|
| 859 | case SB_PAGEDOWN:
|
|---|
| 860 | *scrollcmd = SB_PAGEDOWN_W;
|
|---|
| 861 | break;
|
|---|
| 862 | case SB_SLIDERTRACK:
|
|---|
| 863 | *scrollcmd = SB_THUMBTRACK_W;
|
|---|
| 864 | break;
|
|---|
| 865 | case SB_SLIDERPOSITION:
|
|---|
| 866 | *scrollcmd = SB_THUMBPOSITION_W;
|
|---|
| 867 | break;
|
|---|
| 868 | case SB_ENDSCROLL:
|
|---|
| 869 | *scrollcmd = SB_ENDSCROLL_W;
|
|---|
| 870 | break;
|
|---|
| 871 | }
|
|---|
| 872 | *msg = (*msg == WM_HSCROLL) ? WM_HSCROLL_W : WM_VSCROLL_W;
|
|---|
| 873 | return;
|
|---|
| 874 | }
|
|---|
| 875 | //******************************************************************************
|
|---|
| 876 | //******************************************************************************
|
|---|
| 877 | void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle)
|
|---|
| 878 | {
|
|---|
| 879 | ULONG OSWinStyle, OSFrameStyle, borderWidth, borderHeight,dwExStyle;
|
|---|
| 880 |
|
|---|
| 881 | OSLibWinConvertStyle(dwStyle, &dwExStyle, &OSWinStyle, &OSFrameStyle, &borderWidth, &borderHeight);
|
|---|
| 882 |
|
|---|
| 883 | OSWinStyle = OSWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPCHILDREN);
|
|---|
| 884 |
|
|---|
| 885 | WinSetWindowULong(hwnd, QWL_STYLE,
|
|---|
| 886 | (WinQueryWindowULong(hwnd, QWL_STYLE) & ~0xffff0000) |
|
|---|
| 887 | OSWinStyle);
|
|---|
| 888 |
|
|---|
| 889 | //CB: bug: it doesn't work with child windows!
|
|---|
| 890 |
|
|---|
| 891 | if(OSFrameStyle != 0) // maybe WinQueryClassName == WC_FRAME is better
|
|---|
| 892 | {
|
|---|
| 893 | if(OSFrameStyle & FCF_TITLEBAR)
|
|---|
| 894 | {
|
|---|
| 895 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_TITLEBAR), hwnd, FALSE);
|
|---|
| 896 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_MENU), hwnd, FALSE);
|
|---|
| 897 | }
|
|---|
| 898 | else
|
|---|
| 899 | {
|
|---|
| 900 | WinSetParent(WinWindowFromID(hwnd, FID_TITLEBAR), HWND_OBJECT, FALSE);
|
|---|
| 901 | WinSetParent(WinWindowFromID(hwnd, FID_MENU), HWND_OBJECT, FALSE);
|
|---|
| 902 | }
|
|---|
| 903 | if(OSFrameStyle & FCF_SYSMENU)
|
|---|
| 904 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_SYSMENU), hwnd, FALSE);
|
|---|
| 905 | else
|
|---|
| 906 | WinSetParent(WinWindowFromID(hwnd, FID_SYSMENU), HWND_OBJECT, FALSE);
|
|---|
| 907 |
|
|---|
| 908 | if(OSFrameStyle & FCF_MINBUTTON | OSFrameStyle & FCF_MAXBUTTON)
|
|---|
| 909 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_MINMAX), hwnd, FALSE);
|
|---|
| 910 | else
|
|---|
| 911 | WinSetParent(WinWindowFromID(hwnd, FID_MINMAX), HWND_OBJECT, FALSE);
|
|---|
| 912 |
|
|---|
| 913 | if(OSFrameStyle & FCF_VERTSCROLL)
|
|---|
| 914 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_VERTSCROLL), hwnd, FALSE);
|
|---|
| 915 | else
|
|---|
| 916 | WinSetParent(WinWindowFromID(hwnd, FID_VERTSCROLL), HWND_OBJECT, FALSE);
|
|---|
| 917 |
|
|---|
| 918 | if(OSFrameStyle & FCF_HORZSCROLL)
|
|---|
| 919 | WinSetParent(OSLibWinObjectWindowFromID(hwnd, FID_HORZSCROLL), hwnd, FALSE);
|
|---|
| 920 | else
|
|---|
| 921 | WinSetParent(WinWindowFromID(hwnd, FID_HORZSCROLL), HWND_OBJECT, FALSE);
|
|---|
| 922 |
|
|---|
| 923 | WinSendMsg(hwnd, WM_UPDATEFRAME,
|
|---|
| 924 | MPFROMLONG(FCF_TITLEBAR | FCF_SYSMENU | FCF_MINMAX |
|
|---|
| 925 | FCF_MENU | FCF_VERTSCROLL | FCF_HORZSCROLL),
|
|---|
| 926 | MPVOID);
|
|---|
| 927 | }
|
|---|
| 928 | }
|
|---|
| 929 | //******************************************************************************
|
|---|
| 930 | //******************************************************************************
|
|---|
| 931 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
|
|---|
| 932 | {
|
|---|
| 933 | HWND hwndNext, hwndFound=0;
|
|---|
| 934 | HENUM henum;
|
|---|
| 935 |
|
|---|
| 936 | henum = WinBeginEnumWindows(HWND_OBJECT);
|
|---|
| 937 | while ((hwndNext = WinGetNextWindow(henum)) != 0)
|
|---|
| 938 | {
|
|---|
| 939 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
|
|---|
| 940 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
|
|---|
| 941 | {
|
|---|
| 942 | hwndFound = hwndNext;
|
|---|
| 943 | break;
|
|---|
| 944 | }
|
|---|
| 945 | }
|
|---|
| 946 | WinEndEnumWindows(henum);
|
|---|
| 947 | return hwndFound;
|
|---|
| 948 | }
|
|---|
| 949 | //******************************************************************************
|
|---|
| 950 | //******************************************************************************
|
|---|
| 951 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
|
|---|
| 952 | {
|
|---|
| 953 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
|
|---|
| 954 | return WinSetWindowULong(hwnd, QWS_ID, value);
|
|---|
| 955 | }
|
|---|
| 956 | //******************************************************************************
|
|---|
| 957 | //******************************************************************************
|
|---|