[10549] | 1 | /* $Id: oslibwin.cpp,v 1.148 2004-03-19 14:42:03 sandervl Exp $ */
|
---|
[2469] | 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)
|
---|
[10284] | 8 | * Copyright 2002-2003 Innotek Systemberatung GmbH
|
---|
[2469] | 9 | *
|
---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
| 11 | *
|
---|
| 12 | */
|
---|
| 13 | #define INCL_WIN
|
---|
| 14 | #define INCL_PM
|
---|
[3610] | 15 | #define INCL_WINSWITCHLIST
|
---|
[2469] | 16 | #include <os2wrap.h>
|
---|
| 17 | #include <stdlib.h>
|
---|
[9076] | 18 | #include <stdio.h>
|
---|
[2469] | 19 | #include <string.h>
|
---|
| 20 |
|
---|
| 21 | #include <misc.h>
|
---|
[5935] | 22 | #include <win32type.h>
|
---|
[2469] | 23 | #include <winconst.h>
|
---|
[6168] | 24 | #include <winuser32.h>
|
---|
[8126] | 25 | #include <wprocess.h>
|
---|
[2469] | 26 | #include "oslibwin.h"
|
---|
| 27 | #include "oslibutil.h"
|
---|
| 28 | #include "oslibmsg.h"
|
---|
| 29 | #include "oslibgdi.h"
|
---|
| 30 | #include "pmwindow.h"
|
---|
[6342] | 31 | #include "initterm.h"
|
---|
[21544] | 32 | #include "codepage.h"
|
---|
[2469] | 33 |
|
---|
[3144] | 34 | #define DBG_LOCALLOG DBG_oslibwin
|
---|
[2804] | 35 | #include "dbglocal.h"
|
---|
| 36 |
|
---|
[9143] | 37 | //Undocumented PM WS_TOPMOST style; similar to WS_EX_TOPMOST in Windows
|
---|
| 38 | #define WS_TOPMOST 0x00200000L
|
---|
| 39 |
|
---|
[10284] | 40 | //pmwindow.cpp
|
---|
| 41 | MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
|
---|
| 42 |
|
---|
[2469] | 43 | //******************************************************************************
|
---|
| 44 | //******************************************************************************
|
---|
| 45 | BOOL OSLibWinSetParent(HWND hwnd, HWND hwndParent, ULONG fRedraw)
|
---|
| 46 | {
|
---|
| 47 | if(hwndParent == OSLIB_HWND_DESKTOP)
|
---|
| 48 | {
|
---|
| 49 | hwndParent = HWND_DESKTOP;
|
---|
| 50 | }
|
---|
| 51 | else
|
---|
| 52 | if(hwndParent == OSLIB_HWND_OBJECT) {
|
---|
| 53 | hwndParent = HWND_OBJECT;
|
---|
| 54 | }
|
---|
| 55 | return (WinSetParent(hwnd, hwndParent, fRedraw) == 0);
|
---|
| 56 | }
|
---|
| 57 | //******************************************************************************
|
---|
| 58 | //******************************************************************************
|
---|
| 59 | BOOL OSLibWinSetOwner(HWND hwnd, HWND hwndOwner)
|
---|
| 60 | {
|
---|
| 61 | return WinSetOwner(hwnd, hwndOwner);
|
---|
| 62 | }
|
---|
| 63 | //******************************************************************************
|
---|
| 64 | //******************************************************************************
|
---|
[5951] | 65 | HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle, ULONG dwOSFrameStyle,
|
---|
[5685] | 66 | char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
|
---|
[2676] | 67 | ULONG id, BOOL fTaskList,BOOL fShellPosition,
|
---|
[10013] | 68 | DWORD classStyle, HWND *hwndFrame)
|
---|
[2469] | 69 | {
|
---|
[10284] | 70 | HWND hwndClient;
|
---|
| 71 | ULONG dwFrameStyle = 0;
|
---|
[2469] | 72 |
|
---|
[5685] | 73 | if(pszName && *pszName == 0) {
|
---|
[2469] | 74 | pszName = NULL;
|
---|
[5685] | 75 | }
|
---|
| 76 | if(hwndParent == OSLIB_HWND_DESKTOP) {
|
---|
[2469] | 77 | hwndParent = HWND_DESKTOP;
|
---|
[5685] | 78 | }
|
---|
| 79 | if(Owner == OSLIB_HWND_DESKTOP) {
|
---|
[2469] | 80 | Owner = HWND_DESKTOP;
|
---|
[5685] | 81 | }
|
---|
[2469] | 82 |
|
---|
[5685] | 83 | if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
|
---|
| 84 | if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
|
---|
[2676] | 85 |
|
---|
[5685] | 86 | dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
|
---|
[2469] | 87 |
|
---|
[10379] | 88 | if(fTaskList || hwndParent == HWND_DESKTOP)
|
---|
[5685] | 89 | {
|
---|
| 90 | dwFrameStyle |= FCF_NOMOVEWITHOWNER;
|
---|
| 91 | }
|
---|
| 92 | if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
|
---|
[2469] | 93 |
|
---|
[5685] | 94 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
|
---|
| 95 | FCData.flCreateFlags = dwFrameStyle;
|
---|
[2469] | 96 |
|
---|
[5685] | 97 | dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
|
---|
[10275] | 98 | dprintf(("WinCreateWindow parent %x, owner %x", hwndParent, Owner));
|
---|
[2469] | 99 |
|
---|
[5685] | 100 | //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise.
|
---|
| 101 | //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds
|
---|
| 102 | // a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
|
---|
| 103 | *hwndFrame = WinCreateWindow(hwndParent,
|
---|
[10284] | 104 | WC_FRAME,
|
---|
[5685] | 105 | pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
|
---|
| 106 | Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
|
---|
[5951] | 107 | id, (PVOID)&FCData, NULL);
|
---|
[10013] | 108 |
|
---|
[10284] | 109 | //We no longer register our own frame window class as there is code in PM
|
---|
| 110 | //that makes assumptions about frame window class names.
|
---|
| 111 | //Instead we subclass the frame window right after creating it.
|
---|
| 112 | if(*hwndFrame) {
|
---|
| 113 | WinSubclassWindow(*hwndFrame, Win32FrameWindowProc);
|
---|
| 114 | }
|
---|
[5951] | 115 | if(fOS2Look && *hwndFrame) {
|
---|
| 116 | FCData.flCreateFlags = dwOSFrameStyle;
|
---|
| 117 | WinCreateFrameControls(*hwndFrame, &FCData, NULL);
|
---|
| 118 | }
|
---|
[9694] | 119 | if(*hwndFrame == 0) {
|
---|
| 120 | dprintf(("Frame window creation failed!! OS LastError %0x", WinGetLastError(0)));
|
---|
| 121 | return 0;
|
---|
| 122 | }
|
---|
[5685] | 123 | hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
|
---|
| 124 | NULL, dwWinStyle | WS_VISIBLE, 0, 0, 0, 0,
|
---|
| 125 | *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
|
---|
[9256] | 126 | //@PF For all top-level windows we create invisible vertical scroller
|
---|
| 127 | //to show IBM wheel driver that we need WM_VSCROLL messages
|
---|
| 128 | if (hwndParent == HWND_DESKTOP && *hwndFrame)
|
---|
| 129 | OSLibWinCreateInvisibleScroller(*hwndFrame, SBS_VERT);
|
---|
[9694] | 130 |
|
---|
| 131 | if(hwndClient == 0) {
|
---|
| 132 | dprintf(("Client window creation failed!! OS LastError %0x", WinGetLastError(0)));
|
---|
| 133 | }
|
---|
[5685] | 134 | return hwndClient;
|
---|
[2469] | 135 | }
|
---|
| 136 | //******************************************************************************
|
---|
[5512] | 137 | //Note: Also check OSLibSetWindowStyle when changing this!!
|
---|
[2469] | 138 | //******************************************************************************
|
---|
[10031] | 139 | BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle,
|
---|
[9575] | 140 | ULONG *OSFrameStyle)
|
---|
[2469] | 141 | {
|
---|
| 142 | *OSWinStyle = 0;
|
---|
[5951] | 143 | *OSFrameStyle = 0;
|
---|
[2469] | 144 |
|
---|
| 145 | /* Window styles */
|
---|
| 146 | if(dwStyle & WS_DISABLED_W)
|
---|
| 147 | *OSWinStyle |= WS_DISABLED;
|
---|
| 148 | if(dwStyle & WS_CLIPSIBLINGS_W)
|
---|
| 149 | *OSWinStyle |= WS_CLIPSIBLINGS;
|
---|
| 150 | if(dwStyle & WS_CLIPCHILDREN_W)
|
---|
| 151 | *OSWinStyle |= WS_CLIPCHILDREN;
|
---|
[10549] | 152 |
|
---|
| 153 | //Topmost child windows cause painting problems when moved in PM
|
---|
| 154 | if(!(dwStyle & WS_CHILD_W) && dwExStyle & WS_EX_TOPMOST_W)
|
---|
[9143] | 155 | *OSWinStyle |= WS_TOPMOST;
|
---|
[2469] | 156 |
|
---|
[10013] | 157 | //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
|
---|
[10031] | 158 | if(fOS2Look && !(dwExStyle & WS_EX_TOOLWINDOW_W))
|
---|
[10013] | 159 | {
|
---|
[5951] | 160 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
|
---|
| 161 | *OSFrameStyle = FCF_TITLEBAR;
|
---|
[9575] | 162 |
|
---|
[5993] | 163 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
|
---|
[5951] | 164 | {
|
---|
| 165 | *OSFrameStyle |= FCF_SYSMENU;
|
---|
| 166 | }
|
---|
[8035] | 167 | if(dwStyle & WS_MINIMIZEBOX_W) {
|
---|
| 168 | *OSFrameStyle |= FCF_MINBUTTON;
|
---|
[5951] | 169 | }
|
---|
[8035] | 170 | if(dwStyle & WS_MAXIMIZEBOX_W) {
|
---|
| 171 | *OSFrameStyle |= FCF_MAXBUTTON;
|
---|
| 172 | }
|
---|
[5993] | 173 | if(dwStyle & WS_SYSMENU_W) {
|
---|
| 174 | *OSFrameStyle |= FCF_CLOSEBUTTON;
|
---|
| 175 | }
|
---|
[5951] | 176 | }
|
---|
| 177 | }
|
---|
[2469] | 178 | return TRUE;
|
---|
| 179 | }
|
---|
| 180 | //******************************************************************************
|
---|
| 181 | //******************************************************************************
|
---|
[10031] | 182 | BOOL OSLibWinPositionFrameControls(HWND hwndFrame, RECTLOS2 *pRect, DWORD dwStyle,
|
---|
| 183 | DWORD dwExStyle, HICON hSysMenuIcon,
|
---|
[9575] | 184 | BOOL drawCloseButton, BOOL fClassIcon)
|
---|
[5951] | 185 | {
|
---|
| 186 | SWP swp[3];
|
---|
| 187 | HWND hwndControl;
|
---|
| 188 | int i = 0;
|
---|
[5969] | 189 | static int minmaxwidth = 0;
|
---|
| 190 | static int minmaxheight = 0;
|
---|
[5951] | 191 |
|
---|
[9563] | 192 | dprintf(("OSLibWinPositionFrameControls %x (%x,%x) %x %d", hwndFrame, dwStyle, dwExStyle, hSysMenuIcon, drawCloseButton));
|
---|
| 193 |
|
---|
[10013] | 194 | //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
|
---|
| 195 | if(dwExStyle & WS_EX_TOOLWINDOW_W) {
|
---|
| 196 | DebugInt3();
|
---|
| 197 | return FALSE;
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[5951] | 200 | if(minmaxwidth == 0) {
|
---|
[5969] | 201 | minmaxwidth = WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON);
|
---|
| 202 | minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
|
---|
[5951] | 203 | }
|
---|
[10031] | 204 |
|
---|
[7063] | 205 | if(fOS2Look == OS2_APPEARANCE_SYSMENU) {
|
---|
[9575] | 206 | //Note: If no class icon *and* WS_EX_DLGMODALFRAME -> no system menu!!
|
---|
| 207 | // --> TODO
|
---|
[7063] | 208 | hwndControl = WinWindowFromID(hwndFrame, FID_SYSMENU);
|
---|
| 209 | if(hwndControl) {
|
---|
| 210 | swp[i].hwnd = hwndControl;
|
---|
| 211 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
| 212 | swp[i].x = pRect->xLeft;
|
---|
| 213 | swp[i].y = pRect->yBottom;
|
---|
| 214 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
| 215 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
| 216 | }
|
---|
| 217 | swp[i].cx = minmaxwidth/2;
|
---|
| 218 | swp[i].cy = minmaxheight;;
|
---|
| 219 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
| 220 | dprintf(("FID_SYSMENU (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
| 221 | pRect->xLeft += minmaxwidth/2;
|
---|
| 222 | i++;
|
---|
[5969] | 223 | }
|
---|
[5951] | 224 | }
|
---|
[7063] | 225 | else
|
---|
[9575] | 226 | //Note: If no class icon *and* WS_EX_DLGMODALFRAME -> no system menu!!
|
---|
| 227 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W) &&
|
---|
| 228 | !(!fClassIcon && (dwExStyle & WS_EX_DLGMODALFRAME_W)) && hSysMenuIcon)
|
---|
| 229 | {
|
---|
[5993] | 230 | pRect->xLeft += minmaxwidth/2;
|
---|
| 231 | }
|
---|
[7063] | 232 |
|
---|
[5993] | 233 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
|
---|
| 234 | hwndControl = WinWindowFromID(hwndFrame, FID_TITLEBAR);
|
---|
| 235 | if(hwndControl) {
|
---|
| 236 | swp[i].hwnd = hwndControl;
|
---|
| 237 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
| 238 | swp[i].x = pRect->xLeft;
|
---|
| 239 | swp[i].y = pRect->yBottom;
|
---|
| 240 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
| 241 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
| 242 | }
|
---|
| 243 | swp[i].cx = pRect->xRight - pRect->xLeft;
|
---|
[8035] | 244 | if((dwStyle & WS_MINIMIZEBOX_W)) {
|
---|
| 245 | swp[i].cx -= minmaxwidth/2;
|
---|
[5993] | 246 | }
|
---|
[8035] | 247 | if((dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
| 248 | swp[i].cx -= minmaxwidth/2;
|
---|
| 249 | }
|
---|
[10031] | 250 | //there is no close button in warp 3 and sometimes we do not
|
---|
[9345] | 251 | //have close button as well
|
---|
| 252 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3 && drawCloseButton) {
|
---|
[5993] | 253 | swp[i].cx -= minmaxwidth/2;
|
---|
| 254 | }
|
---|
| 255 | swp[i].cy = minmaxheight;
|
---|
| 256 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
| 257 | dprintf(("FID_TITLEBAR (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
| 258 | pRect->xLeft += swp[i].cx;
|
---|
| 259 | i++;
|
---|
[5989] | 260 | }
|
---|
[6019] | 261 | else return FALSE; //no titlebar -> no frame controls
|
---|
[5951] | 262 | }
|
---|
[5993] | 263 | if((dwStyle & WS_MINIMIZEBOX_W) || (dwStyle & WS_MAXIMIZEBOX_W) || (dwStyle & WS_SYSMENU_W)) {
|
---|
| 264 | hwndControl = WinWindowFromID(hwndFrame, FID_MINMAX);
|
---|
| 265 | if(hwndControl) {
|
---|
| 266 | swp[i].hwnd = hwndControl;
|
---|
| 267 | swp[i].hwndInsertBehind = HWND_TOP;
|
---|
| 268 | swp[i].x = pRect->xLeft;
|
---|
| 269 | swp[i].y = pRect->yBottom;
|
---|
| 270 | if(pRect->yTop - pRect->yBottom > minmaxheight) {
|
---|
| 271 | swp[i].y += pRect->yTop - pRect->yBottom - minmaxheight;
|
---|
| 272 | }
|
---|
| 273 | swp[i].cx = 0;
|
---|
[8035] | 274 | if((dwStyle & WS_MINIMIZEBOX_W)) {
|
---|
| 275 | swp[i].cx += minmaxwidth/2;
|
---|
[5993] | 276 | }
|
---|
[8035] | 277 | if((dwStyle & WS_MAXIMIZEBOX_W)) {
|
---|
| 278 | swp[i].cx += minmaxwidth/2;
|
---|
| 279 | }
|
---|
[9345] | 280 | //there is no close button in warp 3 and sometimes we do not have
|
---|
| 281 | //close button as well
|
---|
| 282 | if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3 && drawCloseButton) {
|
---|
[5993] | 283 | swp[i].cx += minmaxwidth/2;
|
---|
| 284 | }
|
---|
[10379] | 285 | //one pixel more to let PM center the controls properly
|
---|
| 286 | swp[i].cy = minmaxheight+1;
|
---|
[5993] | 287 | swp[i].fl = SWP_SIZE | SWP_MOVE | SWP_SHOW;
|
---|
| 288 | dprintf(("FID_MINMAX (%d,%d)(%d,%d)", swp[i].x, swp[i].y, swp[i].cx, swp[i].cy));
|
---|
| 289 | pRect->xLeft += swp[i].cx;
|
---|
| 290 | i++;
|
---|
[5969] | 291 | }
|
---|
[5951] | 292 | }
|
---|
| 293 | return WinSetMultWindowPos(GetThreadHAB(), swp, i);
|
---|
| 294 | }
|
---|
| 295 | //******************************************************************************
|
---|
| 296 | //******************************************************************************
|
---|
[2469] | 297 | BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
|
---|
| 298 | {
|
---|
| 299 | if(offset == OSLIB_QWL_USER)
|
---|
| 300 | offset = QWL_USER;
|
---|
| 301 |
|
---|
| 302 | return WinSetWindowULong(hwnd, offset, value);
|
---|
| 303 | }
|
---|
| 304 | //******************************************************************************
|
---|
| 305 | //******************************************************************************
|
---|
[8097] | 306 | BOOL OSLibWinGetMinPosition(HWND hwnd, PSWP pswp, PPOINTL pointl)
|
---|
| 307 | {
|
---|
| 308 | return WinGetMinPosition(hwnd, pswp, pointl);
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | //******************************************************************************
|
---|
| 312 | //******************************************************************************
|
---|
[2469] | 313 | ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
|
---|
| 314 | {
|
---|
| 315 | if(offset == OSLIB_QWL_USER)
|
---|
| 316 | offset = QWL_USER;
|
---|
| 317 |
|
---|
| 318 | return WinQueryWindowULong(hwnd, offset);
|
---|
| 319 | }
|
---|
| 320 | //******************************************************************************
|
---|
| 321 | //******************************************************************************
|
---|
| 322 | BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
|
---|
| 323 | {
|
---|
[5713] | 324 | return WinAlarm(hwndDeskTop,flStyle);
|
---|
[2469] | 325 | }
|
---|
| 326 | //******************************************************************************
|
---|
| 327 | HWND OSLibWinQueryFocus(HWND hwndDeskTop)
|
---|
| 328 | {
|
---|
[5713] | 329 | return WinQueryFocus(hwndDeskTop);
|
---|
[2469] | 330 | }
|
---|
| 331 | //******************************************************************************
|
---|
| 332 | //******************************************************************************
|
---|
| 333 | HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
|
---|
| 334 | {
|
---|
[5713] | 335 | return WinWindowFromID(hwndParent,id);
|
---|
[2469] | 336 | }
|
---|
| 337 | //******************************************************************************
|
---|
| 338 | //******************************************************************************
|
---|
| 339 | BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
|
---|
| 340 | {
|
---|
[5713] | 341 | return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? 0 : FC_NOSETACTIVE);
|
---|
[2469] | 342 | }
|
---|
| 343 | //******************************************************************************
|
---|
| 344 | //******************************************************************************
|
---|
| 345 | BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
|
---|
| 346 | {
|
---|
[5713] | 347 | return WinIsChild (hwnd, hwndOf);
|
---|
[2469] | 348 | }
|
---|
| 349 | //******************************************************************************
|
---|
| 350 | //******************************************************************************
|
---|
| 351 | ULONG OSLibGetWindowHeight(HWND hwnd)
|
---|
| 352 | {
|
---|
[5713] | 353 | RECTL rect;
|
---|
[2469] | 354 |
|
---|
[5713] | 355 | return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
|
---|
[2469] | 356 | }
|
---|
| 357 | //******************************************************************************
|
---|
| 358 | //******************************************************************************
|
---|
[3250] | 359 | LONG OSLibWinQuerySysValue(LONG iSysValue)
|
---|
[2469] | 360 | {
|
---|
[5713] | 361 | return WinQuerySysValue(HWND_DESKTOP,iSysValue);
|
---|
[2469] | 362 | }
|
---|
| 363 | //******************************************************************************
|
---|
| 364 | //******************************************************************************
|
---|
[6395] | 365 | BOOL OSLibWinSetSysValue(LONG iSysValue, ULONG val)
|
---|
| 366 | {
|
---|
[9072] | 367 | return WinSetSysValue(HWND_DESKTOP, iSysValue, val);
|
---|
[6395] | 368 | }
|
---|
| 369 | //******************************************************************************
|
---|
| 370 | //******************************************************************************
|
---|
[2469] | 371 | ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
|
---|
| 372 | {
|
---|
[5713] | 373 | return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
|
---|
[2469] | 374 | }
|
---|
| 375 | //******************************************************************************
|
---|
| 376 | //******************************************************************************
|
---|
| 377 | BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
|
---|
| 378 | {
|
---|
[5713] | 379 | return WinSetDlgItemText(hwndDlg,idItem,pszText);
|
---|
[2469] | 380 | }
|
---|
| 381 | //******************************************************************************
|
---|
| 382 | //******************************************************************************
|
---|
[3250] | 383 | BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint)
|
---|
[2469] | 384 | {
|
---|
[5713] | 385 | return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
|
---|
[2469] | 386 | }
|
---|
| 387 | //******************************************************************************
|
---|
| 388 | //******************************************************************************
|
---|
[5385] | 389 | BOOL OSLibWinSetPointerPos(int x, int y)
|
---|
| 390 | {
|
---|
[5713] | 391 | return WinSetPointerPos(HWND_DESKTOP, x, y);
|
---|
[5385] | 392 | }
|
---|
| 393 | //******************************************************************************
|
---|
| 394 | //******************************************************************************
|
---|
[2469] | 395 | HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
|
---|
| 396 | {
|
---|
[5713] | 397 | return WinQueryWindow(hwnd, lCode);
|
---|
[2469] | 398 | }
|
---|
| 399 | //******************************************************************************
|
---|
| 400 | //******************************************************************************
|
---|
| 401 | BOOL OSLibWinSetMultWindowPos(PSWP pswp, ULONG num)
|
---|
| 402 | {
|
---|
| 403 | return WinSetMultWindowPos(GetThreadHAB(), pswp, num);
|
---|
| 404 | }
|
---|
| 405 | //******************************************************************************
|
---|
| 406 | //******************************************************************************
|
---|
| 407 | BOOL OSLibWinShowWindow(HWND hwnd, ULONG fl)
|
---|
| 408 | {
|
---|
| 409 | BOOL rc = 1;
|
---|
| 410 |
|
---|
| 411 | if(fl & SWP_SHOW) {
|
---|
| 412 | rc = WinShowWindow(hwnd, TRUE);
|
---|
| 413 | }
|
---|
| 414 | if(rc == 0)
|
---|
| 415 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
| 416 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, fl);
|
---|
| 417 | if(rc == 0)
|
---|
| 418 | dprintf(("WinShowWindow %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
| 419 | return rc;
|
---|
| 420 | }
|
---|
| 421 | //******************************************************************************
|
---|
| 422 | //******************************************************************************
|
---|
| 423 | BOOL OSLibWinDestroyWindow(HWND hwnd)
|
---|
| 424 | {
|
---|
| 425 | return WinDestroyWindow(hwnd);
|
---|
| 426 | }
|
---|
| 427 | //******************************************************************************
|
---|
| 428 | //******************************************************************************
|
---|
[7765] | 429 | BOOL OSLibWinQueryWindowClientRect(HWND hwndOS2, PRECT pRect)
|
---|
| 430 | {
|
---|
| 431 | BOOL rc;
|
---|
| 432 | RECTLOS2 rectl;
|
---|
| 433 |
|
---|
| 434 | rc = WinQueryWindowRect(hwndOS2, (PRECTL)&rectl);
|
---|
| 435 | if(rc) {
|
---|
| 436 | pRect->left = 0;
|
---|
| 437 | pRect->right = rectl.xRight - rectl.xLeft;
|
---|
| 438 | pRect->top = 0;
|
---|
| 439 | pRect->bottom = rectl.yTop - rectl.yBottom;
|
---|
| 440 | }
|
---|
| 441 | else memset(pRect, 0, sizeof(RECT));
|
---|
| 442 | return rc;
|
---|
| 443 | }
|
---|
| 444 | //******************************************************************************
|
---|
| 445 | //******************************************************************************
|
---|
[7780] | 446 | BOOL OSLibQueryWindowRectAbsolute (HWND hwndOS2, PRECT pRect)
|
---|
| 447 | {
|
---|
| 448 | BOOL rc;
|
---|
| 449 | RECTLOS2 rectl;
|
---|
| 450 |
|
---|
| 451 | rc = WinQueryWindowRect (hwndOS2, (RECTL *)&rectl);
|
---|
| 452 | if (rc)
|
---|
| 453 | {
|
---|
| 454 | rc = WinMapWindowPoints (hwndOS2, HWND_DESKTOP, (POINTL *)&rectl, 2);
|
---|
| 455 | if (rc)
|
---|
| 456 | {
|
---|
| 457 | pRect->left = rectl.xLeft;
|
---|
| 458 | pRect->right = rectl.xRight;
|
---|
| 459 | pRect->top = mapScreenY (rectl.yTop);
|
---|
| 460 | pRect->bottom = mapScreenY (rectl.yBottom);
|
---|
| 461 | }
|
---|
| 462 | }
|
---|
| 463 | if (!rc)
|
---|
| 464 | {
|
---|
| 465 | memset(pRect, 0, sizeof(*pRect));
|
---|
| 466 | }
|
---|
| 467 | return rc;
|
---|
| 468 | }
|
---|
| 469 | //******************************************************************************
|
---|
| 470 | //******************************************************************************
|
---|
[3662] | 471 | #if 0
|
---|
| 472 | BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
|
---|
[2469] | 473 | {
|
---|
| 474 | BOOL rc;
|
---|
| 475 | RECTLOS2 rectl;
|
---|
| 476 |
|
---|
[3662] | 477 | rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
|
---|
[2469] | 478 | if(rc) {
|
---|
| 479 | if(RelativeTo == RELATIVE_TO_SCREEN) {
|
---|
[3662] | 480 | mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
|
---|
[2469] | 481 | }
|
---|
[3662] | 482 | else mapOS2ToWin32RectFrame(window,&rectl,pRect);
|
---|
[2469] | 483 | }
|
---|
| 484 | else memset(pRect, 0, sizeof(RECT));
|
---|
| 485 | return rc;
|
---|
| 486 | }
|
---|
[3662] | 487 | #endif
|
---|
[2469] | 488 | //******************************************************************************
|
---|
| 489 | //******************************************************************************
|
---|
| 490 | BOOL OSLibWinIsIconic(HWND hwnd)
|
---|
| 491 | {
|
---|
| 492 | SWP swp;
|
---|
| 493 | BOOL rc;
|
---|
| 494 |
|
---|
| 495 | rc = WinQueryWindowPos(hwnd, &swp);
|
---|
| 496 | if(rc == FALSE) {
|
---|
| 497 | dprintf(("OSLibWinIsIconic: WinQueryWindowPos %x failed", hwnd));
|
---|
| 498 | return FALSE;
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | if(swp.fl & SWP_MINIMIZE)
|
---|
| 502 | return TRUE;
|
---|
| 503 | else return FALSE;
|
---|
| 504 | }
|
---|
| 505 | //******************************************************************************
|
---|
| 506 | //******************************************************************************
|
---|
| 507 | BOOL OSLibWinSetActiveWindow(HWND hwnd)
|
---|
| 508 | {
|
---|
[3662] | 509 | BOOL rc;
|
---|
| 510 |
|
---|
| 511 | rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
|
---|
| 512 | if(rc == FALSE) {
|
---|
[5685] | 513 | dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
|
---|
[3662] | 514 | }
|
---|
| 515 | return rc;
|
---|
[2469] | 516 | }
|
---|
| 517 | //******************************************************************************
|
---|
| 518 | //******************************************************************************
|
---|
| 519 | BOOL OSLibWinSetFocus(HWND hwnd)
|
---|
| 520 | {
|
---|
| 521 | return WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
| 522 | }
|
---|
| 523 | //******************************************************************************
|
---|
| 524 | //******************************************************************************
|
---|
| 525 | BOOL OSLibWinEnableWindow(HWND hwnd, BOOL fEnable)
|
---|
| 526 | {
|
---|
| 527 | BOOL rc;
|
---|
| 528 | HWND hwndClient;
|
---|
| 529 |
|
---|
| 530 | rc = WinEnableWindow(hwnd, fEnable);
|
---|
| 531 | hwndClient = WinWindowFromID(hwnd, FID_CLIENT);
|
---|
| 532 | if(hwndClient) {
|
---|
| 533 | WinEnableWindow(hwndClient, fEnable);
|
---|
| 534 | }
|
---|
| 535 | return rc;
|
---|
| 536 | }
|
---|
| 537 | //******************************************************************************
|
---|
| 538 | //******************************************************************************
|
---|
| 539 | BOOL OSLibWinIsWindowEnabled(HWND hwnd)
|
---|
| 540 | {
|
---|
| 541 | return WinIsWindowEnabled(hwnd);
|
---|
| 542 | }
|
---|
| 543 | //******************************************************************************
|
---|
| 544 | //******************************************************************************
|
---|
| 545 | BOOL OSLibWinIsWindowVisible(HWND hwnd)
|
---|
| 546 | {
|
---|
| 547 | return WinIsWindowVisible(hwnd);
|
---|
| 548 | }
|
---|
| 549 | //******************************************************************************
|
---|
| 550 | //******************************************************************************
|
---|
[3513] | 551 | HWND OSLibWinQueryActiveWindow()
|
---|
[2469] | 552 | {
|
---|
| 553 | return WinQueryActiveWindow(HWND_DESKTOP);
|
---|
| 554 | }
|
---|
| 555 | //******************************************************************************
|
---|
| 556 | //******************************************************************************
|
---|
| 557 | LONG OSLibWinQueryWindowTextLength(HWND hwnd)
|
---|
| 558 | {
|
---|
| 559 | return WinQueryWindowTextLength(hwnd);
|
---|
| 560 | }
|
---|
| 561 | //******************************************************************************
|
---|
| 562 | //******************************************************************************
|
---|
| 563 | LONG OSLibWinQueryWindowText(HWND hwnd, LONG length, LPSTR lpsz)
|
---|
| 564 | {
|
---|
[21463] | 565 | return WinQueryWindowText(hwnd, length, lpsz);
|
---|
[2469] | 566 | }
|
---|
| 567 | //******************************************************************************
|
---|
| 568 | //******************************************************************************
|
---|
| 569 | BOOL OSLibWinSetWindowText(HWND hwnd, LPSTR lpsz)
|
---|
| 570 | {
|
---|
[21463] | 571 | return WinSetWindowText(hwnd, lpsz);
|
---|
[2469] | 572 | }
|
---|
| 573 | //******************************************************************************
|
---|
| 574 | //******************************************************************************
|
---|
[5951] | 575 | BOOL OSLibWinSetTitleBarText(HWND hwnd, LPSTR lpsz)
|
---|
| 576 | {
|
---|
[21544] | 577 | // convert character code if needed (normally, only on the main
|
---|
| 578 | // thread since Win32ThreadProc() sets the HMQ code page to the
|
---|
| 579 | // Windows ANSI code page so that all threads created by Win32 API
|
---|
| 580 | // will be already in the ANSI code page)
|
---|
| 581 | ULONG cpFrom, cpTo;
|
---|
| 582 | cpFrom = cpTo = GetDisplayCodepage();
|
---|
| 583 | HMQ hmq = (HMQ)WinQueryWindowULong(hwnd, QWL_HMQ);
|
---|
| 584 | if (hmq)
|
---|
| 585 | cpTo = WinQueryCp(hmq);
|
---|
| 586 |
|
---|
| 587 | LPSTR psz = NULL;
|
---|
| 588 | if(lpsz && cpFrom != cpTo) {
|
---|
| 589 | int size = (strlen(lpsz) + 1) * 2; // count for DBCS just in case
|
---|
| 590 | psz = (LPSTR)_smalloc(size);
|
---|
| 591 | if (WinCpTranslateString(GetThreadHAB(), cpFrom, lpsz, cpTo, size, psz)) {
|
---|
| 592 | dprintf(("OSLibWinSetTitleBarTextCp: cp%d->cp%d", cpFrom, cpTo));
|
---|
| 593 | lpsz = psz;
|
---|
| 594 | } else {
|
---|
| 595 | dprintf(("OSLibWinSetTitleBarTextCp: ERROR: cp%d->cp%d failed!", cpFrom, cpTo));
|
---|
| 596 | }
|
---|
| 597 | }
|
---|
| 598 | BOOL rc = WinSetWindowText(WinWindowFromID(hwnd, FID_TITLEBAR), lpsz);
|
---|
| 599 | if (psz) {
|
---|
| 600 | _sfree(psz);
|
---|
| 601 | }
|
---|
| 602 | return rc;
|
---|
[5951] | 603 | }
|
---|
| 604 | //******************************************************************************
|
---|
| 605 | //******************************************************************************
|
---|
[2469] | 606 | BOOL OSLibWinFlashWindow(HWND hwnd, BOOL fFlash)
|
---|
| 607 | {
|
---|
| 608 | return WinFlashWindow(hwnd, fFlash);
|
---|
| 609 | }
|
---|
| 610 | //******************************************************************************
|
---|
| 611 | //******************************************************************************
|
---|
| 612 | HWND OSLibWinWindowFromPoint(HWND hwnd, PVOID ppoint)
|
---|
| 613 | {
|
---|
| 614 | return WinWindowFromPoint((hwnd == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP : hwnd, (PPOINTL)ppoint, TRUE);
|
---|
| 615 | }
|
---|
[9866] | 616 |
|
---|
[2469] | 617 | //******************************************************************************
|
---|
[10031] | 618 | //@PF This is exactly that weird message PM sends when we maximize window from
|
---|
[9866] | 619 | //icon - this coordinates NEVER surface later and this combination of SWP
|
---|
| 620 | //commands is useless, yet it starts the correct reaction of maximiztion from
|
---|
| 621 | //icon state
|
---|
[2469] | 622 | //******************************************************************************
|
---|
[9866] | 623 | BOOL OSLibWinRestoreWindow(HWND hwnd)
|
---|
| 624 | {
|
---|
| 625 | BOOL rc = WinSetWindowPos(hwnd, 0, -32000, 32000, 32000, 32000 , SWP_MAXIMIZE | SWP_RESTORE | SWP_ACTIVATE);
|
---|
| 626 | return (rc);
|
---|
| 627 | }
|
---|
| 628 |
|
---|
| 629 | //******************************************************************************
|
---|
| 630 | //******************************************************************************
|
---|
[2469] | 631 | BOOL OSLibWinMinimizeWindow(HWND hwnd)
|
---|
| 632 | {
|
---|
[8301] | 633 | /* @@PF The reason for this weird minimize algorithm is that we are not fully
|
---|
| 634 | using PM for minimization. I.e. we respect all PM messages yet we do mess
|
---|
[10031] | 635 | so much with some messages that minimization is based partly on vodoo.
|
---|
[8301] | 636 | That is if you try minimize and deactivate in one call it will fail.
|
---|
| 637 | Here we deactivate yourselves and give focus to next window that is
|
---|
| 638 | on desktop, this func also works with MDI */
|
---|
| 639 |
|
---|
| 640 | BOOL rc;
|
---|
[8350] | 641 | HWND hwndNext;
|
---|
[8301] | 642 |
|
---|
| 643 | rc = WinSetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_MINIMIZE);
|
---|
[9072] | 644 |
|
---|
[8301] | 645 | if (rc) {
|
---|
| 646 | rc = WinSetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE | SWP_ZORDER);
|
---|
[8304] | 647 | if (rc)
|
---|
| 648 | {
|
---|
[8350] | 649 | HENUM henum;
|
---|
| 650 | henum = WinBeginEnumWindows(HWND_DESKTOP);
|
---|
| 651 | while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE)
|
---|
| 652 | {
|
---|
| 653 | if (WinIsWindowVisible(hwndNext) && WinIsWindowShowing(hwndNext)) break;
|
---|
| 654 | }
|
---|
| 655 | WinEndEnumWindows (henum);
|
---|
| 656 | rc = WinSetWindowPos(hwndNext, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
|
---|
[8304] | 657 | }
|
---|
[8301] | 658 | }
|
---|
[9072] | 659 |
|
---|
[8301] | 660 | return (rc);
|
---|
[2469] | 661 | }
|
---|
| 662 | //******************************************************************************
|
---|
| 663 | //******************************************************************************
|
---|
| 664 | BOOL OSLibWinGetBorderSize(HWND hwnd, OSLIBPOINT *pointl)
|
---|
| 665 | {
|
---|
| 666 | pointl->x = 0;
|
---|
| 667 | pointl->y = 0;
|
---|
| 668 | return (BOOL) WinSendMsg(hwnd, WM_QUERYBORDERSIZE, MPFROMP( &pointl), 0);
|
---|
| 669 | }
|
---|
| 670 | //******************************************************************************
|
---|
| 671 | //******************************************************************************
|
---|
| 672 | BOOL OSLibWinSetIcon(HWND hwnd, HANDLE hIcon)
|
---|
| 673 | {
|
---|
[6168] | 674 | ULONG hIconOS2 = GetOS2Icon(hIcon);
|
---|
[10031] | 675 | if(hIconOS2)
|
---|
[6168] | 676 | return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIconOS2, 0);
|
---|
| 677 | return FALSE;
|
---|
[2469] | 678 | }
|
---|
| 679 | //******************************************************************************
|
---|
| 680 | //******************************************************************************
|
---|
| 681 | BOOL OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp)
|
---|
| 682 | {
|
---|
| 683 | return WinQueryWindowPos(hwnd, pswp);
|
---|
| 684 | }
|
---|
| 685 | //******************************************************************************
|
---|
| 686 | //******************************************************************************
|
---|
[5685] | 687 | void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
|
---|
| 688 | int parentHeight, HWND hwnd)
|
---|
[2469] | 689 | {
|
---|
| 690 | HWND hWindow = pswp->hwnd;
|
---|
| 691 | HWND hWndInsertAfter = pswp->hwndInsertBehind;
|
---|
[5685] | 692 | long x = pswp->x;
|
---|
| 693 | long y = pswp->y;
|
---|
[2469] | 694 | long cx = pswp->cx;
|
---|
| 695 | long cy = pswp->cy;
|
---|
| 696 | UINT fuFlags = (UINT)pswp->fl;
|
---|
| 697 |
|
---|
| 698 | HWND hWinAfter;
|
---|
| 699 | ULONG flags = 0;
|
---|
| 700 |
|
---|
| 701 | HWND hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
|
---|
| 702 |
|
---|
| 703 | if (hWndInsertAfter == HWND_TOP)
|
---|
| 704 | hWinAfter = HWND_TOP_W;
|
---|
| 705 | else if (hWndInsertAfter == HWND_BOTTOM)
|
---|
| 706 | hWinAfter = HWND_BOTTOM_W;
|
---|
| 707 | else
|
---|
| 708 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
| 709 |
|
---|
| 710 | //***********************************
|
---|
| 711 | // convert PM flags to Windows flags
|
---|
| 712 | //***********************************
|
---|
| 713 | if (!(fuFlags & SWP_SIZE)) flags |= SWP_NOSIZE_W;
|
---|
| 714 | if (!(fuFlags & SWP_MOVE)) flags |= SWP_NOMOVE_W;
|
---|
| 715 | if (!(fuFlags & SWP_ZORDER)) flags |= SWP_NOZORDER_W;
|
---|
| 716 | if ( fuFlags & SWP_NOREDRAW) flags |= SWP_NOREDRAW_W;
|
---|
| 717 | if (!(fuFlags & SWP_ACTIVATE)) flags |= SWP_NOACTIVATE_W;
|
---|
| 718 | if ( fuFlags & SWP_SHOW) flags |= SWP_SHOWWINDOW_W;
|
---|
| 719 | if ( fuFlags & SWP_HIDE) flags |= SWP_HIDEWINDOW_W;
|
---|
| 720 | if ( fuFlags & SWP_NOADJUST) flags |= SWP_NOSENDCHANGING_W;
|
---|
| 721 |
|
---|
| 722 | if(fuFlags & (SWP_MOVE | SWP_SIZE))
|
---|
| 723 | {
|
---|
[3662] | 724 | y = parentHeight - y - pswp->cy;
|
---|
[2521] | 725 |
|
---|
[2469] | 726 | if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
|
---|
| 727 | flags |= SWP_NOMOVE_W;
|
---|
| 728 |
|
---|
| 729 | if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
|
---|
| 730 | flags |= SWP_NOSIZE_W;
|
---|
| 731 |
|
---|
| 732 | if (fuFlags & SWP_SIZE)
|
---|
| 733 | {
|
---|
| 734 | if (pswp->cy != pswpOld->cy)
|
---|
| 735 | {
|
---|
| 736 | flags &= ~SWP_NOMOVE_W;
|
---|
| 737 | }
|
---|
| 738 | }
|
---|
| 739 | }
|
---|
| 740 |
|
---|
| 741 | pswpOld->x = pswp->x;
|
---|
[3662] | 742 | pswpOld->y = parentHeight-pswp->y-pswp->cy;
|
---|
[2469] | 743 | pswpOld->cx = pswp->cx;
|
---|
| 744 | pswpOld->cy = pswp->cy;
|
---|
| 745 |
|
---|
| 746 | dprintf(("window (%d,%d)(%d,%d) client (%d,%d)(%d,%d)",
|
---|
| 747 | x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
|
---|
| 748 |
|
---|
| 749 | pwpos->flags = (UINT)flags;
|
---|
| 750 | pwpos->cy = cy;
|
---|
| 751 | pwpos->cx = cx;
|
---|
| 752 | pwpos->x = x;
|
---|
| 753 | pwpos->y = y;
|
---|
| 754 | pwpos->hwndInsertAfter = hWinAfter;
|
---|
| 755 | pwpos->hwnd = hWindow;
|
---|
[9463] | 756 |
|
---|
| 757 | dprintf2(("OSLibMapSWPtoWINDOWPOS %x (%d,%d)(%d,%d) -> %x (%d,%d)(%d,%d) parent height %d", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy, flags, x, y, cx, cy, parentHeight));
|
---|
[2469] | 758 | }
|
---|
| 759 | //******************************************************************************
|
---|
| 760 | //******************************************************************************
|
---|
[5685] | 761 | void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
|
---|
| 762 | int parentHeight, HWND hFrame)
|
---|
[2469] | 763 | {
|
---|
| 764 | BOOL fCvt = FALSE;
|
---|
| 765 |
|
---|
| 766 | HWND hWnd = pwpos->hwnd;
|
---|
| 767 | HWND hWndInsertAfter = pwpos->hwndInsertAfter;
|
---|
[5685] | 768 | long x = pwpos->x;
|
---|
| 769 | long y = pwpos->y;
|
---|
[2469] | 770 | long cx = pwpos->cx;
|
---|
| 771 | long cy = pwpos->cy;
|
---|
| 772 | UINT fuFlags = pwpos->flags;
|
---|
| 773 |
|
---|
| 774 | HWND hWinAfter;
|
---|
| 775 | ULONG flags = 0;
|
---|
| 776 | HWND hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
|
---|
| 777 |
|
---|
| 778 | if (hWndInsertAfter == HWND_TOPMOST_W)
|
---|
| 779 | // hWinAfter = HWND_TOPMOST;
|
---|
| 780 | hWinAfter = HWND_TOP;
|
---|
| 781 | else if (hWndInsertAfter == HWND_NOTOPMOST_W)
|
---|
| 782 | // hWinAfter = HWND_NOTOPMOST;
|
---|
| 783 | hWinAfter = HWND_TOP;
|
---|
| 784 | else if (hWndInsertAfter == HWND_TOP_W)
|
---|
| 785 | hWinAfter = HWND_TOP;
|
---|
| 786 | else if (hWndInsertAfter == HWND_BOTTOM_W)
|
---|
| 787 | hWinAfter = HWND_BOTTOM;
|
---|
| 788 | else
|
---|
| 789 | hWinAfter = (HWND) hWndInsertAfter;
|
---|
| 790 |
|
---|
| 791 | if (!(fuFlags & SWP_NOSIZE_W )) flags |= SWP_SIZE;
|
---|
| 792 | if (!(fuFlags & SWP_NOMOVE_W )) flags |= SWP_MOVE;
|
---|
| 793 | if (!(fuFlags & SWP_NOZORDER_W )) flags |= SWP_ZORDER;
|
---|
| 794 | if ( fuFlags & SWP_NOREDRAW_W ) flags |= SWP_NOREDRAW;
|
---|
| 795 | if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
|
---|
| 796 | if ( fuFlags & SWP_SHOWWINDOW_W) flags |= SWP_SHOW;
|
---|
[9589] | 797 | //SvL: Must also deactivate the window when hiding it or else focus won't
|
---|
| 798 | // change. (NOTE: make sure this doesn't cause regressions (01-02-2003)
|
---|
[9590] | 799 | if ( fuFlags & SWP_HIDEWINDOW_W) {
|
---|
| 800 | flags |= SWP_HIDE|SWP_DEACTIVATE;
|
---|
| 801 | }
|
---|
[9589] | 802 |
|
---|
[2469] | 803 | if ( fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
|
---|
| 804 |
|
---|
[3662] | 805 | if(flags & (SWP_MOVE | SWP_SIZE))
|
---|
[2469] | 806 | {
|
---|
[3662] | 807 | if((flags & SWP_MOVE) == 0)
|
---|
[2469] | 808 | {
|
---|
| 809 | x = pswpOld->x;
|
---|
| 810 | y = pswpOld->y;
|
---|
| 811 |
|
---|
[3662] | 812 | y = parentHeight - y - pswpOld->cy;
|
---|
| 813 | }
|
---|
[2469] | 814 |
|
---|
[3662] | 815 | if(flags & SWP_SIZE)
|
---|
[2469] | 816 | {
|
---|
| 817 | if (cy != pswpOld->cy)
|
---|
| 818 | flags |= SWP_MOVE;
|
---|
| 819 | }
|
---|
| 820 | else
|
---|
| 821 | {
|
---|
| 822 | cx = pswpOld->cx;
|
---|
| 823 | cy = pswpOld->cy;
|
---|
| 824 | }
|
---|
[3662] | 825 | y = parentHeight - y - cy;
|
---|
[2469] | 826 |
|
---|
[2521] | 827 | if ((pswpOld->x == x) && (pswpOld->y == y))
|
---|
[2469] | 828 | flags &= ~SWP_MOVE;
|
---|
| 829 |
|
---|
| 830 | if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
|
---|
| 831 | flags &= ~SWP_SIZE;
|
---|
| 832 | }
|
---|
| 833 |
|
---|
| 834 | pswp->fl = flags;
|
---|
| 835 | pswp->cy = cy;
|
---|
| 836 | pswp->cx = cx;
|
---|
| 837 | pswp->x = x;
|
---|
| 838 | pswp->y = y;
|
---|
| 839 | pswp->hwndInsertBehind = hWinAfter;
|
---|
| 840 | pswp->hwnd = hWindow;
|
---|
| 841 | pswp->ulReserved1 = 0;
|
---|
| 842 | pswp->ulReserved2 = 0;
|
---|
[9463] | 843 |
|
---|
| 844 | dprintf2(("OSLibMapWINDOWPOStoSWP %x (%d,%d)(%d,%d) -> %x (%d,%d)(%d,%d) parent height %d", pwpos->flags, pwpos->x, pwpos->y, pwpos->cx, pwpos->cy, flags, x, y, cx, cy, parentHeight));
|
---|
[2469] | 845 | }
|
---|
| 846 | //******************************************************************************
|
---|
| 847 | //******************************************************************************
|
---|
[5685] | 848 | void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
|
---|
| 849 | {
|
---|
| 850 | SWP swp;
|
---|
| 851 | BOOL rc;
|
---|
| 852 |
|
---|
| 853 | swp.hwnd = hwnd;
|
---|
| 854 | swp.hwndInsertBehind = 0;
|
---|
| 855 | swp.x = x;
|
---|
| 856 | swp.y = parentHeight - y - cy;
|
---|
| 857 | swp.cx = cx;
|
---|
| 858 | swp.cy = cy;
|
---|
| 859 | swp.fl = SWP_MOVE | SWP_SIZE;
|
---|
| 860 |
|
---|
| 861 | dprintf(("OSLibWinSetClientPos (%d,%d) (%d,%d) -> (%d,%d) (%d,%d)", x, y, x+cx, y+cy, swp.x, swp.y, swp.x+swp.cx, swp.y+swp.cy));
|
---|
| 862 |
|
---|
| 863 | rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
|
---|
| 864 | if(rc == FALSE) {
|
---|
| 865 | dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
|
---|
| 866 | }
|
---|
| 867 | }
|
---|
| 868 | //******************************************************************************
|
---|
| 869 | //******************************************************************************
|
---|
[3662] | 870 | BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
|
---|
[2469] | 871 | {
|
---|
| 872 | BOOL rc;
|
---|
| 873 |
|
---|
| 874 | WinMapWindowPoints(hwndFrame, HWND_DESKTOP, (PPOINTL)pRect, 2);
|
---|
| 875 |
|
---|
| 876 | rc = WinCalcFrameRect(hwndFrame, (PRECTL)pRect, fClient);
|
---|
| 877 | WinMapWindowPoints(HWND_DESKTOP, hwndFrame, (PPOINTL)pRect, 2);
|
---|
| 878 |
|
---|
| 879 | return rc;
|
---|
| 880 | }
|
---|
| 881 | //******************************************************************************
|
---|
| 882 | //******************************************************************************
|
---|
| 883 | BOOL OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax)
|
---|
| 884 | {
|
---|
| 885 | TRACKINFO tinfo;
|
---|
| 886 |
|
---|
| 887 | memset(&tinfo, 0, sizeof(TRACKINFO));
|
---|
| 888 | WinSendMsg(hwndFrame, WM_QUERYTRACKINFO, (MPARAM)0,(MPARAM)&tinfo);
|
---|
| 889 |
|
---|
| 890 | pMinMax->ptMinTrackSize.x = tinfo.ptlMinTrackSize.x;
|
---|
| 891 | pMinMax->ptMinTrackSize.y = tinfo.ptlMinTrackSize.y;
|
---|
| 892 | pMinMax->ptMaxTrackSize.x = tinfo.ptlMaxTrackSize.x;
|
---|
| 893 | pMinMax->ptMaxTrackSize.y = tinfo.ptlMaxTrackSize.y;
|
---|
| 894 | return TRUE;
|
---|
| 895 | }
|
---|
| 896 | //******************************************************************************
|
---|
| 897 | //******************************************************************************
|
---|
| 898 | HWND OSLibWinBeginEnumWindows(HWND hwnd)
|
---|
| 899 | {
|
---|
| 900 | if(hwnd == OSLIB_HWND_DESKTOP) hwnd = HWND_DESKTOP;
|
---|
| 901 | else
|
---|
| 902 | if(hwnd == OSLIB_HWND_OBJECT) hwnd = HWND_OBJECT;
|
---|
| 903 |
|
---|
| 904 | return WinBeginEnumWindows(hwnd);
|
---|
| 905 | }
|
---|
| 906 | //******************************************************************************
|
---|
| 907 | //******************************************************************************
|
---|
| 908 | HWND OSLibWinGetNextWindow(HWND hwndEnum)
|
---|
| 909 | {
|
---|
| 910 | return WinGetNextWindow(hwndEnum);
|
---|
| 911 | }
|
---|
| 912 | //******************************************************************************
|
---|
| 913 | //******************************************************************************
|
---|
| 914 | BOOL OSLibWinEndEnumWindows(HWND hwndEnum)
|
---|
| 915 | {
|
---|
| 916 | return WinEndEnumWindows(hwndEnum);
|
---|
| 917 | }
|
---|
| 918 | //******************************************************************************
|
---|
| 919 | //******************************************************************************
|
---|
| 920 | BOOL OSLibWinQueryWindowProcess(HWND hwnd, ULONG *pid, ULONG *tid)
|
---|
| 921 | {
|
---|
[8126] | 922 | BOOL ret;
|
---|
| 923 |
|
---|
| 924 | ret = WinQueryWindowProcess(hwnd, pid, tid);
|
---|
| 925 | *tid = MAKE_THREADID(*pid, *tid);
|
---|
| 926 | return ret;
|
---|
[2469] | 927 | }
|
---|
| 928 | //******************************************************************************
|
---|
| 929 | //******************************************************************************
|
---|
| 930 | BOOL OSLibWinMapWindowPoints (HWND hwndFrom, HWND hwndTo, OSLIBPOINT *pptl, ULONG num)
|
---|
| 931 | {
|
---|
| 932 | return WinMapWindowPoints (hwndFrom, hwndTo, (PPOINTL)pptl, num);
|
---|
| 933 | }
|
---|
| 934 | //******************************************************************************
|
---|
| 935 | //******************************************************************************
|
---|
| 936 | HWND OSLibWinQueryObjectWindow(VOID)
|
---|
| 937 | {
|
---|
| 938 | return WinQueryObjectWindow(HWND_DESKTOP);
|
---|
| 939 | }
|
---|
| 940 | //******************************************************************************
|
---|
| 941 | //******************************************************************************
|
---|
| 942 | HWND OSLibWinObjectWindowFromID(HWND hwndOwner, ULONG ID)
|
---|
| 943 | {
|
---|
| 944 | HWND hwndNext, hwndFound=0;
|
---|
| 945 | HENUM henum;
|
---|
| 946 |
|
---|
| 947 | henum = WinBeginEnumWindows(HWND_OBJECT);
|
---|
| 948 | while ((hwndNext = WinGetNextWindow(henum)) != 0)
|
---|
| 949 | {
|
---|
| 950 | if(WinQueryWindow(hwndNext, QW_OWNER) == hwndOwner &&
|
---|
| 951 | WinQueryWindowUShort(hwndNext, QWS_ID) == ID)
|
---|
| 952 | {
|
---|
| 953 | hwndFound = hwndNext;
|
---|
| 954 | break;
|
---|
| 955 | }
|
---|
| 956 | }
|
---|
| 957 | WinEndEnumWindows(henum);
|
---|
| 958 | return hwndFound;
|
---|
| 959 | }
|
---|
| 960 | //******************************************************************************
|
---|
| 961 | //******************************************************************************
|
---|
| 962 | BOOL OSLibSetWindowID(HWND hwnd, ULONG value)
|
---|
| 963 | {
|
---|
| 964 | dprintf(("OSLibSetWindowID hwnd:%x ID:%x", hwnd, value));
|
---|
| 965 | return WinSetWindowULong(hwnd, QWS_ID, value);
|
---|
| 966 | }
|
---|
| 967 | //******************************************************************************
|
---|
| 968 | //******************************************************************************
|
---|
| 969 | PVOID OSLibWinSubclassWindow(HWND hwnd,PVOID newWndProc)
|
---|
| 970 | {
|
---|
[21916] | 971 | return (PVOID)WinSubclassWindow(hwnd,(PFNWP)newWndProc);
|
---|
[2469] | 972 | }
|
---|
| 973 | //******************************************************************************
|
---|
| 974 | //******************************************************************************
|
---|
| 975 | BOOL OSLibSetWindowRestoreRect(HWND hwnd, PRECT pRect)
|
---|
| 976 | {
|
---|
| 977 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 978 |
|
---|
| 979 | WinSetWindowUShort(hwnd, QWS_XRESTORE, (USHORT)pRect->left );
|
---|
| 980 | WinSetWindowUShort(hwnd, QWS_YRESTORE, (USHORT)(yHeight - pRect->top -
|
---|
| 981 | (pRect->bottom - pRect->top)));
|
---|
| 982 | WinSetWindowUShort(hwnd, QWS_CXRESTORE, (USHORT)(pRect->right - pRect->left));
|
---|
| 983 | WinSetWindowUShort(hwnd, QWS_CYRESTORE, (USHORT)(pRect->bottom - pRect->top));
|
---|
| 984 | return TRUE;
|
---|
| 985 | }
|
---|
| 986 | //******************************************************************************
|
---|
| 987 | //******************************************************************************
|
---|
| 988 | BOOL OSLibSetWindowMinPos(HWND hwnd, ULONG x, ULONG y)
|
---|
| 989 | {
|
---|
| 990 | ULONG yHeight = OSLibGetWindowHeight(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 991 |
|
---|
| 992 | WinSetWindowUShort(hwnd, QWS_XMINIMIZE, (USHORT)x );
|
---|
| 993 | WinSetWindowUShort(hwnd, QWS_YMINIMIZE, (USHORT)(yHeight - y -
|
---|
| 994 | ( 2 * WinQuerySysValue( HWND_DESKTOP, SV_CYSIZEBORDER)) -
|
---|
| 995 | WinQuerySysValue( HWND_DESKTOP, SV_CYICON)));
|
---|
| 996 | return TRUE;
|
---|
| 997 | }
|
---|
| 998 | //******************************************************************************
|
---|
| 999 | //******************************************************************************
|
---|
[5721] | 1000 | BOOL OSLibWinEnableWindowUpdate(HWND hwndFrame, HWND hwndClient ,BOOL fEnable)
|
---|
[2469] | 1001 | {
|
---|
[5721] | 1002 | WinEnableWindowUpdate(hwndFrame, fEnable);
|
---|
| 1003 | return WinEnableWindowUpdate(hwndClient, fEnable);
|
---|
[2469] | 1004 | }
|
---|
| 1005 | //******************************************************************************
|
---|
| 1006 | //******************************************************************************
|
---|
| 1007 | ULONG OSLibWinGetLastError()
|
---|
| 1008 | {
|
---|
| 1009 | return WinGetLastError(GetThreadHAB()) & 0xFFFF;
|
---|
| 1010 | }
|
---|
| 1011 | //******************************************************************************
|
---|
| 1012 | //******************************************************************************
|
---|
| 1013 | void OSLibWinShowTaskList(HWND hwndFrame)
|
---|
| 1014 | {
|
---|
[8853] | 1015 | SWBLOCK swblk;
|
---|
| 1016 | // the first entry returned is always the window list itself
|
---|
| 1017 | if (WinQuerySwitchList(0, &swblk, sizeof(SWBLOCK)) > 0)
|
---|
[9345] | 1018 | WinSetActiveWindow(HWND_DESKTOP, swblk.aswentry[0].swctl.hwnd);
|
---|
| 1019 | // WinShowWindow(swblk.aswentry[0].swctl.hwnd, TRUE);
|
---|
[2469] | 1020 | }
|
---|
| 1021 | //******************************************************************************
|
---|
| 1022 | //******************************************************************************
|
---|
[9866] | 1023 | //PF: PM Logic approved by numerous testcases shows this:
|
---|
| 1024 | //There is no other way to tweak FID_MINMAX without deleting it
|
---|
[10031] | 1025 | //Controls are created with size 0,0, invisible and should be immediately
|
---|
[9866] | 1026 | //positioned. MINMAX control can't function properly without FID_SYSMENU
|
---|
| 1027 | //control if it is present, so we need to recreate BOTH controls.
|
---|
| 1028 | //Currently OSLibSetWindowStyle checks for changes and actually do the job
|
---|
| 1029 | //only when it is needed so no additional messages are generated.
|
---|
| 1030 | //TO-DO: There MAY BE some regressions here but I haven't seen them
|
---|
| 1031 | //and yes this code is the only way to do WinCreateFrame controls,
|
---|
| 1032 | //first delete old then create new - all other variants create new and
|
---|
| 1033 | //leave old, WinCreateFrameControls can't tweak anything.
|
---|
| 1034 |
|
---|
[10031] | 1035 | void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle,
|
---|
[9866] | 1036 | ULONG dwExStyle, ULONG dwOldWindowsStyle)
|
---|
[2657] | 1037 | {
|
---|
[5685] | 1038 | ULONG dwWinStyle;
|
---|
| 1039 | ULONG dwOldWinStyle;
|
---|
[2657] | 1040 |
|
---|
[10031] | 1041 | int checksum, checksum2;
|
---|
[9866] | 1042 | DWORD dest_tid, dest_pid;
|
---|
[2657] | 1043 |
|
---|
[9866] | 1044 | static int minmaxwidth = 0;
|
---|
| 1045 | static int minmaxheight = 0;
|
---|
| 1046 |
|
---|
| 1047 |
|
---|
| 1048 | //PF We can tweak OS/2 controls ONLY from thread that created them
|
---|
| 1049 | //in other case heavy PM lockups will follow
|
---|
| 1050 |
|
---|
| 1051 | dest_tid = GetWindowThreadProcessId(OS2ToWin32Handle(hwndClient) , &dest_pid );
|
---|
| 1052 |
|
---|
[10031] | 1053 | if (dest_tid != GetCurrentThreadId())
|
---|
[9866] | 1054 | {
|
---|
| 1055 | dprintf(("OSLibSetWindowStyle: Redirecting Change Frame controls to another thread"));
|
---|
| 1056 | WinSendMsg(hwndFrame, WIN32APP_CHNGEFRAMECTRLS, (MPARAM)dwStyle, (MPARAM)dwOldWindowsStyle);
|
---|
| 1057 | return;
|
---|
[5685] | 1058 | }
|
---|
[9866] | 1059 | if(minmaxwidth == 0) {
|
---|
| 1060 | minmaxwidth = WinQuerySysValue(HWND_DESKTOP, SV_CXMINMAXBUTTON);
|
---|
| 1061 | minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
|
---|
| 1062 | }
|
---|
[10031] | 1063 |
|
---|
[9866] | 1064 | if (hwndClient)
|
---|
| 1065 | {
|
---|
| 1066 | //client window:
|
---|
| 1067 | dwWinStyle = WinQueryWindowULong(hwndClient, QWL_STYLE);
|
---|
| 1068 | dwOldWinStyle = dwWinStyle;
|
---|
[2657] | 1069 |
|
---|
[9866] | 1070 | if(dwStyle & WS_CLIPCHILDREN_W) {
|
---|
| 1071 | dwWinStyle |= WS_CLIPCHILDREN;
|
---|
| 1072 | }
|
---|
| 1073 | else dwWinStyle &= ~WS_CLIPCHILDREN;
|
---|
| 1074 |
|
---|
| 1075 | if(dwWinStyle != dwOldWinStyle) {
|
---|
| 1076 | WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
|
---|
| 1077 | }
|
---|
[5685] | 1078 | }
|
---|
[5512] | 1079 |
|
---|
[5685] | 1080 | //Frame window
|
---|
| 1081 | dwWinStyle = WinQueryWindowULong(hwndFrame, QWL_STYLE);
|
---|
| 1082 | dwOldWinStyle = dwWinStyle;
|
---|
[9866] | 1083 |
|
---|
| 1084 | checksum = (dwOldWindowsStyle & WS_MINIMIZEBOX_W) + (dwOldWindowsStyle & WS_MAXIMIZEBOX_W) + (dwOldWindowsStyle & WS_SYSMENU_W);
|
---|
| 1085 | checksum2 = (dwStyle & WS_MINIMIZEBOX_W) + (dwStyle & WS_MAXIMIZEBOX_W) + (dwStyle & WS_SYSMENU_W);
|
---|
| 1086 |
|
---|
[5685] | 1087 | if(dwStyle & WS_DISABLED_W) {
|
---|
| 1088 | dwWinStyle |= WS_DISABLED;
|
---|
| 1089 | }
|
---|
| 1090 | else dwWinStyle &= ~WS_DISABLED;
|
---|
| 1091 |
|
---|
[10549] | 1092 | if(!(dwStyle & WS_CHILD_W) && dwExStyle & WS_EX_TOPMOST_W) {
|
---|
[9143] | 1093 | dwWinStyle |= WS_TOPMOST;
|
---|
| 1094 | }
|
---|
| 1095 | else dwWinStyle &= ~WS_TOPMOST;
|
---|
| 1096 |
|
---|
[5685] | 1097 | if(dwStyle & WS_CLIPSIBLINGS_W) {
|
---|
| 1098 | dwWinStyle |= WS_CLIPSIBLINGS;
|
---|
| 1099 | }
|
---|
| 1100 | else dwWinStyle &= ~WS_CLIPSIBLINGS;
|
---|
| 1101 |
|
---|
[5777] | 1102 | if(dwStyle & WS_MINIMIZE_W) {
|
---|
| 1103 | dwWinStyle |= WS_MINIMIZED;
|
---|
| 1104 | }
|
---|
| 1105 | else dwWinStyle &= ~WS_MINIMIZED;
|
---|
| 1106 |
|
---|
[6008] | 1107 | if(dwStyle & WS_MAXIMIZE_W) {
|
---|
| 1108 | dwWinStyle |= WS_MAXIMIZED;
|
---|
| 1109 | }
|
---|
[10031] | 1110 | else
|
---|
[9866] | 1111 | dwWinStyle &= ~WS_MAXIMIZED;
|
---|
[6008] | 1112 |
|
---|
[10013] | 1113 | //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
|
---|
| 1114 | if(fOS2Look && !(dwExStyle & WS_EX_TOOLWINDOW_W)) {
|
---|
[6019] | 1115 | ULONG OSFrameStyle = 0;
|
---|
[9866] | 1116 | SWP rc1,rc2,rc3;
|
---|
| 1117 | int totalwidth = 0;
|
---|
| 1118 |
|
---|
[9076] | 1119 | if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W)
|
---|
| 1120 | {
|
---|
[6019] | 1121 | if(WinWindowFromID(hwndFrame, FID_TITLEBAR) == 0) {
|
---|
| 1122 | OSFrameStyle = FCF_TITLEBAR;
|
---|
| 1123 | }
|
---|
[9866] | 1124 | else
|
---|
[10031] | 1125 | WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR), &rc1);
|
---|
[9866] | 1126 |
|
---|
[6019] | 1127 | if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
|
---|
| 1128 | {
|
---|
[9866] | 1129 | if(WinWindowFromID(hwndFrame, FID_SYSMENU) == 0)
|
---|
| 1130 | OSFrameStyle |= FCF_SYSMENU;
|
---|
[6019] | 1131 | }
|
---|
[9866] | 1132 | WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU), &rc2);
|
---|
| 1133 | WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX), &rc3);
|
---|
[9076] | 1134 |
|
---|
[9866] | 1135 | if (checksum != checksum2)
|
---|
[9578] | 1136 | {
|
---|
[9866] | 1137 | dprintf(("OSLibSetWindowStyle: Min/Max/Close state changed. Creating:"));
|
---|
| 1138 | if(dwStyle & WS_MINIMIZEBOX_W)
|
---|
| 1139 | {
|
---|
| 1140 | OSFrameStyle |= FCF_MINBUTTON;
|
---|
| 1141 | totalwidth += minmaxwidth/2;
|
---|
| 1142 | dprintf(("min button"));
|
---|
| 1143 | }
|
---|
[9076] | 1144 |
|
---|
[9866] | 1145 | if(dwStyle & WS_MAXIMIZEBOX_W)
|
---|
| 1146 | {
|
---|
| 1147 | OSFrameStyle |= FCF_MAXBUTTON;
|
---|
| 1148 | totalwidth += minmaxwidth/2;
|
---|
| 1149 | dprintf(("max button"));
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | if(dwStyle & WS_SYSMENU_W)
|
---|
| 1153 | {
|
---|
| 1154 | OSFrameStyle |= FCF_CLOSEBUTTON;
|
---|
[10031] | 1155 | OSFrameStyle |= FCF_SYSMENU;
|
---|
[9866] | 1156 | totalwidth += minmaxwidth/2;
|
---|
| 1157 | dprintf(("close button"));
|
---|
| 1158 | }
|
---|
[6019] | 1159 | }
|
---|
[9076] | 1160 | }
|
---|
[10031] | 1161 | else
|
---|
[9076] | 1162 | {
|
---|
[10031] | 1163 | if (WinWindowFromID(hwndFrame, FID_TITLEBAR))
|
---|
[9076] | 1164 | WinDestroyWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR));
|
---|
| 1165 | }
|
---|
[9866] | 1166 |
|
---|
| 1167 | if (checksum != checksum2)
|
---|
| 1168 | {
|
---|
[10031] | 1169 | if (WinWindowFromID(hwndFrame, FID_SYSMENU))
|
---|
[9866] | 1170 | WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU));
|
---|
[10031] | 1171 | if (WinWindowFromID(hwndFrame, FID_MINMAX))
|
---|
[9866] | 1172 | WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX));
|
---|
| 1173 | }
|
---|
| 1174 |
|
---|
[9076] | 1175 | if(OSFrameStyle) {
|
---|
[6019] | 1176 | FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
|
---|
[9076] | 1177 | char buffer[255];
|
---|
[9866] | 1178 | dprintf(("Controls will be created %x",OSFrameStyle));
|
---|
[9076] | 1179 | FCData.flCreateFlags = OSFrameStyle;
|
---|
[6019] | 1180 |
|
---|
[9076] | 1181 | GetWindowTextA(OS2ToWin32Handle(hwndClient), buffer, sizeof(buffer));
|
---|
| 1182 | WinCreateFrameControls(hwndFrame, &FCData, buffer );
|
---|
[10031] | 1183 |
|
---|
[9866] | 1184 | if (totalwidth != rc3.cx)
|
---|
| 1185 | {
|
---|
| 1186 | rc3.cx = totalwidth;
|
---|
| 1187 | totalwidth = rc3.cx - totalwidth;
|
---|
| 1188 | rc1.cx = rc1.cx + totalwidth;
|
---|
| 1189 | rc3.x = rc3.x + totalwidth;
|
---|
| 1190 | }
|
---|
[9076] | 1191 |
|
---|
[10031] | 1192 | WinSetWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX),0,rc3.x,rc3.y,rc3.cx,rc3.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
|
---|
| 1193 | WinSetWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU),0,rc2.x,rc2.y,rc2.cx,rc2.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
|
---|
| 1194 | WinSetWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR),0,rc1.x,rc1.y,rc1.cx,rc1.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
|
---|
| 1195 |
|
---|
[9076] | 1196 | if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame)
|
---|
| 1197 | WinSendMsg(WinWindowFromID(hwndFrame, FID_TITLEBAR), TBM_SETHILITE, (MPARAM)1, 0);
|
---|
[9345] | 1198 |
|
---|
[9076] | 1199 | }
|
---|
| 1200 | } // os2look
|
---|
[9866] | 1201 |
|
---|
| 1202 | if(dwWinStyle != dwOldWinStyle) {
|
---|
[10013] | 1203 | dprintf(("Setting new window U long"));
|
---|
| 1204 | WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
|
---|
[9866] | 1205 | }
|
---|
| 1206 |
|
---|
[2657] | 1207 | }
|
---|
| 1208 | //******************************************************************************
|
---|
| 1209 | //******************************************************************************
|
---|
[9345] | 1210 | BOOL OSLibChangeCloseButtonState(HWND hwndFrame, BOOL State)
|
---|
| 1211 | {
|
---|
[9563] | 1212 | dprintf(("OSLibChangeCloseButtonState %x %d", hwndFrame, State));
|
---|
[9345] | 1213 | return WinEnableMenuItem(WinWindowFromID(hwndFrame, FID_SYSMENU), SC_CLOSE, State);
|
---|
| 1214 | }
|
---|
| 1215 | //******************************************************************************
|
---|
| 1216 | //******************************************************************************
|
---|
[3581] | 1217 | DWORD OSLibQueryWindowStyle(HWND hwnd)
|
---|
| 1218 | {
|
---|
[5685] | 1219 | return WinQueryWindowULong(hwnd, QWL_STYLE);
|
---|
[3581] | 1220 | }
|
---|
| 1221 | //******************************************************************************
|
---|
| 1222 | //******************************************************************************
|
---|
[3364] | 1223 | void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
|
---|
| 1224 | {
|
---|
[5685] | 1225 | WinSetVisibleRegionNotify(hwnd, fNotify);
|
---|
[3364] | 1226 | }
|
---|
| 1227 | //******************************************************************************
|
---|
| 1228 | //******************************************************************************
|
---|
[3488] | 1229 | HWND OSLibWinQueryCapture()
|
---|
| 1230 | {
|
---|
[5685] | 1231 | return WinQueryCapture(HWND_DESKTOP);
|
---|
[3488] | 1232 | }
|
---|
| 1233 | //******************************************************************************
|
---|
| 1234 | //******************************************************************************
|
---|
| 1235 | BOOL OSLibWinSetCapture(HWND hwnd)
|
---|
| 1236 | {
|
---|
[5685] | 1237 | return WinSetCapture(HWND_DESKTOP, hwnd);
|
---|
[3488] | 1238 | }
|
---|
| 1239 | //******************************************************************************
|
---|
| 1240 | //******************************************************************************
|
---|
[3610] | 1241 | BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
|
---|
| 1242 | {
|
---|
[9598] | 1243 | dprintf(("OSLibWinRemoveFromTasklist %x", hTaskList));
|
---|
[5685] | 1244 | return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
|
---|
[3610] | 1245 | }
|
---|
| 1246 | //******************************************************************************
|
---|
| 1247 | //******************************************************************************
|
---|
| 1248 | HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
|
---|
| 1249 | {
|
---|
[5685] | 1250 | SWCNTRL swctrl;
|
---|
| 1251 | ULONG tid;
|
---|
[3610] | 1252 |
|
---|
[5685] | 1253 | swctrl.hwnd = hwndFrame;
|
---|
| 1254 | swctrl.hwndIcon = 0;
|
---|
| 1255 | swctrl.hprog = 0;
|
---|
| 1256 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
|
---|
| 1257 | swctrl.idSession = 0;
|
---|
| 1258 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
|
---|
| 1259 | swctrl.fbJump = SWL_JUMPABLE;
|
---|
| 1260 | swctrl.bProgType = PROG_PM;
|
---|
| 1261 | if(title) {
|
---|
[9077] | 1262 | CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
|
---|
[5685] | 1263 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
|
---|
| 1264 | }
|
---|
| 1265 | else {
|
---|
| 1266 | swctrl.szSwtitle[0] = 0;
|
---|
| 1267 | swctrl.uchVisibility = SWL_INVISIBLE;
|
---|
| 1268 | }
|
---|
[9598] | 1269 | HANDLE hTaskList = WinAddSwitchEntry(&swctrl);
|
---|
| 1270 | dprintf(("OSLibWinAddToTaskList %s %x", swctrl.szSwtitle, hTaskList));
|
---|
| 1271 | return hTaskList;
|
---|
[3610] | 1272 | }
|
---|
| 1273 | //******************************************************************************
|
---|
| 1274 | //******************************************************************************
|
---|
| 1275 | BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
|
---|
| 1276 | {
|
---|
[5685] | 1277 | SWCNTRL swctrl;
|
---|
| 1278 | ULONG tid;
|
---|
| 1279 |
|
---|
| 1280 | swctrl.hwnd = hwndFrame;
|
---|
| 1281 | swctrl.hwndIcon = 0;
|
---|
| 1282 | swctrl.hprog = 0;
|
---|
| 1283 | WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
|
---|
| 1284 | swctrl.idSession = 0;
|
---|
| 1285 | swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
|
---|
| 1286 | swctrl.fbJump = SWL_JUMPABLE;
|
---|
| 1287 | swctrl.bProgType = PROG_PM;
|
---|
[9694] | 1288 | dprintf(("OSLibWinChangeTaskList %x %s swctrl %x size %d", hTaskList, title, &swctrl, sizeof(swctrl)));
|
---|
[5685] | 1289 | if(title) {
|
---|
[9077] | 1290 | CharToOemBuffA( title, swctrl.szSwtitle, min(strlen(title)+1,MAXNAMEL+4) );
|
---|
[5685] | 1291 | swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
|
---|
| 1292 | }
|
---|
| 1293 | else {
|
---|
| 1294 | swctrl.szSwtitle[0] = 0;
|
---|
| 1295 | swctrl.uchVisibility = SWL_INVISIBLE;
|
---|
| 1296 | }
|
---|
[9694] | 1297 | dprintf(("hwnd %x", swctrl.hwnd));
|
---|
| 1298 | dprintf(("hwndIcon %x", swctrl.hwndIcon));
|
---|
| 1299 | dprintf(("hprog %x", swctrl.hprog));
|
---|
| 1300 | dprintf(("idProcess %x", swctrl.idProcess));
|
---|
| 1301 | dprintf(("idSession %x", swctrl.idSession));
|
---|
| 1302 | dprintf(("uchVisibility %x", swctrl.uchVisibility));
|
---|
| 1303 | dprintf(("fbJump %x", swctrl.fbJump));
|
---|
| 1304 | dprintf(("bProgType %x", swctrl.bProgType));
|
---|
| 1305 | dprintf(("szSwtitle %s", swctrl.szSwtitle));
|
---|
| 1306 |
|
---|
[5685] | 1307 | return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
|
---|
[3610] | 1308 | }
|
---|
| 1309 | //******************************************************************************
|
---|
| 1310 | //******************************************************************************
|
---|
[5191] | 1311 | BOOL OSLibWinLockWindowUpdate(HWND hwnd)
|
---|
| 1312 | {
|
---|
[5685] | 1313 | return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
|
---|
[5191] | 1314 | }
|
---|
| 1315 | //******************************************************************************
|
---|
| 1316 | //******************************************************************************
|
---|
[3705] | 1317 | ULONG OSLibGetScreenHeight()
|
---|
| 1318 | {
|
---|
[5685] | 1319 | return ScreenHeight;
|
---|
[3705] | 1320 | }
|
---|
| 1321 | //******************************************************************************
|
---|
| 1322 | //******************************************************************************
|
---|
| 1323 | ULONG OSLibGetScreenWidth()
|
---|
| 1324 | {
|
---|
[5685] | 1325 | return ScreenWidth;
|
---|
[3705] | 1326 | }
|
---|
| 1327 | //******************************************************************************
|
---|
[5215] | 1328 | //Returns the maximum position for a window
|
---|
| 1329 | //Should only be used from toplevel windows
|
---|
[3705] | 1330 | //******************************************************************************
|
---|
[5215] | 1331 | BOOL OSLibWinGetMaxPosition(HWND hwndOS2, RECT *rect)
|
---|
| 1332 | {
|
---|
| 1333 | SWP swp;
|
---|
[5685] | 1334 |
|
---|
| 1335 | if(!WinGetMaxPosition(hwndOS2, &swp)) {
|
---|
| 1336 | dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
|
---|
| 1337 | return FALSE;
|
---|
| 1338 | }
|
---|
| 1339 | rect->left = swp.x;
|
---|
| 1340 | rect->right = swp.x + swp.cx;
|
---|
| 1341 | rect->top = ScreenHeight - (swp.y + swp.cy);
|
---|
| 1342 | rect->bottom = ScreenHeight - swp.y;
|
---|
| 1343 | return TRUE;
|
---|
[5215] | 1344 | }
|
---|
| 1345 | //******************************************************************************
|
---|
| 1346 | //******************************************************************************
|
---|
[5482] | 1347 | BOOL OSLibWinShowPointer(BOOL fShow)
|
---|
| 1348 | {
|
---|
[5685] | 1349 | return WinShowPointer(HWND_DESKTOP, fShow);
|
---|
[5482] | 1350 | }
|
---|
| 1351 | //******************************************************************************
|
---|
| 1352 | //******************************************************************************
|
---|
[7500] | 1353 | ULONG OSLibWinQuerySysColor(int index)
|
---|
| 1354 | {
|
---|
| 1355 | return CONVERT_RGB(WinQuerySysColor(HWND_DESKTOP, index, 0));
|
---|
| 1356 | }
|
---|
| 1357 | //******************************************************************************
|
---|
[9230] | 1358 | //PF This was added for IBM Wheel Mouse driver - it searches for scrollbars and
|
---|
| 1359 | //only if they exist sends WM_VSCROLL messages to the window
|
---|
[7500] | 1360 | //******************************************************************************
|
---|
[9230] | 1361 | HWND OSLibWinCreateInvisibleScroller(HWND parentHWND, int direction)
|
---|
| 1362 | {
|
---|
| 1363 | return WinCreateWindow(parentHWND, WC_SCROLLBAR, NULL, direction,
|
---|
| 1364 | 0, 0, 0, 0, parentHWND, HWND_BOTTOM, 1, NULL, NULL);
|
---|
| 1365 | }
|
---|
| 1366 | //******************************************************************************
|
---|
| 1367 | //******************************************************************************
|
---|
[9943] | 1368 | void OSLibWinLockVisibleRegions(BOOL fLock)
|
---|
| 1369 | {
|
---|
| 1370 | WinLockVisRegions(HWND_DESKTOP, fLock);
|
---|
| 1371 | }
|
---|
| 1372 | //******************************************************************************
|
---|
| 1373 | //******************************************************************************
|
---|
[10031] | 1374 |
|
---|
| 1375 | /* 'Private' PM property stuff. */
|
---|
| 1376 | PVOID APIENTRY WinQueryProperty(HWND hwnd, PCSZ pszNameOrAtom);
|
---|
| 1377 | PVOID APIENTRY WinRemoveProperty(HWND hwnd, PCSZ pszNameOrAtom);
|
---|
| 1378 | BOOL APIENTRY WinSetProperty(HWND hwnd, PCSZ pszNameOrAtom, PVOID pvData, ULONG ulFlags);
|
---|
| 1379 |
|
---|
| 1380 | /**
|
---|
| 1381 | * Set Property.
|
---|
| 1382 | * @returns Success indicator.
|
---|
| 1383 | * @param hwnd Window the property is associated with.
|
---|
| 1384 | * @param psz The property atom or name.
|
---|
| 1385 | * @param pv Property value.
|
---|
| 1386 | * @param fFlags Flags. Use 0.
|
---|
| 1387 | */
|
---|
| 1388 | BOOL OSLibSetProperty(HWND hwnd, const char *psz, void *pv, unsigned fFlags)
|
---|
| 1389 | {
|
---|
| 1390 | USHORT selFS = RestoreOS2FS();
|
---|
| 1391 | BOOL fRet = WinSetProperty(hwnd, psz, pv, fFlags);
|
---|
| 1392 | SetFS(selFS);
|
---|
| 1393 | return fRet;
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | /**
|
---|
| 1397 | * Get Property.
|
---|
| 1398 | * @returns Property value.
|
---|
| 1399 | * @param hwnd Window the property is associated with.
|
---|
| 1400 | * @param psz The property atom or name.
|
---|
| 1401 | */
|
---|
| 1402 | void * OSLibQueryProperty(HWND hwnd, const char *psz)
|
---|
| 1403 | {
|
---|
| 1404 | USHORT selFS = RestoreOS2FS();
|
---|
| 1405 | void *pvRet = WinQueryProperty(hwnd, psz);
|
---|
| 1406 | SetFS(selFS);
|
---|
| 1407 | return pvRet;
|
---|
| 1408 | }
|
---|
| 1409 |
|
---|
| 1410 | /**
|
---|
| 1411 | * Remove Property.
|
---|
| 1412 | * @returns Property value.
|
---|
| 1413 | * @param hwnd Window the property is associated with.
|
---|
| 1414 | * @param psz The property atom or name.
|
---|
| 1415 | */
|
---|
| 1416 | void * OSLibRemoveProperty(HWND hwnd, const char *psz)
|
---|
| 1417 | {
|
---|
| 1418 | USHORT selFS = RestoreOS2FS();
|
---|
| 1419 | void *pvRet = WinRemoveProperty(hwnd, psz);
|
---|
| 1420 | SetFS(selFS);
|
---|
| 1421 | return pvRet;
|
---|
| 1422 | }
|
---|
| 1423 |
|
---|