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