1 | /* $Id: win32wbase.cpp,v 1.387 2004-03-16 13:56:12 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window Base Class for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1998-2002 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
7 | * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch)
|
---|
8 | *
|
---|
9 | * Parts based on Wine Windows code (windows\win.c)
|
---|
10 | * Corel version: corel20000212
|
---|
11 | *
|
---|
12 | * Copyright 1993, 1994, 1996 Alexandre Julliard
|
---|
13 | * 1995 Alex Korobka
|
---|
14 | *
|
---|
15 | * TODO: Not thread/process safe
|
---|
16 | *
|
---|
17 | * NOTE: To access a window object, you must call GetWindowFromOS2Handle or
|
---|
18 | * GetWindowFromHandle. Both these methods increase the reference count
|
---|
19 | * of the object. When you're done with the object, you MUST call
|
---|
20 | * the release method!
|
---|
21 | * This mechanism prevents premature destruction of objects when there
|
---|
22 | * are still clients using it.
|
---|
23 | *
|
---|
24 | * NOTE: Client rectangle always relative to frame window
|
---|
25 | * Window rectangle in parent coordinates (relative to parent's client window)
|
---|
26 | * (screen coord. if no parent)
|
---|
27 | *
|
---|
28 | * NOTE: Status of window:
|
---|
29 | * Before a window has processed WM_NCCREATE:
|
---|
30 | * - GetTopWindow can't return that window handle
|
---|
31 | * - GetWindow(parent, GW_CHILD) can't return that window handle
|
---|
32 | * - IsChild works
|
---|
33 | * TODO: Does this affect more functions?? (other GetWindow ops)
|
---|
34 | * (verified in NT4, SP6)
|
---|
35 | *
|
---|
36 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
37 | *
|
---|
38 | */
|
---|
39 | #include <os2win.h>
|
---|
40 | #include <win.h>
|
---|
41 | #include <stdlib.h>
|
---|
42 | #include <string.h>
|
---|
43 | #include <stdarg.h>
|
---|
44 | #include <assert.h>
|
---|
45 | #include <misc.h>
|
---|
46 | #include <heapstring.h>
|
---|
47 | #include <winuser32.h>
|
---|
48 | #include <custombuild.h>
|
---|
49 | #include "win32wbase.h"
|
---|
50 | #include "win32wfake.h"
|
---|
51 | #include "wndmsg.h"
|
---|
52 | #include "oslibwin.h"
|
---|
53 | #include "oslibmsg.h"
|
---|
54 | #include "oslibutil.h"
|
---|
55 | #include "oslibgdi.h"
|
---|
56 | #include "oslibres.h"
|
---|
57 | #include "oslibdos.h"
|
---|
58 | #include "syscolor.h"
|
---|
59 | #include "win32wndhandle.h"
|
---|
60 | #include "dc.h"
|
---|
61 | #include "win32wdesktop.h"
|
---|
62 | #include "pmwindow.h"
|
---|
63 | #include "controls.h"
|
---|
64 | #include <wprocess.h>
|
---|
65 | #include <win\hook.h>
|
---|
66 | #include <menu.h>
|
---|
67 | #define INCL_TIMERWIN32
|
---|
68 | #include "timer.h"
|
---|
69 | #include "user32api.h"
|
---|
70 | #include "callwrap.h"
|
---|
71 |
|
---|
72 | #define DBG_LOCALLOG DBG_win32wbase
|
---|
73 | #include "dbglocal.h"
|
---|
74 |
|
---|
75 | /* bits in the dwKeyData */
|
---|
76 | #define KEYDATA_ALT 0x2000
|
---|
77 | #define KEYDATA_PREVSTATE 0x4000
|
---|
78 |
|
---|
79 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
|
---|
80 |
|
---|
81 | static fDestroyAll = FALSE;
|
---|
82 | //For quick lookup of current process id
|
---|
83 | static ULONG currentProcessId = -1;
|
---|
84 | static int iF10Key = 0;
|
---|
85 | static int iMenuSysKey = 0;
|
---|
86 |
|
---|
87 | //******************************************************************************
|
---|
88 | //******************************************************************************
|
---|
89 | Win32BaseWindow::Win32BaseWindow()
|
---|
90 | : GenericObject(&windows, &critsect), ChildWindow(&critsect)
|
---|
91 | {
|
---|
92 | Init();
|
---|
93 | }
|
---|
94 | //******************************************************************************
|
---|
95 | //******************************************************************************
|
---|
96 | Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
|
---|
97 | : GenericObject(&windows, &critsect), ChildWindow(&critsect)
|
---|
98 | {
|
---|
99 | Init();
|
---|
100 | this->isUnicode = isUnicode;
|
---|
101 | // call member function
|
---|
102 | CreateWindowExA(lpCreateStructA, classAtom);
|
---|
103 | }
|
---|
104 | //******************************************************************************
|
---|
105 | //******************************************************************************
|
---|
106 | void Win32BaseWindow::Init()
|
---|
107 | {
|
---|
108 | isUnicode = FALSE;
|
---|
109 | fFirstShow = TRUE;
|
---|
110 | fIsDialog = FALSE;
|
---|
111 | fIsModalDialogOwner = FALSE;
|
---|
112 | OS2HwndModalDialog = 0;
|
---|
113 | fParentChange = FALSE;
|
---|
114 | fDestroyWindowCalled = FALSE;
|
---|
115 | fChildDestructionInProgress = FALSE;
|
---|
116 | fTaskList = FALSE;
|
---|
117 | fParentDC = FALSE;
|
---|
118 | fComingToTop = FALSE;
|
---|
119 | fMinMaxChange = FALSE;
|
---|
120 | fPMUpdateRegionChanged = FALSE;
|
---|
121 | fEraseBkgndFlag = TRUE;
|
---|
122 | fIsDragDropActive= FALSE;
|
---|
123 | fDirtyUpdateRegion = FALSE;
|
---|
124 | fWindowLocked = FALSE;
|
---|
125 |
|
---|
126 | state = STATE_INIT;
|
---|
127 | windowNameA = NULL;
|
---|
128 | windowNameW = NULL;
|
---|
129 | windowNameLengthA = 0;
|
---|
130 | windowNameLengthW = 0;
|
---|
131 |
|
---|
132 | userWindowBytes = NULL;;
|
---|
133 | nrUserWindowBytes= 0;
|
---|
134 |
|
---|
135 | OS2Hwnd = 0;
|
---|
136 | OS2HwndFrame = 0;
|
---|
137 | hSysMenu = 0;
|
---|
138 | Win32Hwnd = 0;
|
---|
139 |
|
---|
140 | // allocate a Win32 HWND, return it in Win32Hwnd and associate object
|
---|
141 | // pointer with it
|
---|
142 | if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
|
---|
143 | {
|
---|
144 | dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
|
---|
145 | DebugInt3();
|
---|
146 | }
|
---|
147 | Win32HwndOrg = Win32Hwnd;
|
---|
148 |
|
---|
149 | posx = posy = 0;
|
---|
150 | width = height = 0;
|
---|
151 |
|
---|
152 | dwExStyle = 0;
|
---|
153 | dwStyle = 0;
|
---|
154 | dwOldStyle = 0;
|
---|
155 | win32wndproc = 0;
|
---|
156 | hInstance = 0;
|
---|
157 | dwIDMenu = 0; //0xFFFFFFFF; //default -1
|
---|
158 | userData = 0;
|
---|
159 | contextHelpId = 0;
|
---|
160 | hotkey = 0;
|
---|
161 |
|
---|
162 | hwndLinkAfter = HWND_BOTTOM;
|
---|
163 | flags = 0;
|
---|
164 | lastHitTestVal = HTCLIENT;
|
---|
165 | owner = NULL;
|
---|
166 | windowClass = 0;
|
---|
167 |
|
---|
168 | hIcon = 0;
|
---|
169 | hIconSm = 0;
|
---|
170 |
|
---|
171 | horzScrollInfo = NULL;
|
---|
172 | vertScrollInfo = NULL;
|
---|
173 |
|
---|
174 | propertyList = NULL;
|
---|
175 |
|
---|
176 | cbExtra = 0;
|
---|
177 | pExtra = NULL;
|
---|
178 |
|
---|
179 | ownDC = 0;
|
---|
180 | hWindowRegion = 0;
|
---|
181 | hClipRegion = 0;
|
---|
182 | hVisRegion = 0;
|
---|
183 | hUpdateRegion = 0;
|
---|
184 |
|
---|
185 | hTaskList = 0;
|
---|
186 |
|
---|
187 | if(currentProcessId == -1)
|
---|
188 | {
|
---|
189 | currentProcessId = GetCurrentProcessId();
|
---|
190 | }
|
---|
191 | dwThreadId = GetCurrentThreadId();
|
---|
192 | dwProcessId = currentProcessId;
|
---|
193 |
|
---|
194 | memset(&windowpos, 0, sizeof(windowpos));
|
---|
195 | //min and max position are initially -1 (verified in NT4, SP6)
|
---|
196 | windowpos.ptMinPosition.x = -1;
|
---|
197 | windowpos.ptMinPosition.y = -1;
|
---|
198 | windowpos.ptMaxPosition.x = -1;
|
---|
199 | windowpos.ptMaxPosition.y = -1;
|
---|
200 |
|
---|
201 | lpVisRgnNotifyProc = NULL;
|
---|
202 | dwVisRgnNotifyParam = NULL;
|
---|
203 |
|
---|
204 | pfnOldPMWndProc = NULL;
|
---|
205 |
|
---|
206 | memset(hdcWindow, 0, sizeof(hdcWindow));
|
---|
207 | nrOpenDCs = 0;
|
---|
208 | }
|
---|
209 | //******************************************************************************
|
---|
210 | //todo get rid of resources (menu, icon etc)
|
---|
211 | //******************************************************************************
|
---|
212 | Win32BaseWindow::~Win32BaseWindow()
|
---|
213 | {
|
---|
214 | if(getRefCount() < 0) {
|
---|
215 | DebugInt3();
|
---|
216 | }
|
---|
217 |
|
---|
218 | if(hTaskList) {
|
---|
219 | OSLibWinRemoveFromTasklist(hTaskList);
|
---|
220 | }
|
---|
221 |
|
---|
222 | OSLibWinSetVisibleRegionNotify(OS2Hwnd, FALSE);
|
---|
223 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
---|
224 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
---|
225 |
|
---|
226 | if(fDestroyAll) {
|
---|
227 | dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
|
---|
228 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
---|
229 | }
|
---|
230 | else
|
---|
231 | if(getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
|
---|
232 | {
|
---|
233 | //if we're the last child that's being destroyed and our
|
---|
234 | //parent window was also destroyed, then we
|
---|
235 | if(getParent()->IsWindowDestroyed())
|
---|
236 | {
|
---|
237 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
---|
238 | RELEASE_WNDOBJ(wndparent);
|
---|
239 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
---|
240 | }
|
---|
241 | }
|
---|
242 | else
|
---|
243 | {
|
---|
244 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
---|
245 | if(wndparent && !fDestroyAll) {
|
---|
246 | RELEASE_WNDOBJ(wndparent);
|
---|
247 | }
|
---|
248 | }
|
---|
249 | if(owner && !fDestroyAll) {
|
---|
250 | RELEASE_WNDOBJ(owner);
|
---|
251 | }
|
---|
252 |
|
---|
253 | // Decrement class window counter
|
---|
254 | // NOTE: Must be done before ReleaseDC call for ownDC!
|
---|
255 | if(windowClass) {
|
---|
256 | RELEASE_CLASSOBJ(windowClass);
|
---|
257 | }
|
---|
258 |
|
---|
259 | if(ownDC)
|
---|
260 | ReleaseDC(Win32HwndOrg, ownDC);
|
---|
261 |
|
---|
262 | if(Win32Hwnd)
|
---|
263 | HwFreeWindowHandle(Win32Hwnd);
|
---|
264 |
|
---|
265 | if(userWindowBytes)
|
---|
266 | free(userWindowBytes);
|
---|
267 |
|
---|
268 | if(windowNameA) {
|
---|
269 | free(windowNameA);
|
---|
270 | windowNameA = NULL;
|
---|
271 | }
|
---|
272 | if(windowNameW) {
|
---|
273 | free(windowNameW);
|
---|
274 | windowNameW = NULL;
|
---|
275 | }
|
---|
276 | if(vertScrollInfo) {
|
---|
277 | free(vertScrollInfo);
|
---|
278 | vertScrollInfo = NULL;
|
---|
279 | }
|
---|
280 | if(horzScrollInfo) {
|
---|
281 | free(horzScrollInfo);
|
---|
282 | horzScrollInfo = NULL;
|
---|
283 | }
|
---|
284 | if(propertyList) {
|
---|
285 | removeWindowProps();
|
---|
286 | }
|
---|
287 | if(hUpdateRegion) {
|
---|
288 | DeleteObject(hUpdateRegion);
|
---|
289 | hUpdateRegion = NULL;
|
---|
290 | }
|
---|
291 | }
|
---|
292 | //******************************************************************************
|
---|
293 | //******************************************************************************
|
---|
294 | void Win32BaseWindow::DestroyAll()
|
---|
295 | {
|
---|
296 | fDestroyAll = TRUE;
|
---|
297 | GenericObject::DestroyAll(windows);
|
---|
298 | }
|
---|
299 | //******************************************************************************
|
---|
300 | //******************************************************************************
|
---|
301 | BOOL Win32BaseWindow::isChild()
|
---|
302 | {
|
---|
303 | return ((dwStyle & WS_CHILD) != 0);
|
---|
304 | }
|
---|
305 | //******************************************************************************
|
---|
306 | //******************************************************************************
|
---|
307 | BOOL Win32BaseWindow::IsWindowUnicode()
|
---|
308 | {
|
---|
309 | dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
|
---|
310 | return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
|
---|
311 | }
|
---|
312 | //******************************************************************************
|
---|
313 | //******************************************************************************
|
---|
314 | BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
|
---|
315 | {
|
---|
316 | char buffer[256];
|
---|
317 |
|
---|
318 | #ifdef DEBUG
|
---|
319 | PrintWindowStyle(cs->style, cs->dwExStyle);
|
---|
320 | #endif
|
---|
321 |
|
---|
322 | //If window has no owner/parent window, then it will be added to the tasklist
|
---|
323 | //(depending on visibility state)
|
---|
324 | if (!cs->hwndParent) fTaskList = TRUE;
|
---|
325 |
|
---|
326 | sw = SW_SHOW;
|
---|
327 | SetLastError(0);
|
---|
328 |
|
---|
329 | /* Find the parent window */
|
---|
330 | if (cs->hwndParent)
|
---|
331 | {
|
---|
332 | Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
|
---|
333 | if(!window) {
|
---|
334 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
---|
335 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
336 | return FALSE;
|
---|
337 | }
|
---|
338 | /* Make sure parent is valid */
|
---|
339 | if (!window->IsWindow() )
|
---|
340 | {
|
---|
341 | RELEASE_WNDOBJ(window);
|
---|
342 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
---|
343 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
344 | return FALSE;
|
---|
345 | }
|
---|
346 | if (window->getExStyle() & WS_EX_TOPMOST)
|
---|
347 | cs->dwExStyle |= WS_EX_TOPMOST;
|
---|
348 |
|
---|
349 | RELEASE_WNDOBJ(window);
|
---|
350 | /* Windows does this for overlapped windows
|
---|
351 | * (I don't know about other styles.) */
|
---|
352 | if (cs->hwndParent == GetDesktopWindow() && (!(cs->style & WS_CHILD) || (cs->style & WS_POPUP)))
|
---|
353 | {
|
---|
354 | cs->hwndParent = 0;
|
---|
355 | }
|
---|
356 | }
|
---|
357 | else
|
---|
358 | if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
|
---|
359 | dprintf(("No parent for child window" ));
|
---|
360 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
361 | return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
|
---|
362 | }
|
---|
363 |
|
---|
364 | /* Find the window class */
|
---|
365 | windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
|
---|
366 | if (!windowClass)
|
---|
367 | {
|
---|
368 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
---|
369 | dprintf(("Bad class '%s'", buffer ));
|
---|
370 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
371 | return 0;
|
---|
372 | }
|
---|
373 |
|
---|
374 | #ifdef DEBUG
|
---|
375 | if(HIWORD(cs->lpszClass))
|
---|
376 | {
|
---|
377 | if(isUnicode) dprintf(("Window class %ls", cs->lpszClass));
|
---|
378 | else dprintf(("Window class %s", cs->lpszClass));
|
---|
379 | }
|
---|
380 | else dprintf(("Window class %x", cs->lpszClass));
|
---|
381 | #endif
|
---|
382 |
|
---|
383 | /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
|
---|
384 | * with an atom as the class name, put some programs expect to have a *REAL* string in
|
---|
385 | * lpszClass when the CREATESTRUCT is sent with WM_CREATE
|
---|
386 | */
|
---|
387 | if (!HIWORD(cs->lpszClass) ) {
|
---|
388 | if (isUnicode) {
|
---|
389 | GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
|
---|
390 | }
|
---|
391 | else {
|
---|
392 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
---|
393 | }
|
---|
394 | cs->lpszClass = buffer;
|
---|
395 | }
|
---|
396 | /* Fix the coordinates */
|
---|
397 | fXDefault = FALSE;
|
---|
398 | fCXDefault = FALSE;
|
---|
399 | FixCoordinates(cs, &sw);
|
---|
400 |
|
---|
401 | /* Correct the window style - stage 1
|
---|
402 | *
|
---|
403 | * These are patches that appear to affect both the style loaded into the
|
---|
404 | * WIN structure and passed in the CreateStruct to the WM_CREATE etc.
|
---|
405 | *
|
---|
406 | * WS_EX_WINDOWEDGE appears to be enforced based on the other styles, so
|
---|
407 | * why does the user get to set it?
|
---|
408 | */
|
---|
409 |
|
---|
410 | /* This has been tested for WS_CHILD | WS_VISIBLE. It has not been
|
---|
411 | * tested for WS_POPUP
|
---|
412 | */
|
---|
413 | if ((cs->dwExStyle & WS_EX_DLGMODALFRAME) ||
|
---|
414 | ((!(cs->dwExStyle & WS_EX_STATICEDGE)) &&
|
---|
415 | (cs->style & (WS_DLGFRAME | WS_THICKFRAME))))
|
---|
416 | cs->dwExStyle |= WS_EX_WINDOWEDGE;
|
---|
417 | else
|
---|
418 | cs->dwExStyle &= ~WS_EX_WINDOWEDGE;
|
---|
419 |
|
---|
420 | //Allocate window words
|
---|
421 | nrUserWindowBytes = windowClass->getExtraWndBytes();
|
---|
422 | if(nrUserWindowBytes) {
|
---|
423 | userWindowBytes = (char *)_smalloc(nrUserWindowBytes);
|
---|
424 | memset(userWindowBytes, 0, nrUserWindowBytes);
|
---|
425 | }
|
---|
426 |
|
---|
427 | // check if it's the standard child window case
|
---|
428 | if ((cs->style & WS_CHILD) && cs->hwndParent)
|
---|
429 | {
|
---|
430 | SetParent(cs->hwndParent);
|
---|
431 | owner = NULL;
|
---|
432 | //SvL: Shell positioning shouldn't be done for child windows! (breaks Notes)
|
---|
433 | fXDefault = fCXDefault = FALSE;
|
---|
434 | }
|
---|
435 | else
|
---|
436 | {
|
---|
437 | // either no child window or a popup window
|
---|
438 |
|
---|
439 | SetParent(0);
|
---|
440 | if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
|
---|
441 | owner = NULL;
|
---|
442 | }
|
---|
443 | else
|
---|
444 | {
|
---|
445 | // we're a popup window
|
---|
446 |
|
---|
447 | Win32BaseWindow *wndparent = GetWindowFromHandle(cs->hwndParent);
|
---|
448 | if(wndparent) {
|
---|
449 | owner = GetWindowFromHandle(wndparent->GetTopParent());
|
---|
450 | RELEASE_WNDOBJ(wndparent);
|
---|
451 | }
|
---|
452 | else owner = NULL;
|
---|
453 |
|
---|
454 | if(owner == NULL)
|
---|
455 | {
|
---|
456 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
---|
457 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
458 | return FALSE;
|
---|
459 | }
|
---|
460 | }
|
---|
461 | }
|
---|
462 |
|
---|
463 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc((isUnicode) ? WNDPROC_UNICODE : WNDPROC_ASCII), WINPROC_GetProcType(windowClass->getWindowProc((isUnicode) ? WNDPROC_UNICODE : WNDPROC_ASCII)), WIN_PROC_WINDOW);
|
---|
464 | hInstance = cs->hInstance;
|
---|
465 | dwStyle = cs->style & ~WS_VISIBLE;
|
---|
466 | dwOldStyle = dwStyle;
|
---|
467 | dwExStyle = cs->dwExStyle;
|
---|
468 |
|
---|
469 | hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
|
---|
470 |
|
---|
471 | /* Correct the window style phase 2 */
|
---|
472 | if (!(cs->style & WS_CHILD))
|
---|
473 | {
|
---|
474 | dwStyle |= WS_CLIPSIBLINGS;
|
---|
475 | if (!(cs->style & WS_POPUP))
|
---|
476 | {
|
---|
477 | dwStyle |= WS_CAPTION;
|
---|
478 | flags |= WIN_NEED_SIZE;
|
---|
479 | }
|
---|
480 | }
|
---|
481 |
|
---|
482 | //WinZip 8.0 crashes when a dialog created after opening a zipfile receives
|
---|
483 | //the WM_SIZE message (before WM_INITDIALOG)
|
---|
484 | //Opera doesn't like this either.
|
---|
485 | if(IsDialog()) {
|
---|
486 | flags |= WIN_NEED_SIZE;
|
---|
487 | }
|
---|
488 |
|
---|
489 | //copy pointer of CREATESTRUCT for usage in MsgCreate method
|
---|
490 | tmpcs = cs;
|
---|
491 |
|
---|
492 | //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
|
---|
493 | TEB *teb = GetThreadTEB();
|
---|
494 | if(teb == NULL) {
|
---|
495 | dprintf(("Window creation failed - teb == NULL")); //this is VERY bad
|
---|
496 | ExitProcess(666);
|
---|
497 | return FALSE;
|
---|
498 | }
|
---|
499 | teb->o.odin.newWindow = (ULONG)this;
|
---|
500 |
|
---|
501 | DWORD dwOSWinStyle, dwOSFrameStyle;
|
---|
502 | OSLibWinConvertStyle(dwStyle,dwExStyle,&dwOSWinStyle, &dwOSFrameStyle);
|
---|
503 |
|
---|
504 | // create PM windows - frame and client window
|
---|
505 | HWND hwndOS2Frame = (getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP;
|
---|
506 | OS2Hwnd = OSLibWinCreateWindow(hwndOS2Frame,
|
---|
507 | dwOSWinStyle,
|
---|
508 | dwOSFrameStyle,
|
---|
509 | (char *)windowNameA,
|
---|
510 | (owner) ? owner->getOS2WindowHandle() : 0,
|
---|
511 | (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
|
---|
512 | 0,
|
---|
513 | fTaskList,
|
---|
514 | fXDefault | fCXDefault,
|
---|
515 | windowClass->getStyle(),
|
---|
516 | &OS2HwndFrame);
|
---|
517 | if(OS2Hwnd == 0) {
|
---|
518 | dprintf(("Window creation failed!! OS LastError %0x", OSLibWinGetLastError()));
|
---|
519 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
520 | return FALSE;
|
---|
521 | }
|
---|
522 | OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE);
|
---|
523 | state = STATE_CREATED;
|
---|
524 | SetLastError(0);
|
---|
525 | return TRUE;
|
---|
526 | }
|
---|
527 | //******************************************************************************
|
---|
528 | //******************************************************************************
|
---|
529 | BOOL Win32BaseWindow::MsgCreate(HWND hwndOS2)
|
---|
530 | {
|
---|
531 | CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
|
---|
532 | POINT maxSize, maxPos, minTrack, maxTrack;
|
---|
533 | HWND hwnd = getWindowHandle();
|
---|
534 | LRESULT (* CALLBACK localSend32)(HWND, UINT, WPARAM, LPARAM);
|
---|
535 |
|
---|
536 | OS2Hwnd = hwndOS2;
|
---|
537 |
|
---|
538 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, getWindowHandle()) == FALSE) {
|
---|
539 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
|
---|
540 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
541 | return FALSE;
|
---|
542 | }
|
---|
543 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
---|
544 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
---|
545 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
546 | return FALSE;
|
---|
547 | }
|
---|
548 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32FLAGS, 0) == FALSE) {
|
---|
549 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
---|
550 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
551 | return FALSE;
|
---|
552 | }
|
---|
553 |
|
---|
554 | if (HOOK_IsHooked( WH_CBT ))
|
---|
555 | {
|
---|
556 | CBT_CREATEWNDA cbtc;
|
---|
557 | LRESULT ret;
|
---|
558 |
|
---|
559 | cbtc.lpcs = cs;
|
---|
560 | cbtc.hwndInsertAfter = hwndLinkAfter;
|
---|
561 | ret = (isUnicode) ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc)
|
---|
562 | : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
|
---|
563 | if(ret)
|
---|
564 | {
|
---|
565 | dprintf(("CBT-hook returned non-0 !!"));
|
---|
566 | SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
|
---|
567 | return FALSE;
|
---|
568 | }
|
---|
569 | //todo: if hook changes parent, we need to do so too!!!!!!!!!!
|
---|
570 | }
|
---|
571 |
|
---|
572 | if (cs->style & WS_HSCROLL)
|
---|
573 | {
|
---|
574 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
575 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
---|
576 | horzScrollInfo->MaxVal = 100;
|
---|
577 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
578 | }
|
---|
579 |
|
---|
580 | if (cs->style & WS_VSCROLL)
|
---|
581 | {
|
---|
582 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
583 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
---|
584 | vertScrollInfo->MaxVal = 100;
|
---|
585 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
586 | }
|
---|
587 |
|
---|
588 | // initially allocate the window name fields
|
---|
589 | if(HIWORD(cs->lpszName))
|
---|
590 | {
|
---|
591 | if (!isUnicode)
|
---|
592 | {
|
---|
593 | windowNameLengthA = strlen(cs->lpszName);
|
---|
594 | windowNameA = (LPSTR)_smalloc(windowNameLengthA+1);
|
---|
595 | strcpy(windowNameA,cs->lpszName);
|
---|
596 |
|
---|
597 | windowNameLengthW = lstrlenAtoW( windowNameA, -1 );
|
---|
598 | windowNameW = (LPWSTR)_smalloc(( windowNameLengthW + 1 ) * sizeof( WCHAR ) );
|
---|
599 | lstrcpyAtoW( windowNameW, windowNameA );
|
---|
600 | }
|
---|
601 | else
|
---|
602 | {
|
---|
603 | // Wide
|
---|
604 | windowNameLengthW = lstrlenW((LPWSTR)cs->lpszName);
|
---|
605 | windowNameW = (LPWSTR)_smalloc((windowNameLengthW+1)*sizeof(WCHAR));
|
---|
606 | strcpyW(windowNameW,(LPWSTR)cs->lpszName);
|
---|
607 |
|
---|
608 | // windowNameW[lstrlenW((LPWSTR)cs->lpszName)] = 0; // need ?
|
---|
609 |
|
---|
610 | // Ascii
|
---|
611 | windowNameLengthA = lstrlenWtoA( windowNameW, -1 );
|
---|
612 | windowNameA = (LPSTR)_smalloc( windowNameLengthA + 1 );
|
---|
613 | lstrcpyWtoA( windowNameA, windowNameW );
|
---|
614 | }
|
---|
615 |
|
---|
616 | dprintf(("windowNameA 0x%lx to 0x%lx windowNameW : 0x%lx to 0x%lx",
|
---|
617 | windowNameA, windowNameA + windowNameLengthA,
|
---|
618 | windowNameW, windowNameW + windowNameLengthW ));
|
---|
619 |
|
---|
620 | if(fOS2Look) {
|
---|
621 | OSLibWinSetTitleBarText(OS2HwndFrame, windowNameA);
|
---|
622 | }
|
---|
623 | }
|
---|
624 |
|
---|
625 | //SvL: This completely messes up MS Word 97 (no button bar, no menu)
|
---|
626 | #if 0
|
---|
627 | //adjust CW_USEDEFAULT position
|
---|
628 | if (fXDefault | fCXDefault)
|
---|
629 | {
|
---|
630 | RECT rect;
|
---|
631 |
|
---|
632 | //SvL: Returns invalid rectangle (not the expected shell default size)
|
---|
633 | OSLibWinQueryWindowRect(OS2Hwnd,&rect,RELATIVE_TO_SCREEN);
|
---|
634 | if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
|
---|
635 | if (fXDefault)
|
---|
636 | {
|
---|
637 | cs->x = rect.left;
|
---|
638 | cs->y = rect.top;
|
---|
639 | if (!fCXDefault)
|
---|
640 | {
|
---|
641 | //CB: todo: adjust pos to screen rect
|
---|
642 | }
|
---|
643 | }
|
---|
644 | if (fCXDefault)
|
---|
645 | {
|
---|
646 | cs->cx = rect.right-rect.left;
|
---|
647 | cs->cy = rect.bottom-rect.top;
|
---|
648 | }
|
---|
649 | }
|
---|
650 | #endif
|
---|
651 |
|
---|
652 | //Set icon from window or class
|
---|
653 | if (hIcon)
|
---|
654 | OSLibWinSetIcon(OS2HwndFrame,hIcon);
|
---|
655 | else
|
---|
656 | if (windowClass->getIcon())
|
---|
657 | OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
|
---|
658 |
|
---|
659 | /* Get class or window DC if needed */
|
---|
660 | if(windowClass->getStyle() & CS_OWNDC) {
|
---|
661 | dprintf(("Class with CS_OWNDC style"));
|
---|
662 | ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
|
---|
663 | }
|
---|
664 | else
|
---|
665 | if (windowClass->getStyle() & CS_PARENTDC) {
|
---|
666 | fParentDC = TRUE;
|
---|
667 | ownDC = 0;
|
---|
668 | }
|
---|
669 | else
|
---|
670 | if (windowClass->getStyle() & CS_CLASSDC) {
|
---|
671 | dprintf(("WARNING: Class with CS_CLASSDC style!"));
|
---|
672 | //not a good solution, but it's a bit difficult to share a single
|
---|
673 | //DC among different windows... DevOpenDC apparently can't be used
|
---|
674 | //for window DCs and WinOpenWindowDC must be associated with a window
|
---|
675 | ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
|
---|
676 | }
|
---|
677 | /* Set the window menu */
|
---|
678 | if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
|
---|
679 | {
|
---|
680 | if (cs->hMenu) {
|
---|
681 | ::SetMenu(getWindowHandle(), cs->hMenu);
|
---|
682 | }
|
---|
683 | else {
|
---|
684 | if (windowClass->getMenuNameA()) {
|
---|
685 | cs->hMenu = LoadMenuA(windowClass->getInstance(),windowClass->getMenuNameA());
|
---|
686 | #if 0 //CB: hack for treeview test cases bug
|
---|
687 | if (!cs->hMenu) cs->hMenu = LoadMenuA(windowClass->getInstance(),"MYAPP");
|
---|
688 | #endif
|
---|
689 | if (cs->hMenu) ::SetMenu(getWindowHandle(), cs->hMenu );
|
---|
690 | }
|
---|
691 | }
|
---|
692 | }
|
---|
693 | else
|
---|
694 | {
|
---|
695 | setWindowId((DWORD)cs->hMenu);
|
---|
696 | }
|
---|
697 | hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
|
---|
698 |
|
---|
699 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */
|
---|
700 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
---|
701 | {
|
---|
702 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
---|
703 | if (maxSize.x < cs->cx) cs->cx = maxSize.x;
|
---|
704 | if (maxSize.y < cs->cy) cs->cy = maxSize.y;
|
---|
705 | if (cs->cx < minTrack.x) cs->cx = minTrack.x;
|
---|
706 | if (cs->cy < minTrack.y) cs->cy = minTrack.y;
|
---|
707 | if (cs->cx < 0) cs->cx = 0;
|
---|
708 | if (cs->cy < 0) cs->cy = 0;
|
---|
709 | }
|
---|
710 |
|
---|
711 | //set client & window rectangles from CreateWindowEx CREATESTRUCT
|
---|
712 | rectWindow.left = cs->x;
|
---|
713 | rectWindow.right = cs->x+cs->cx;
|
---|
714 | rectWindow.top = cs->y;
|
---|
715 | rectWindow.bottom = cs->y+cs->cy;
|
---|
716 | rectClient = rectWindow;
|
---|
717 | OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
|
---|
718 |
|
---|
719 | /* Send the WM_CREATE message
|
---|
720 | * Perhaps we shouldn't allow width/height changes as well.
|
---|
721 | * See p327 in "Internals".
|
---|
722 | */
|
---|
723 | maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
|
---|
724 |
|
---|
725 | if(fTaskList) {
|
---|
726 | hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
|
---|
727 | }
|
---|
728 |
|
---|
729 | localSend32 = (isUnicode) ? ::SendMessageW : ::SendMessageA;
|
---|
730 |
|
---|
731 | state = STATE_PRE_WMNCCREATE;
|
---|
732 | if(localSend32(getWindowHandle(), WM_NCCREATE,0,(LPARAM)cs))
|
---|
733 | {
|
---|
734 | RECT tmpRect;
|
---|
735 |
|
---|
736 | //CB: recheck flags
|
---|
737 | if (cs->style & (WS_POPUP | WS_CHILD))
|
---|
738 | {
|
---|
739 | fXDefault = FALSE;
|
---|
740 | if (fCXDefault)
|
---|
741 | {
|
---|
742 | fCXDefault = FALSE;
|
---|
743 | cs->cx = cs->cy = 0;
|
---|
744 | rectWindow.right = rectWindow.left;
|
---|
745 | rectWindow.bottom = rectWindow.top;
|
---|
746 | }
|
---|
747 | }
|
---|
748 | tmpRect = rectWindow;
|
---|
749 | state = STATE_POST_WMNCCREATE;
|
---|
750 |
|
---|
751 | //set the window size and update the client
|
---|
752 | //@@PF Popup children of inactive windows can thus bring inactive window
|
---|
753 | //on top, this is not correct, popup windows can be on top only if their owner
|
---|
754 | //is in foreground, otherwise they are linked after owner.
|
---|
755 | if (((dwStyle & (WS_CHILD|WS_POPUP)) == WS_POPUP) && getOwner() && (getOwner()->getWindowHandle() != GetForegroundWindow()))
|
---|
756 | {
|
---|
757 | hwndLinkAfter = getOwner()->getWindowHandle();
|
---|
758 | }
|
---|
759 | SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
|
---|
760 |
|
---|
761 | state = STATE_PRE_WMCREATE;
|
---|
762 | if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
|
---|
763 | if( (localSend32(getWindowHandle(), WM_CREATE, 0, (LPARAM)cs )) != -1 )
|
---|
764 | {
|
---|
765 | state = STATE_POST_WMCREATE;
|
---|
766 |
|
---|
767 | if(!(flags & WIN_NEED_SIZE))
|
---|
768 | {
|
---|
769 | SendMessageA(getWindowHandle(), WM_SIZE, SIZE_RESTORED,
|
---|
770 | MAKELONG(rectClient.right-rectClient.left,
|
---|
771 | rectClient.bottom-rectClient.top));
|
---|
772 |
|
---|
773 | if(!::IsWindow(hwnd))
|
---|
774 | {
|
---|
775 | dprintf(("Createwindow: WM_SIZE destroyed window"));
|
---|
776 | goto end;
|
---|
777 | }
|
---|
778 | SendMessageA(getWindowHandle(), WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
|
---|
779 | if(!::IsWindow(hwnd))
|
---|
780 | {
|
---|
781 | dprintf(("Createwindow: WM_MOVE destroyed window"));
|
---|
782 | goto end;
|
---|
783 | }
|
---|
784 | }
|
---|
785 |
|
---|
786 | if (getStyle() & (WS_MINIMIZE | WS_MAXIMIZE))
|
---|
787 | {
|
---|
788 | RECT newPos;
|
---|
789 | UINT swFlag = (getStyle() & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
|
---|
790 | setStyle(getStyle() & ~(WS_MAXIMIZE | WS_MINIMIZE));
|
---|
791 | MinMaximize(swFlag, &newPos);
|
---|
792 | swFlag = ((getStyle() & WS_CHILD) || GetActiveWindow()) ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
|
---|
793 | : SWP_NOZORDER | SWP_FRAMECHANGED;
|
---|
794 | SetWindowPos(0, newPos.left, newPos.top, newPos.right, newPos.bottom, swFlag);
|
---|
795 | if(!::IsWindow(hwnd))
|
---|
796 | {
|
---|
797 | dprintf(("Createwindow: min/max destroyed window"));
|
---|
798 | goto end;
|
---|
799 | }
|
---|
800 | }
|
---|
801 |
|
---|
802 | if( (getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
803 | {
|
---|
804 | /* Notify the parent window only */
|
---|
805 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
---|
806 | {
|
---|
807 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
|
---|
808 | }
|
---|
809 | if(!::IsWindow(hwnd))
|
---|
810 | {
|
---|
811 | dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
|
---|
812 | goto end;
|
---|
813 | }
|
---|
814 | }
|
---|
815 |
|
---|
816 | if(cs->style & WS_VISIBLE) {
|
---|
817 | dwStyle &= ~WS_VISIBLE;
|
---|
818 | ShowWindow(sw);
|
---|
819 | }
|
---|
820 |
|
---|
821 | /* Call WH_SHELL hook */
|
---|
822 | if (!(getStyle() & WS_CHILD) && !owner)
|
---|
823 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0);
|
---|
824 |
|
---|
825 | //Call custom Odin hook for window creation (for all windows)
|
---|
826 | HOOK_CallOdinHookA(HODIN_WINDOWCREATED, hwnd, 0);
|
---|
827 |
|
---|
828 | SetLastError(0);
|
---|
829 | return TRUE;
|
---|
830 | }
|
---|
831 | }
|
---|
832 | dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
|
---|
833 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
834 | end:
|
---|
835 | return FALSE;
|
---|
836 | }
|
---|
837 | //******************************************************************************
|
---|
838 | //******************************************************************************
|
---|
839 | ULONG Win32BaseWindow::MsgQuit()
|
---|
840 | {
|
---|
841 | return SendMessageA(getWindowHandle(), WM_QUIT, 0, 0);
|
---|
842 | }
|
---|
843 | //******************************************************************************
|
---|
844 | //******************************************************************************
|
---|
845 | ULONG Win32BaseWindow::MsgClose()
|
---|
846 | {
|
---|
847 | return SendMessageA(getWindowHandle(), WM_CLOSE,0,0);
|
---|
848 | }
|
---|
849 | //******************************************************************************
|
---|
850 | //******************************************************************************
|
---|
851 | ULONG Win32BaseWindow::MsgDestroy()
|
---|
852 | {
|
---|
853 | ULONG rc;
|
---|
854 | Win32BaseWindow *child;
|
---|
855 | HWND hwnd = getWindowHandle();
|
---|
856 |
|
---|
857 | state = STATE_DESTROYED;
|
---|
858 |
|
---|
859 | if(fDestroyWindowCalled == FALSE)
|
---|
860 | {//this window was destroyed because DestroyWindow was called for its parent
|
---|
861 | //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
|
---|
862 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
---|
863 | {
|
---|
864 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
---|
865 | {
|
---|
866 | /* Notify the parent window only */
|
---|
867 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
---|
868 | }
|
---|
869 | //// else DebugInt3();
|
---|
870 | }
|
---|
871 | }
|
---|
872 | SendMessageA(getWindowHandle(),WM_DESTROY, 0, 0);
|
---|
873 | if(::IsWindow(hwnd) == FALSE) {
|
---|
874 | //object already destroyed, so return immediately
|
---|
875 | return 1;
|
---|
876 | }
|
---|
877 | SendMessageA(getWindowHandle(),WM_NCDESTROY, 0, 0);
|
---|
878 |
|
---|
879 | TIMER_KillTimerFromWindow(getWindowHandle());
|
---|
880 |
|
---|
881 | if(getRefCount() == 0 && getFirstChild() == NULL && state == STATE_CREATED) {
|
---|
882 | delete this;
|
---|
883 | }
|
---|
884 | else {
|
---|
885 | //make sure no message can ever arrive for this window again (PM or from other win32 windows)
|
---|
886 | dprintf(("Mark window %x (%x) as deleted; refcount %d", getWindowHandle(), this, getRefCount()));
|
---|
887 | markDeleted();
|
---|
888 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
---|
889 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
---|
890 | if(Win32Hwnd) {
|
---|
891 | HwFreeWindowHandle(Win32Hwnd);
|
---|
892 | Win32Hwnd = 0;
|
---|
893 | }
|
---|
894 | // Decrement class window counter
|
---|
895 | // NOTE: Must be done before ReleaseDC call for ownDC!
|
---|
896 | if(windowClass) {
|
---|
897 | RELEASE_CLASSOBJ(windowClass);
|
---|
898 | }
|
---|
899 |
|
---|
900 | if(ownDC) {
|
---|
901 | ReleaseDC(Win32Hwnd, ownDC);
|
---|
902 | ownDC = 0;
|
---|
903 | }
|
---|
904 | }
|
---|
905 | return 1;
|
---|
906 | }
|
---|
907 | //******************************************************************************
|
---|
908 | //******************************************************************************
|
---|
909 | ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
|
---|
910 | {
|
---|
911 | if(fEnable) {
|
---|
912 | dwStyle &= ~WS_DISABLED;
|
---|
913 | }
|
---|
914 | else dwStyle |= WS_DISABLED;
|
---|
915 |
|
---|
916 | return SendMessageA(getWindowHandle(),WM_ENABLE, fEnable, 0);
|
---|
917 | }
|
---|
918 | //******************************************************************************
|
---|
919 | //TODO: SW_PARENTCLOSING/OPENING flag (lParam)
|
---|
920 | //******************************************************************************
|
---|
921 | ULONG Win32BaseWindow::MsgShow(BOOL fShow)
|
---|
922 | {
|
---|
923 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled) {
|
---|
924 | return 1;
|
---|
925 | }
|
---|
926 |
|
---|
927 | if(fShow) {
|
---|
928 | setStyle(getStyle() | WS_VISIBLE);
|
---|
929 | if(getStyle() & WS_MINIMIZE) {
|
---|
930 | return ShowWindow(SW_RESTORE);
|
---|
931 | }
|
---|
932 | }
|
---|
933 | else setStyle(getStyle() & ~WS_VISIBLE);
|
---|
934 |
|
---|
935 | //already sent from ShowWindow
|
---|
936 | //// return SendMessageA(getWindowHandle(),WM_SHOWWINDOW, fShow, 0);
|
---|
937 | return 0;
|
---|
938 | }
|
---|
939 | //******************************************************************************
|
---|
940 | //******************************************************************************
|
---|
941 | ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
|
---|
942 | {
|
---|
943 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
---|
944 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
---|
945 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
|
---|
946 | return 0;
|
---|
947 |
|
---|
948 | return SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGING, 0, lp);
|
---|
949 | }
|
---|
950 | //******************************************************************************
|
---|
951 | //******************************************************************************
|
---|
952 | ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
|
---|
953 | {
|
---|
954 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
---|
955 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
---|
956 | if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
|
---|
957 | return 1;
|
---|
958 |
|
---|
959 | return SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGED, 0, lp);
|
---|
960 | }
|
---|
961 | //******************************************************************************
|
---|
962 | //******************************************************************************
|
---|
963 | ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
|
---|
964 | {
|
---|
965 | //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
|
---|
966 | //window scrollbars send these messages
|
---|
967 | return SendMessageA(getWindowHandle(),msg, MAKELONG(scrollCode, scrollPos), 0);
|
---|
968 | }
|
---|
969 | //******************************************************************************
|
---|
970 | //******************************************************************************
|
---|
971 | ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win)
|
---|
972 | {
|
---|
973 | ULONG rc, procidhwnd = -1, threadidhwnd = 0;
|
---|
974 |
|
---|
975 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
---|
976 | if(fDestroyWindowCalled) {
|
---|
977 | return 0;
|
---|
978 | }
|
---|
979 |
|
---|
980 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
---|
981 | //default processing is cancelled
|
---|
982 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
---|
983 | if(SendMessageA(getWindowHandle(),WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
---|
984 | {
|
---|
985 | dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
|
---|
986 | return 0;
|
---|
987 | }
|
---|
988 | /* child windows get a WM_CHILDACTIVATE message */
|
---|
989 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
---|
990 | {
|
---|
991 | if(fActivate) {//WM_CHILDACTIVE is for activation only
|
---|
992 | SendMessageA(getWindowHandle(),WM_CHILDACTIVATE, 0, 0L);
|
---|
993 | }
|
---|
994 | return 0;
|
---|
995 | }
|
---|
996 |
|
---|
997 | return SendMessageA(getWindowHandle(),WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
|
---|
998 | }
|
---|
999 | //******************************************************************************
|
---|
1000 | //******************************************************************************
|
---|
1001 | ULONG Win32BaseWindow::MsgChildActivate(BOOL fActivate)
|
---|
1002 | {
|
---|
1003 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
---|
1004 | if(fDestroyWindowCalled) {
|
---|
1005 | return 0;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
---|
1009 | //default processing is cancelled
|
---|
1010 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
---|
1011 | if(SendMessageA(getWindowHandle(),WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
---|
1012 | {
|
---|
1013 | dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
|
---|
1014 | return 0;
|
---|
1015 | }
|
---|
1016 | /* child windows get a WM_CHILDACTIVATE message */
|
---|
1017 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
---|
1018 | {
|
---|
1019 | if(fActivate) {//WM_CHILDACTIVE is for activation only
|
---|
1020 | SendMessageA(getWindowHandle(),WM_CHILDACTIVATE, 0, 0L);
|
---|
1021 | }
|
---|
1022 | return 0;
|
---|
1023 | }
|
---|
1024 | DebugInt3();
|
---|
1025 | return 0;
|
---|
1026 | }
|
---|
1027 | //******************************************************************************
|
---|
1028 | //******************************************************************************
|
---|
1029 | ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
|
---|
1030 | {
|
---|
1031 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
---|
1032 | }
|
---|
1033 | //******************************************************************************
|
---|
1034 | //******************************************************************************
|
---|
1035 | ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
|
---|
1036 | {
|
---|
1037 | return SendMessageW(getWindowHandle(), msg->message, msg->wParam, msg->lParam);
|
---|
1038 | }
|
---|
1039 | //******************************************************************************
|
---|
1040 | //******************************************************************************
|
---|
1041 | ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
|
---|
1042 | {
|
---|
1043 | //Notify that focus has changed (necessary for SetFocus(0) handling)
|
---|
1044 | SetFocusChanged();
|
---|
1045 |
|
---|
1046 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
---|
1047 | if(fDestroyWindowCalled) {
|
---|
1048 | return 0;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | // if in <= 8bpp mode, then we must send a WM_QUERYNEWPALETTE message here
|
---|
1052 | // this gives the app the chance to realize its palette
|
---|
1053 | if(ScreenBitsPerPel <= 8) {
|
---|
1054 | SendMessageA(getWindowHandle(),WM_QUERYNEWPALETTE, 0, 0);
|
---|
1055 | }
|
---|
1056 | return SendMessageA(getWindowHandle(),WM_SETFOCUS, hwnd, 0);
|
---|
1057 | }
|
---|
1058 | //******************************************************************************
|
---|
1059 | //******************************************************************************
|
---|
1060 | ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
|
---|
1061 | {
|
---|
1062 | //Notify that focus has changed (necessary for SetFocus(0) handling)
|
---|
1063 | SetFocusChanged();
|
---|
1064 |
|
---|
1065 | //SvL: Don't send WM_(NC)ACTIVATE messages when the window is being destroyed
|
---|
1066 | if(fDestroyWindowCalled) {
|
---|
1067 | return 0;
|
---|
1068 | }
|
---|
1069 | return SendMessageA(getWindowHandle(),WM_KILLFOCUS, hwnd, 0);
|
---|
1070 | }
|
---|
1071 | //******************************************************************************
|
---|
1072 | //******************************************************************************
|
---|
1073 | ULONG Win32BaseWindow::MsgButton(MSG *msg)
|
---|
1074 | {
|
---|
1075 | BOOL fClick = FALSE;
|
---|
1076 |
|
---|
1077 | dprintf(("MsgButton %d at (%d,%d)", msg->message, msg->pt.x, msg->pt.y));
|
---|
1078 | switch(msg->message)
|
---|
1079 | {
|
---|
1080 | case WM_LBUTTONDBLCLK:
|
---|
1081 | case WM_RBUTTONDBLCLK:
|
---|
1082 | case WM_MBUTTONDBLCLK:
|
---|
1083 | if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
|
---|
1084 | {
|
---|
1085 | msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
|
---|
1086 | return MsgButton(msg);
|
---|
1087 | }
|
---|
1088 | break;
|
---|
1089 | case WM_NCLBUTTONDBLCLK:
|
---|
1090 | case WM_NCRBUTTONDBLCLK:
|
---|
1091 | case WM_NCMBUTTONDBLCLK:
|
---|
1092 | //Docs say CS_DBLCLKS style doesn't matter for non-client double clicks
|
---|
1093 | fClick = TRUE;
|
---|
1094 | break;
|
---|
1095 |
|
---|
1096 | case WM_LBUTTONDOWN:
|
---|
1097 | case WM_RBUTTONDOWN:
|
---|
1098 | case WM_MBUTTONDOWN:
|
---|
1099 | case WM_NCLBUTTONDOWN:
|
---|
1100 | case WM_NCRBUTTONDOWN:
|
---|
1101 | case WM_NCMBUTTONDOWN:
|
---|
1102 | fClick = TRUE;
|
---|
1103 | break;
|
---|
1104 | }
|
---|
1105 |
|
---|
1106 | if(fClick)
|
---|
1107 | {
|
---|
1108 | HWND hwndTop;
|
---|
1109 |
|
---|
1110 | /* Activate the window if needed */
|
---|
1111 | hwndTop = GetTopParent();
|
---|
1112 |
|
---|
1113 | HWND hwndActive = GetActiveWindow();
|
---|
1114 | if (hwndTop && (getWindowHandle() != hwndActive))
|
---|
1115 | {
|
---|
1116 | LONG ret = SendMessageA(getWindowHandle(),WM_MOUSEACTIVATE, hwndTop,
|
---|
1117 | MAKELONG( lastHitTestVal, msg->message) );
|
---|
1118 |
|
---|
1119 | dprintf2(("WM_MOUSEACTIVATE returned %d foreground %x top %x", ret, GetForegroundWindow(), hwndTop));
|
---|
1120 | #if 0
|
---|
1121 | if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
|
---|
1122 | eatMsg = TRUE;
|
---|
1123 | #endif
|
---|
1124 | //SvL: 0 is not documented, but experiments in NT4 show that
|
---|
1125 | // the window will get activated when it returns this.
|
---|
1126 | // (FreeCell is an example)
|
---|
1127 | if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT) || (ret == 0))
|
---|
1128 | && (hwndTop != GetForegroundWindow()) )
|
---|
1129 | {
|
---|
1130 | Win32BaseWindow *win32top = Win32BaseWindow::GetWindowFromHandle(hwndTop);
|
---|
1131 |
|
---|
1132 | //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
|
---|
1133 | if (win32top) {
|
---|
1134 | //Must use client window handle (not frame!!)
|
---|
1135 | SetFocus(win32top->getWindowHandle());
|
---|
1136 | RELEASE_WNDOBJ(win32top);
|
---|
1137 | }
|
---|
1138 | }
|
---|
1139 | }
|
---|
1140 | }
|
---|
1141 |
|
---|
1142 | SendMessageA(getWindowHandle(),WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
|
---|
1143 |
|
---|
1144 | switch(msg->message)
|
---|
1145 | {
|
---|
1146 | case WM_LBUTTONDOWN:
|
---|
1147 | case WM_MBUTTONDOWN:
|
---|
1148 | case WM_RBUTTONDOWN:
|
---|
1149 | {
|
---|
1150 | if (getParent())
|
---|
1151 | NotifyParent(msg->message, msg->wParam, 0);
|
---|
1152 | break;
|
---|
1153 | }
|
---|
1154 | }
|
---|
1155 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
---|
1156 | }
|
---|
1157 | //******************************************************************************
|
---|
1158 | //******************************************************************************
|
---|
1159 | ULONG Win32BaseWindow::MsgPaint(ULONG tmp, ULONG select)
|
---|
1160 | {
|
---|
1161 | if (select && IsWindowIconic())
|
---|
1162 | return SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
|
---|
1163 | else
|
---|
1164 | return SendMessageA(getWindowHandle(),WM_PAINT, 0, 0);
|
---|
1165 | }
|
---|
1166 | //******************************************************************************
|
---|
1167 | //
|
---|
1168 | // Win32BaseWindow::saveAndValidateUpdateRegion
|
---|
1169 | //
|
---|
1170 | // If an application doesn't validate the update region while processing
|
---|
1171 | // WM_PAINT, then we must remember it for the next time. Also validates
|
---|
1172 | // the current update region.
|
---|
1173 | //
|
---|
1174 | // Parameters:
|
---|
1175 | // Returns:
|
---|
1176 | //
|
---|
1177 | // NOTE:
|
---|
1178 | // Windows will only send a WM_PAINT once until another part of the
|
---|
1179 | // window is invalidated. Unfortunately PM keeps on sending
|
---|
1180 | // WM_PAINT messages until we validate the update region.
|
---|
1181 | //
|
---|
1182 | // This affects UpdateWindow, RedrawWindow, GetUpdateRgn, GetUpdateRect,
|
---|
1183 | // BeginPaint and the next WM_PAINT message.
|
---|
1184 | //
|
---|
1185 | //******************************************************************************
|
---|
1186 | void Win32BaseWindow::saveAndValidateUpdateRegion()
|
---|
1187 | {
|
---|
1188 | if(hUpdateRegion == NULL) {
|
---|
1189 | hUpdateRegion = ::CreateRectRgn(0, 0, 1, 1);
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | dprintf(("Win32BaseWindow::saveAndValidateUpdateRegion; marked dirty!"));
|
---|
1193 |
|
---|
1194 | //save update region
|
---|
1195 | ::GetUpdateRgn(getWindowHandle(), hUpdateRegion, FALSE);
|
---|
1196 |
|
---|
1197 | //and validate it so PM won't bother us again
|
---|
1198 | ::ValidateRgn(getWindowHandle(), hUpdateRegion);
|
---|
1199 |
|
---|
1200 | //we just pretend the entire window is invalid. easier this way
|
---|
1201 | fDirtyUpdateRegion = TRUE;
|
---|
1202 | }
|
---|
1203 | //******************************************************************************
|
---|
1204 | //
|
---|
1205 | // Win32BaseWindow::checkForDirtyUpdateRegion
|
---|
1206 | //
|
---|
1207 | // If an application doesn't validate the update region while processing
|
---|
1208 | // WM_PAINT, then we must remember it for the next time. If the window has
|
---|
1209 | // a dirty update region, then invalidate that region.
|
---|
1210 | //
|
---|
1211 | // Parameters:
|
---|
1212 | // Returns:
|
---|
1213 | //
|
---|
1214 | // NOTE:
|
---|
1215 | //
|
---|
1216 | //******************************************************************************
|
---|
1217 | void Win32BaseWindow::checkForDirtyUpdateRegion()
|
---|
1218 | {
|
---|
1219 | if(fDirtyUpdateRegion) {
|
---|
1220 | dprintf(("Win32BaseWindow::checkForDirtyUpdateRegion; marked dirty -> invalidate whole window!"));
|
---|
1221 | fDirtyUpdateRegion = FALSE;
|
---|
1222 | ::InvalidateRgn(getWindowHandle(), hUpdateRegion, TRUE);
|
---|
1223 | }
|
---|
1224 | }
|
---|
1225 | //******************************************************************************
|
---|
1226 | //TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
|
---|
1227 | // (or are we simply erasing too much here)
|
---|
1228 | //******************************************************************************
|
---|
1229 | ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
|
---|
1230 | {
|
---|
1231 | ULONG rc;
|
---|
1232 | HDC hdcErase = hdc;
|
---|
1233 |
|
---|
1234 | if (hdcErase == 0) {
|
---|
1235 | DebugInt3();
|
---|
1236 | return 0;
|
---|
1237 | }
|
---|
1238 |
|
---|
1239 | if(IsWindowIconic())
|
---|
1240 | rc = SendMessageA(getWindowHandle(),WM_ICONERASEBKGND, hdcErase, 0);
|
---|
1241 | else
|
---|
1242 | rc = SendMessageA(getWindowHandle(),WM_ERASEBKGND, hdcErase, 0);
|
---|
1243 |
|
---|
1244 | return (rc);
|
---|
1245 | }
|
---|
1246 | //******************************************************************************
|
---|
1247 | //******************************************************************************
|
---|
1248 | ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
|
---|
1249 | {
|
---|
1250 | //TODO: hiword should be 0 if window enters menu mode (SDK docs)
|
---|
1251 | //SDK: WM_SETCURSOR is not sent if the mouse is captured
|
---|
1252 | if(GetCapture() == 0) {
|
---|
1253 | SendMessageA(getWindowHandle(),WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
|
---|
1254 | }
|
---|
1255 |
|
---|
1256 | //translated message == WM_(NC)MOUSEMOVE
|
---|
1257 | return SendMessageA(getWindowHandle(),msg->message, msg->wParam, msg->lParam);
|
---|
1258 | }
|
---|
1259 | //******************************************************************************
|
---|
1260 | //******************************************************************************
|
---|
1261 | ULONG Win32BaseWindow::MsgChar(MSG *msg)
|
---|
1262 | {
|
---|
1263 | return IsWindowUnicode() ? DispatchMsgW( msg ) : DispatchMsgA( msg );
|
---|
1264 | }
|
---|
1265 | //******************************************************************************
|
---|
1266 | //******************************************************************************
|
---|
1267 | ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect, HRGN hrgnUpdate)
|
---|
1268 | {
|
---|
1269 | ULONG rc;
|
---|
1270 | RECT client = rectClient;
|
---|
1271 |
|
---|
1272 | if ((pUpdateRect->left >= client.left) && (pUpdateRect->left < client.right) &&
|
---|
1273 | (pUpdateRect->right >= client.left) && (pUpdateRect->right < client.right) &&
|
---|
1274 | (pUpdateRect->top >= client.top) && (pUpdateRect->top < client.bottom) &&
|
---|
1275 | (pUpdateRect->bottom >= client.top) && (pUpdateRect->bottom < client.bottom)
|
---|
1276 | && (!(getStyle() & WS_MINIMIZE)))
|
---|
1277 | {
|
---|
1278 | return 0;
|
---|
1279 | }
|
---|
1280 |
|
---|
1281 | rc = SendMessageA(getWindowHandle(),WM_NCPAINT, hrgnUpdate, 0);
|
---|
1282 | //Send WM_PAINTICON here if minimized, because client window will
|
---|
1283 | //not receive a (valid) WM_PAINT message
|
---|
1284 | if (getStyle() & WS_MINIMIZE)
|
---|
1285 | {
|
---|
1286 | rc = SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | return rc;
|
---|
1290 | }
|
---|
1291 | //******************************************************************************
|
---|
1292 | //Called when either the frame's size or position has changed (lpWndPos != NULL)
|
---|
1293 | //or when the frame layout has changed (i.e. scrollbars added/removed) (lpWndPos == NULL)
|
---|
1294 | //******************************************************************************
|
---|
1295 | ULONG Win32BaseWindow::MsgFormatFrame(WINDOWPOS *lpWndPos)
|
---|
1296 | {
|
---|
1297 | RECT oldWindowRect = rectWindow, client = rectClient, newWindowRect;
|
---|
1298 | RECT newClientRect;
|
---|
1299 | WINDOWPOS wndPos;
|
---|
1300 | ULONG rc;
|
---|
1301 |
|
---|
1302 | if(lpWndPos)
|
---|
1303 | {
|
---|
1304 | //set new window rectangle
|
---|
1305 | setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
|
---|
1306 | lpWndPos->y+lpWndPos->cy);
|
---|
1307 | newWindowRect = rectWindow;
|
---|
1308 | }
|
---|
1309 | else {
|
---|
1310 | wndPos.hwnd = getWindowHandle();
|
---|
1311 | wndPos.hwndInsertAfter = 0;
|
---|
1312 | newWindowRect= rectWindow;
|
---|
1313 | wndPos.x = newWindowRect.left;
|
---|
1314 | wndPos.y = newWindowRect.top;
|
---|
1315 | wndPos.cx = newWindowRect.right - newWindowRect.left;
|
---|
1316 | wndPos.cy = newWindowRect.bottom - newWindowRect.top;
|
---|
1317 | wndPos.flags = SWP_FRAMECHANGED;
|
---|
1318 | lpWndPos = &wndPos;
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | newClientRect = rectClient;
|
---|
1322 | rc = SendNCCalcSize(TRUE, &newWindowRect, &oldWindowRect, &client, lpWndPos, &newClientRect);
|
---|
1323 | rectClient = newClientRect; //must update rectClient here
|
---|
1324 |
|
---|
1325 | dprintf(("MsgFormatFrame: old client rect (%d,%d)(%d,%d), new client (%d,%d)(%d,%d)", client.left, client.top, client.right, client.bottom, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom));
|
---|
1326 | dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
---|
1327 |
|
---|
1328 | if(!CanReceiveSizeMsgs() || !EqualRect(&client, &rectClient)) {
|
---|
1329 | OSLibWinSetClientPos(getOS2WindowHandle(), rectClient.left, rectClient.top, getClientWidth(), getClientHeight(), getWindowHeight());
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | #if 1
|
---|
1333 | //this doesn't always work
|
---|
1334 | // if(CanReceiveSizeMsgs() && (client.left != rectClient.left || client.top != rectClient.top))
|
---|
1335 | if(CanReceiveSizeMsgs() && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
|
---|
1336 | || oldWindowRect.bottom - oldWindowRect.top < rectClient.top) ||
|
---|
1337 | (EqualRect(&oldWindowRect, &rectWindow) && (client.left != rectClient.left || client.top != rectClient.top))))
|
---|
1338 | {
|
---|
1339 | Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild();
|
---|
1340 |
|
---|
1341 | //client rectangle has moved -> inform children
|
---|
1342 | dprintf(("MsgFormatFrame -> client rectangle has changed, move children"));
|
---|
1343 | while(child) {
|
---|
1344 | ::SetWindowPos(child->getWindowHandle(),
|
---|
1345 | HWND_TOP, child->getWindowRect()->left,
|
---|
1346 | child->getWindowRect()->top, 0, 0,
|
---|
1347 | SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
|
---|
1348 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
1349 | }
|
---|
1350 | }
|
---|
1351 | #endif
|
---|
1352 | //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
|
---|
1353 | if(fOS2Look && ((dwStyle & WS_CAPTION) == WS_CAPTION) && !(dwExStyle & WS_EX_TOOLWINDOW))
|
---|
1354 | {
|
---|
1355 | RECT rect = {0};
|
---|
1356 | BOOL fCloseButton;
|
---|
1357 |
|
---|
1358 | fCloseButton = !(windowClass && (windowClass->getClassLongA(GCL_STYLE) & CS_NOCLOSE));
|
---|
1359 |
|
---|
1360 | int height = getWindowHeight();
|
---|
1361 | RECTLOS2 rectOS2;
|
---|
1362 |
|
---|
1363 | AdjustRectOuter(&rect, FALSE);
|
---|
1364 |
|
---|
1365 | rect.left = -rect.left;
|
---|
1366 | rect.top = rect.bottom - rect.top;
|
---|
1367 | rect.right = rectWindow.right - rectWindow.left - rect.right;
|
---|
1368 |
|
---|
1369 | rectOS2.xLeft = rect.left;
|
---|
1370 | rectOS2.xRight = rect.right;
|
---|
1371 | rectOS2.yBottom = height - rect.top;
|
---|
1372 | rectOS2.yTop = height - rect.bottom;
|
---|
1373 |
|
---|
1374 | //@@PF Disable close button as well when needed by application
|
---|
1375 | OSLibChangeCloseButtonState(getOS2FrameWindowHandle(), fCloseButton);
|
---|
1376 | OSLibWinPositionFrameControls(getOS2FrameWindowHandle(), &rectOS2,
|
---|
1377 | dwStyle, dwExStyle, IconForWindow(ICON_SMALL),
|
---|
1378 | fCloseButton, windowClass->getIcon() != NULL);
|
---|
1379 | }
|
---|
1380 | return rc;
|
---|
1381 | }
|
---|
1382 | //******************************************************************************
|
---|
1383 | //******************************************************************************
|
---|
1384 | ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
|
---|
1385 | {
|
---|
1386 | return SendMessageA(getWindowHandle(),WM_SETTEXT, 0, (LPARAM)lpsz);
|
---|
1387 | }
|
---|
1388 | //******************************************************************************
|
---|
1389 | //******************************************************************************
|
---|
1390 | ULONG Win32BaseWindow::MsgGetTextLength()
|
---|
1391 | {
|
---|
1392 | return SendMessageA(getWindowHandle(),WM_GETTEXTLENGTH, 0, 0);
|
---|
1393 | }
|
---|
1394 | //******************************************************************************
|
---|
1395 | //******************************************************************************
|
---|
1396 | void Win32BaseWindow::MsgGetText(char *wndtext, ULONG textlength)
|
---|
1397 | {
|
---|
1398 | SendMessageA(getWindowHandle(),WM_GETTEXT, textlength, (LPARAM)wndtext);
|
---|
1399 | }
|
---|
1400 | //******************************************************************************
|
---|
1401 | //******************************************************************************
|
---|
1402 | BOOL Win32BaseWindow::isMDIClient()
|
---|
1403 | {
|
---|
1404 | return FALSE;
|
---|
1405 | }
|
---|
1406 | //******************************************************************************
|
---|
1407 | //******************************************************************************
|
---|
1408 | BOOL Win32BaseWindow::isMDIChild()
|
---|
1409 | {
|
---|
1410 | return FALSE;
|
---|
1411 | }
|
---|
1412 | //******************************************************************************
|
---|
1413 | //TODO: Not complete
|
---|
1414 | //******************************************************************************
|
---|
1415 | BOOL Win32BaseWindow::isFrameWindow()
|
---|
1416 | {
|
---|
1417 | if(getParent() == NULL)
|
---|
1418 | return TRUE;
|
---|
1419 |
|
---|
1420 | return FALSE;
|
---|
1421 | }
|
---|
1422 | //******************************************************************************
|
---|
1423 | //******************************************************************************
|
---|
1424 | BOOL Win32BaseWindow::isDesktopWindow()
|
---|
1425 | {
|
---|
1426 | return FALSE;
|
---|
1427 | }
|
---|
1428 | //******************************************************************************
|
---|
1429 | //******************************************************************************
|
---|
1430 | BOOL Win32BaseWindow::isFakeWindow()
|
---|
1431 | {
|
---|
1432 | return FALSE;
|
---|
1433 | }
|
---|
1434 | //******************************************************************************
|
---|
1435 | //******************************************************************************
|
---|
1436 | BOOL Win32BaseWindow::IsWindowIconic()
|
---|
1437 | {
|
---|
1438 | return ((getStyle() & WS_MINIMIZE) && windowClass->getIcon());
|
---|
1439 | }
|
---|
1440 | //******************************************************************************
|
---|
1441 | //******************************************************************************
|
---|
1442 | SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
|
---|
1443 | {
|
---|
1444 | switch(nBar)
|
---|
1445 | {
|
---|
1446 | case SB_HORZ:
|
---|
1447 | if (!horzScrollInfo)
|
---|
1448 | {
|
---|
1449 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
1450 | if (!horzScrollInfo) break;
|
---|
1451 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
---|
1452 | horzScrollInfo->MaxVal = 100;
|
---|
1453 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
1454 | }
|
---|
1455 | return horzScrollInfo;
|
---|
1456 |
|
---|
1457 | case SB_VERT:
|
---|
1458 | if (!vertScrollInfo)
|
---|
1459 | {
|
---|
1460 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
1461 | if (!vertScrollInfo) break;
|
---|
1462 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
---|
1463 | vertScrollInfo->MaxVal = 100;
|
---|
1464 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
1465 | }
|
---|
1466 | return vertScrollInfo;
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | return NULL;
|
---|
1470 | }
|
---|
1471 | //******************************************************************************
|
---|
1472 | //******************************************************************************
|
---|
1473 | LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
|
---|
1474 | {
|
---|
1475 | //SvL: Set background color to default button color (not window (white))
|
---|
1476 | if(ctlType == CTLCOLOR_BTN)
|
---|
1477 | {
|
---|
1478 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
---|
1479 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1480 | return GetSysColorBrush(COLOR_BTNFACE);
|
---|
1481 | }
|
---|
1482 | //SvL: Set background color to default dialog color if window is dialog
|
---|
1483 | if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
|
---|
1484 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
---|
1485 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1486 | return GetSysColorBrush(COLOR_BTNFACE);
|
---|
1487 | }
|
---|
1488 | if( ctlType == CTLCOLOR_SCROLLBAR)
|
---|
1489 | {
|
---|
1490 | HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
|
---|
1491 | COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
|
---|
1492 | SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
|
---|
1493 | SetBkColor( hdc, bk);
|
---|
1494 |
|
---|
1495 | /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
|
---|
1496 | * we better use 0x55aa bitmap brush to make scrollbar's background
|
---|
1497 | * look different from the window background.
|
---|
1498 | */
|
---|
1499 | if (bk == GetSysColor(COLOR_WINDOW)) {
|
---|
1500 | return GetPattern55AABrush();
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | UnrealizeObject( hb );
|
---|
1504 | return (LRESULT)hb;
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1508 |
|
---|
1509 | if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
|
---|
1510 | {
|
---|
1511 | SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
|
---|
1512 | }
|
---|
1513 | else
|
---|
1514 | {
|
---|
1515 | SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
|
---|
1516 | return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
|
---|
1517 | }
|
---|
1518 | return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
|
---|
1519 | }
|
---|
1520 | //******************************************************************************
|
---|
1521 | //******************************************************************************
|
---|
1522 | LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
|
---|
1523 | {
|
---|
1524 | /*
|
---|
1525 | * Visibility flag.
|
---|
1526 | */
|
---|
1527 | if ( (uFlags & PRF_CHECKVISIBLE) &&
|
---|
1528 | !IsWindowVisible(getWindowHandle()) )
|
---|
1529 | return 0;
|
---|
1530 |
|
---|
1531 | /*
|
---|
1532 | * Unimplemented flags.
|
---|
1533 | */
|
---|
1534 | if ( (uFlags & PRF_CHILDREN) ||
|
---|
1535 | (uFlags & PRF_OWNED) ||
|
---|
1536 | (uFlags & PRF_NONCLIENT) )
|
---|
1537 | {
|
---|
1538 | dprintf(("WM_PRINT message with unsupported flags\n"));
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 | /*
|
---|
1542 | * Background
|
---|
1543 | */
|
---|
1544 | if ( uFlags & PRF_ERASEBKGND)
|
---|
1545 | SendMessageA(getWindowHandle(),WM_ERASEBKGND, (WPARAM)hdc, 0);
|
---|
1546 |
|
---|
1547 | /*
|
---|
1548 | * Client area
|
---|
1549 | */
|
---|
1550 | if ( uFlags & PRF_CLIENT)
|
---|
1551 | SendMessageA(getWindowHandle(),WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
|
---|
1552 |
|
---|
1553 |
|
---|
1554 | return 0;
|
---|
1555 | }
|
---|
1556 | //******************************************************************************
|
---|
1557 | //******************************************************************************
|
---|
1558 | LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
1559 | {
|
---|
1560 | switch(Msg)
|
---|
1561 | {
|
---|
1562 | case WM_CLOSE:
|
---|
1563 | dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
|
---|
1564 | DestroyWindow();
|
---|
1565 | return 0;
|
---|
1566 |
|
---|
1567 | case WM_GETTEXTLENGTH:
|
---|
1568 | return windowNameLengthA;
|
---|
1569 |
|
---|
1570 | case WM_GETTEXT:
|
---|
1571 | if (!lParam || !wParam)
|
---|
1572 | return 0;
|
---|
1573 | if (!windowNameA)
|
---|
1574 | ((LPSTR)lParam)[0] = 0;
|
---|
1575 | else
|
---|
1576 | lstrcpynA(( LPSTR )lParam, windowNameA, wParam );
|
---|
1577 | return strlen(( LPSTR )lParam );
|
---|
1578 |
|
---|
1579 | case WM_SETTEXT:
|
---|
1580 | {
|
---|
1581 | LPCSTR lpsz = (LPCSTR)lParam;
|
---|
1582 |
|
---|
1583 | // reallocate if new buffer is larger
|
---|
1584 | if (!lParam)
|
---|
1585 | {
|
---|
1586 | free(windowNameA);
|
---|
1587 | free(windowNameW);
|
---|
1588 | windowNameLengthA = 0;
|
---|
1589 | windowNameLengthW = 0;
|
---|
1590 | windowNameA = NULL;
|
---|
1591 | windowNameW = NULL;
|
---|
1592 | }
|
---|
1593 | else
|
---|
1594 | {
|
---|
1595 | if (windowNameA)
|
---|
1596 | {
|
---|
1597 | free(windowNameA);
|
---|
1598 | windowNameA = NULL;
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | if (windowNameW)
|
---|
1602 | {
|
---|
1603 | free(windowNameW);
|
---|
1604 | windowNameW = NULL;
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 | windowNameLengthA = strlen( lpsz );
|
---|
1608 | windowNameA = (LPSTR)_smalloc(windowNameLengthA+1);
|
---|
1609 | strcpy(windowNameA, lpsz);
|
---|
1610 | windowNameLengthW = lstrlenAtoW( lpsz, -1 );
|
---|
1611 | windowNameW = (LPWSTR)_smalloc(( windowNameLengthW + 1 )*sizeof(WCHAR));
|
---|
1612 | lstrcpyAtoW( windowNameW, windowNameA );
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
|
---|
1616 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
1617 | {
|
---|
1618 | HandleNCPaint((HRGN)1);
|
---|
1619 | if(hTaskList) {
|
---|
1620 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
|
---|
1621 | }
|
---|
1622 | if(fOS2Look) {
|
---|
1623 | OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
|
---|
1624 | }
|
---|
1625 | }
|
---|
1626 |
|
---|
1627 | return TRUE;
|
---|
1628 | }
|
---|
1629 |
|
---|
1630 | case WM_SETREDRAW:
|
---|
1631 | {
|
---|
1632 | if (wParam)
|
---|
1633 | {
|
---|
1634 | setStyle(getStyle() | WS_VISIBLE);
|
---|
1635 | dprintf(("Enable window update for %x", getWindowHandle()));
|
---|
1636 | OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, TRUE);
|
---|
1637 | }
|
---|
1638 | else
|
---|
1639 | {
|
---|
1640 | if (getStyle() & WS_VISIBLE)
|
---|
1641 | {
|
---|
1642 | setStyle(getStyle() & ~WS_VISIBLE);
|
---|
1643 | dprintf(("Disable window update for %x", getWindowHandle()));
|
---|
1644 | OSLibWinEnableWindowUpdate(OS2HwndFrame, OS2Hwnd, FALSE);
|
---|
1645 | }
|
---|
1646 | }
|
---|
1647 | return 0;
|
---|
1648 | }
|
---|
1649 |
|
---|
1650 | case WM_CTLCOLORMSGBOX:
|
---|
1651 | case WM_CTLCOLOREDIT:
|
---|
1652 | case WM_CTLCOLORLISTBOX:
|
---|
1653 | case WM_CTLCOLORBTN:
|
---|
1654 | case WM_CTLCOLORDLG:
|
---|
1655 | case WM_CTLCOLORSTATIC:
|
---|
1656 | case WM_CTLCOLORSCROLLBAR:
|
---|
1657 | return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
|
---|
1658 |
|
---|
1659 | case WM_CTLCOLOR:
|
---|
1660 | return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
|
---|
1661 |
|
---|
1662 | case WM_VKEYTOITEM:
|
---|
1663 | case WM_CHARTOITEM:
|
---|
1664 | return -1;
|
---|
1665 |
|
---|
1666 | case WM_PARENTNOTIFY:
|
---|
1667 | return 0;
|
---|
1668 |
|
---|
1669 | case WM_MOUSEACTIVATE:
|
---|
1670 | {
|
---|
1671 | HWND hwnd = getWindowHandle();
|
---|
1672 |
|
---|
1673 | dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
---|
1674 | if (::GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
|
---|
1675 | {
|
---|
1676 | LONG ret = ::SendMessageW( ::GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
|
---|
1677 | if (ret) return ret;
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
|
---|
1681 | return (LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE;
|
---|
1682 | }
|
---|
1683 |
|
---|
1684 | case WM_ACTIVATE:
|
---|
1685 | /* The default action in Windows is to set the keyboard focus to
|
---|
1686 | * the window, if it's being activated and not minimized */
|
---|
1687 | if (LOWORD(wParam) != WA_INACTIVE) {
|
---|
1688 | if(!(getStyle() & WS_MINIMIZE))
|
---|
1689 | SetFocus(getWindowHandle());
|
---|
1690 | }
|
---|
1691 | return 0;
|
---|
1692 |
|
---|
1693 | case WM_SETCURSOR:
|
---|
1694 | {
|
---|
1695 | dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
---|
1696 | if((getStyle() & WS_CHILD))
|
---|
1697 | {
|
---|
1698 | if(getParent()) {
|
---|
1699 | LRESULT rc = SendMessageA(getParent()->getWindowHandle(), WM_SETCURSOR, wParam, lParam);
|
---|
1700 | if(rc) return rc;
|
---|
1701 | }
|
---|
1702 | }
|
---|
1703 | if (wParam == getWindowHandle())
|
---|
1704 | {
|
---|
1705 | HCURSOR hCursor;
|
---|
1706 |
|
---|
1707 | switch(LOWORD(lParam))
|
---|
1708 | {
|
---|
1709 | case HTCLIENT:
|
---|
1710 | hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
|
---|
1711 | break;
|
---|
1712 |
|
---|
1713 | case HTLEFT:
|
---|
1714 | case HTRIGHT:
|
---|
1715 | hCursor = LoadCursorA(0,IDC_SIZEWEA);
|
---|
1716 | break;
|
---|
1717 |
|
---|
1718 | case HTTOP:
|
---|
1719 | case HTBOTTOM:
|
---|
1720 | hCursor = LoadCursorA(0,IDC_SIZENSA);
|
---|
1721 | break;
|
---|
1722 |
|
---|
1723 | case HTTOPLEFT:
|
---|
1724 | case HTBOTTOMRIGHT:
|
---|
1725 | hCursor = LoadCursorA(0,IDC_SIZENWSEA);
|
---|
1726 | break;
|
---|
1727 |
|
---|
1728 | case HTTOPRIGHT:
|
---|
1729 | case HTBOTTOMLEFT:
|
---|
1730 | hCursor = LoadCursorA(0,IDC_SIZENESWA);
|
---|
1731 | break;
|
---|
1732 |
|
---|
1733 | default:
|
---|
1734 | hCursor = LoadCursorA(0,IDC_ARROWA);
|
---|
1735 | break;
|
---|
1736 | }
|
---|
1737 |
|
---|
1738 | if (hCursor)
|
---|
1739 | {
|
---|
1740 | SetCursor(hCursor);
|
---|
1741 | return 1;
|
---|
1742 | }
|
---|
1743 | else return 0;
|
---|
1744 | }
|
---|
1745 | else return 0;
|
---|
1746 | }
|
---|
1747 |
|
---|
1748 | case WM_MOUSEMOVE:
|
---|
1749 | return 0;
|
---|
1750 |
|
---|
1751 | case WM_MOUSEWHEEL:
|
---|
1752 | if (::GetWindowLongA( getWindowHandle(), GWL_STYLE ) & WS_CHILD)
|
---|
1753 | return ::SendMessageA( ::GetParent(getWindowHandle()), WM_MOUSEWHEEL, wParam, lParam );
|
---|
1754 | break;
|
---|
1755 |
|
---|
1756 | case WM_WINDOWPOSCHANGED:
|
---|
1757 | {
|
---|
1758 | PWINDOWPOS wpos = (PWINDOWPOS)lParam;
|
---|
1759 | WPARAM wp = SIZE_RESTORED;
|
---|
1760 |
|
---|
1761 | //According to Wine these are always sent, but experiments in Windows NT4, SP6
|
---|
1762 | //show otherwise
|
---|
1763 | if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
|
---|
1764 | {
|
---|
1765 | SendMessageA(getWindowHandle(),WM_MOVE, 0, MAKELONG(rectClient.left,rectClient.top));
|
---|
1766 | }
|
---|
1767 | //According to Wine these are always sent, but experiments in Windows NT4, SP6
|
---|
1768 | //show otherwise
|
---|
1769 | if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
|
---|
1770 | {
|
---|
1771 | if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
|
---|
1772 | else
|
---|
1773 | if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
|
---|
1774 |
|
---|
1775 | SendMessageA(getWindowHandle(),WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
|
---|
1776 | rectClient.bottom - rectClient.top));
|
---|
1777 | }
|
---|
1778 | return 0;
|
---|
1779 | }
|
---|
1780 | case WM_WINDOWPOSCHANGING:
|
---|
1781 | return HandleWindowPosChanging((WINDOWPOS *)lParam);
|
---|
1782 |
|
---|
1783 | case WM_ERASEBKGND:
|
---|
1784 | case WM_ICONERASEBKGND:
|
---|
1785 | {
|
---|
1786 | HBRUSH hBrush;
|
---|
1787 | RECT rect;
|
---|
1788 | int rc;
|
---|
1789 |
|
---|
1790 | if (!windowClass || (!windowClass->getBackgroundBrush()
|
---|
1791 | && !(getStyle() & WS_MINIMIZE))) return 0;
|
---|
1792 |
|
---|
1793 | //PF For PM desktop/MDI icons allocate brush as well to avoid
|
---|
1794 | //garbage in icons
|
---|
1795 |
|
---|
1796 | if (!windowClass->getBackgroundBrush())
|
---|
1797 | hBrush = GetStockObject(GRAY_BRUSH);
|
---|
1798 | else
|
---|
1799 | {
|
---|
1800 | hBrush = windowClass->getBackgroundBrush();
|
---|
1801 | if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1))
|
---|
1802 | hBrush = GetSysColorBrush(hBrush-1);
|
---|
1803 | }
|
---|
1804 |
|
---|
1805 |
|
---|
1806 | rc = GetClipBox( (HDC)wParam, &rect );
|
---|
1807 | if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
|
---|
1808 | FillRect( (HDC)wParam, &rect, hBrush);
|
---|
1809 |
|
---|
1810 | return 1;
|
---|
1811 | }
|
---|
1812 |
|
---|
1813 | case WM_PRINT:
|
---|
1814 | return DefWndPrint(wParam,lParam);
|
---|
1815 |
|
---|
1816 | case WM_SYNCPAINT:
|
---|
1817 | RedrawWindow(getWindowHandle(), NULL, 0, RDW_ERASENOW | RDW_ERASE | RDW_ALLCHILDREN);
|
---|
1818 | return 0;
|
---|
1819 |
|
---|
1820 | case WM_PAINTICON:
|
---|
1821 | case WM_PAINT:
|
---|
1822 | {
|
---|
1823 | PAINTSTRUCT ps;
|
---|
1824 | HDC hdc = BeginPaint(getWindowHandle(), &ps );
|
---|
1825 | if( hdc )
|
---|
1826 | {
|
---|
1827 | if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() || hIcon))
|
---|
1828 | {
|
---|
1829 | int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
|
---|
1830 | int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
|
---|
1831 | dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
|
---|
1832 | DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
|
---|
1833 | }
|
---|
1834 | EndPaint(getWindowHandle(), &ps );
|
---|
1835 | }
|
---|
1836 | return 0;
|
---|
1837 | }
|
---|
1838 |
|
---|
1839 | case WM_GETDLGCODE:
|
---|
1840 | return 0;
|
---|
1841 |
|
---|
1842 | case WM_NCPAINT:
|
---|
1843 | return HandleNCPaint((HRGN)wParam);
|
---|
1844 |
|
---|
1845 | case WM_NCACTIVATE:
|
---|
1846 | return HandleNCActivate(wParam);
|
---|
1847 |
|
---|
1848 | case WM_NCCREATE:
|
---|
1849 | return(TRUE);
|
---|
1850 |
|
---|
1851 | case WM_NCDESTROY:
|
---|
1852 | return 0;
|
---|
1853 |
|
---|
1854 | case WM_NCCALCSIZE:
|
---|
1855 | return HandleNCCalcSize((BOOL)wParam,(RECT*)lParam);
|
---|
1856 |
|
---|
1857 | case WM_NCLBUTTONDOWN:
|
---|
1858 | return HandleNCLButtonDown(wParam,lParam);
|
---|
1859 |
|
---|
1860 | case WM_LBUTTONDBLCLK:
|
---|
1861 | case WM_NCLBUTTONDBLCLK:
|
---|
1862 | return HandleNCLButtonDblClk(wParam,lParam);
|
---|
1863 |
|
---|
1864 | case WM_NCRBUTTONDOWN:
|
---|
1865 | case WM_NCRBUTTONDBLCLK:
|
---|
1866 | case WM_NCMBUTTONDOWN:
|
---|
1867 | case WM_NCMBUTTONDBLCLK:
|
---|
1868 | if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
|
---|
1869 | return 0;
|
---|
1870 |
|
---|
1871 | case WM_NCRBUTTONUP:
|
---|
1872 | return HandleNCRButtonUp(wParam,lParam);
|
---|
1873 |
|
---|
1874 | case WM_NCMBUTTONUP:
|
---|
1875 | return 0;
|
---|
1876 |
|
---|
1877 | case WM_NCHITTEST:
|
---|
1878 | {
|
---|
1879 | POINT point;
|
---|
1880 | LRESULT retvalue;
|
---|
1881 |
|
---|
1882 | point.x = (SHORT)LOWORD(lParam);
|
---|
1883 | point.y = (SHORT)HIWORD(lParam);
|
---|
1884 |
|
---|
1885 | retvalue = HandleNCHitTest(point);
|
---|
1886 | #if 0 //CB: let the Corel people fix the bugs first
|
---|
1887 | if(retvalue == HTMENU)
|
---|
1888 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,TRUE);
|
---|
1889 | else
|
---|
1890 | MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,FALSE);
|
---|
1891 | #endif
|
---|
1892 | return retvalue;
|
---|
1893 | }
|
---|
1894 |
|
---|
1895 | case WM_SYSCOMMAND:
|
---|
1896 | {
|
---|
1897 | POINT point;
|
---|
1898 |
|
---|
1899 | point.x = LOWORD(lParam);
|
---|
1900 | point.y = HIWORD(lParam);
|
---|
1901 | return HandleSysCommand(wParam,&point);
|
---|
1902 | }
|
---|
1903 |
|
---|
1904 | case WM_KEYDOWN:
|
---|
1905 | if(wParam == VK_F10) iF10Key = VK_F10;
|
---|
1906 | break;
|
---|
1907 |
|
---|
1908 | case WM_SYSKEYDOWN:
|
---|
1909 | {
|
---|
1910 | if( HIWORD(lParam) & KEYDATA_ALT )
|
---|
1911 | {
|
---|
1912 | /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
|
---|
1913 | if( wParam == VK_MENU && !iMenuSysKey )
|
---|
1914 | iMenuSysKey = 1;
|
---|
1915 | else
|
---|
1916 | iMenuSysKey = 0;
|
---|
1917 |
|
---|
1918 | iF10Key = 0;
|
---|
1919 |
|
---|
1920 | if( wParam == VK_F4 ) /* try to close the window */
|
---|
1921 | {
|
---|
1922 | HWND top = GetTopParent();
|
---|
1923 | if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
|
---|
1924 | PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
---|
1925 | }
|
---|
1926 |
|
---|
1927 | //Default OS/2 app behaviour for system keys
|
---|
1928 | if(fOS2Look)
|
---|
1929 | {
|
---|
1930 | if( wParam == VK_F5 ) /* try to restore the window */
|
---|
1931 | {
|
---|
1932 | HWND top = GetTopParent();
|
---|
1933 | /* No checks needed SC_RESTORE handler does them */
|
---|
1934 | PostMessageW( top, WM_SYSCOMMAND, SC_RESTORE, 0 );
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | if( wParam == VK_F7 ) /* size the window */
|
---|
1938 | {
|
---|
1939 | HWND top = GetTopParent();
|
---|
1940 | PostMessageW( top, WM_SYSCOMMAND, SC_MOVE, 0 );
|
---|
1941 | }
|
---|
1942 |
|
---|
1943 | if( wParam == VK_F8 ) /* move the window */
|
---|
1944 | {
|
---|
1945 | HWND top = GetTopParent();
|
---|
1946 | if ( GetWindowLongA(top, GWL_STYLE) & WS_SIZEBOX)
|
---|
1947 | PostMessageW( top, WM_SYSCOMMAND, SC_SIZE, 0 );
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 | if( wParam == VK_F9 ) /* try to minimize the window */
|
---|
1951 | {
|
---|
1952 | HWND top = GetTopParent();
|
---|
1953 | if ( GetWindowLongA(top, GWL_STYLE) & WS_MINIMIZEBOX)
|
---|
1954 | PostMessageW( top, WM_SYSCOMMAND, SC_MINIMIZE, 0 );
|
---|
1955 | }
|
---|
1956 |
|
---|
1957 | if( wParam == VK_F10 ) /* try to maximize the window */
|
---|
1958 | {
|
---|
1959 | HWND top = GetTopParent();
|
---|
1960 | if ( GetWindowLongA(top, GWL_STYLE) & WS_MAXIMIZEBOX)
|
---|
1961 | PostMessageW( top, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
|
---|
1962 | }
|
---|
1963 | }
|
---|
1964 |
|
---|
1965 | }
|
---|
1966 | else if( wParam == VK_F10 )
|
---|
1967 | iF10Key = 1;
|
---|
1968 | else
|
---|
1969 | if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
|
---|
1970 | SendMessageW(getWindowHandle(), WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
|
---|
1971 | return 0;
|
---|
1972 | }
|
---|
1973 |
|
---|
1974 | case WM_KEYUP:
|
---|
1975 | //Single Alt down + up always generates WM_SYSKEYUP
|
---|
1976 | iMenuSysKey = 0;
|
---|
1977 | // no break;
|
---|
1978 | case WM_SYSKEYUP:
|
---|
1979 | /* Press and release F10 or ALT */
|
---|
1980 | if (((wParam == VK_MENU) && iMenuSysKey) ||
|
---|
1981 | ((wParam == VK_F10) && iF10Key))
|
---|
1982 | ::SendMessageW( GetTopParent(), WM_SYSCOMMAND, SC_KEYMENU, 0L );
|
---|
1983 | iMenuSysKey = iF10Key = 0;
|
---|
1984 | break;
|
---|
1985 |
|
---|
1986 | case WM_SYSCHAR:
|
---|
1987 | {
|
---|
1988 | iMenuSysKey = 0;
|
---|
1989 | if (wParam == VK_RETURN && (getStyle() & WS_MINIMIZE))
|
---|
1990 | {
|
---|
1991 | PostMessageA(getWindowHandle(), WM_SYSCOMMAND,
|
---|
1992 | (WPARAM)SC_RESTORE, 0L );
|
---|
1993 | break;
|
---|
1994 | }
|
---|
1995 | if((HIWORD(lParam) & KEYDATA_ALT) && wParam)
|
---|
1996 | {
|
---|
1997 | if (wParam == VK_TAB || wParam == VK_ESCAPE || wParam == VK_F4)
|
---|
1998 | break;
|
---|
1999 | if (wParam == VK_SPACE && (getStyle() & WS_CHILD)) {
|
---|
2000 | ::SendMessageW(GetParent(), Msg, wParam, lParam );
|
---|
2001 | }
|
---|
2002 | else ::SendMessageA(getWindowHandle(), WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)wParam );
|
---|
2003 | }
|
---|
2004 | #if 0
|
---|
2005 | else /* check for Ctrl-Esc */
|
---|
2006 | if (wParam != VK_ESCAPE) MessageBeep(0);
|
---|
2007 | break;
|
---|
2008 | #endif
|
---|
2009 | }
|
---|
2010 |
|
---|
2011 | case WM_SETHOTKEY:
|
---|
2012 | hotkey = wParam;
|
---|
2013 | return 1; //CB: always successful
|
---|
2014 |
|
---|
2015 | case WM_GETHOTKEY:
|
---|
2016 | return hotkey;
|
---|
2017 |
|
---|
2018 | case WM_RBUTTONUP:
|
---|
2019 | {
|
---|
2020 | POINT pt;
|
---|
2021 | pt.x = SLOWORD(lParam);
|
---|
2022 | pt.y = SHIWORD(lParam);
|
---|
2023 | ClientToScreen(getWindowHandle(), &pt);
|
---|
2024 | SendMessageA( getWindowHandle(), WM_CONTEXTMENU, getWindowHandle(),MAKELPARAM(pt.x, pt.y) );
|
---|
2025 | }
|
---|
2026 | break;
|
---|
2027 |
|
---|
2028 | case WM_CONTEXTMENU:
|
---|
2029 | if ((dwStyle & WS_CHILD) && getParent())
|
---|
2030 | SendMessageA(getParent()->getWindowHandle(), WM_CONTEXTMENU,wParam,lParam);
|
---|
2031 | else
|
---|
2032 | {
|
---|
2033 | LONG hitcode;
|
---|
2034 | POINT pt;
|
---|
2035 | if (!GetSysMenu()) return 0;
|
---|
2036 | pt.x = SLOWORD(lParam);
|
---|
2037 | pt.y = SHIWORD(lParam);
|
---|
2038 | hitcode = HandleNCHitTest(pt);
|
---|
2039 |
|
---|
2040 | /* Track system popup if click was in the caption area. */
|
---|
2041 | if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
|
---|
2042 | TrackPopupMenu(GetSysMenu(),
|
---|
2043 | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
|
---|
2044 | pt.x, pt.y, 0, getWindowHandle(), NULL);
|
---|
2045 | }
|
---|
2046 | return 0;
|
---|
2047 |
|
---|
2048 | case WM_SHOWWINDOW:
|
---|
2049 | if (!lParam) return 0; /* sent from ShowWindow */
|
---|
2050 | if (!(dwStyle & WS_POPUP) || !owner) return 0;
|
---|
2051 | if ((dwStyle & WS_VISIBLE) && wParam) return 0;
|
---|
2052 | else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
|
---|
2053 | ShowWindow(wParam ? SW_SHOW:SW_HIDE);
|
---|
2054 | return 0;
|
---|
2055 |
|
---|
2056 | case WM_CANCELMODE:
|
---|
2057 | if (getParent() == windowDesktop) EndMenu();
|
---|
2058 | if (GetCapture() == Win32Hwnd) ReleaseCapture();
|
---|
2059 | return 0;
|
---|
2060 |
|
---|
2061 | case WM_DROPOBJECT:
|
---|
2062 | return DRAG_FILE;
|
---|
2063 |
|
---|
2064 | case WM_QUERYDROPOBJECT:
|
---|
2065 | return (dwExStyle & WS_EX_ACCEPTFILES) ? 1:0;
|
---|
2066 |
|
---|
2067 | case WM_QUERYDRAGICON:
|
---|
2068 | {
|
---|
2069 | HICON hDragIcon = windowClass->getCursor();
|
---|
2070 | UINT len;
|
---|
2071 |
|
---|
2072 | if(hDragIcon) return (LRESULT)hDragIcon;
|
---|
2073 | for(len = 1; len < 64; len++)
|
---|
2074 | {
|
---|
2075 | hDragIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
|
---|
2076 | if(hDragIcon)
|
---|
2077 | return (LRESULT)hDragIcon;
|
---|
2078 | }
|
---|
2079 | return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
|
---|
2080 | }
|
---|
2081 |
|
---|
2082 | case WM_QUERYOPEN:
|
---|
2083 | case WM_QUERYENDSESSION:
|
---|
2084 | return 1;
|
---|
2085 |
|
---|
2086 | case WM_NOTIFYFORMAT:
|
---|
2087 | return IsWindowUnicode() ? NFR_UNICODE:NFR_ANSI;
|
---|
2088 |
|
---|
2089 | case WM_SETICON:
|
---|
2090 | case WM_GETICON:
|
---|
2091 | {
|
---|
2092 | LRESULT result = 0;
|
---|
2093 |
|
---|
2094 | /* Set the appropriate icon members in the window structure. */
|
---|
2095 | if (wParam == ICON_SMALL)
|
---|
2096 | {
|
---|
2097 | result = hIconSm;
|
---|
2098 | if (Msg == WM_SETICON)
|
---|
2099 | hIconSm = (HICON)lParam;
|
---|
2100 | }
|
---|
2101 | else
|
---|
2102 | {
|
---|
2103 | result = hIcon;
|
---|
2104 | if (Msg == WM_SETICON)
|
---|
2105 | {
|
---|
2106 | hIcon = (HICON)lParam;
|
---|
2107 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
2108 | OSLibWinSetIcon(OS2HwndFrame,hIcon);
|
---|
2109 | }
|
---|
2110 | }
|
---|
2111 | if ((Msg == WM_SETICON) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
---|
2112 | HandleNCPaint((HRGN)1);
|
---|
2113 |
|
---|
2114 | return result;
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | case WM_HELP:
|
---|
2118 | if (getParent()) SendMessageA(getParent()->getWindowHandle(), Msg,wParam,lParam);
|
---|
2119 | break;
|
---|
2120 |
|
---|
2121 | case WM_NOTIFY:
|
---|
2122 | return 0; //comctl32 controls expect this
|
---|
2123 |
|
---|
2124 | case WM_IME_CHAR:
|
---|
2125 | if( wParam & 0xFF00 ) // DBCS ?
|
---|
2126 | SendMessageA( getWindowHandle(), WM_CHAR, ( WPARAM )( BYTE )( wParam >> 8 ), lParam );
|
---|
2127 | SendMessageA( getWindowHandle(), WM_CHAR, ( WPARAM )( BYTE )( wParam & 0xFF ), lParam );
|
---|
2128 | break;
|
---|
2129 |
|
---|
2130 | default:
|
---|
2131 | return 0;
|
---|
2132 | }
|
---|
2133 | return 0;
|
---|
2134 | }
|
---|
2135 | //******************************************************************************
|
---|
2136 | //******************************************************************************
|
---|
2137 | LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
2138 | {
|
---|
2139 | switch(Msg)
|
---|
2140 | {
|
---|
2141 | case WM_GETTEXTLENGTH:
|
---|
2142 | return windowNameLengthW;
|
---|
2143 |
|
---|
2144 | case WM_GETTEXT:
|
---|
2145 | if (!lParam || !wParam)
|
---|
2146 | return 0;
|
---|
2147 | if (!windowNameW)
|
---|
2148 | ((LPWSTR)lParam)[0] = 0;
|
---|
2149 | else
|
---|
2150 | lstrcpynW(( LPWSTR )lParam, windowNameW, wParam );
|
---|
2151 |
|
---|
2152 | return strlenW(( LPWSTR )lParam );
|
---|
2153 |
|
---|
2154 | case WM_SETTEXT:
|
---|
2155 | {
|
---|
2156 | LPWSTR lpsz = (LPWSTR)lParam;
|
---|
2157 |
|
---|
2158 | // reallocate if new buffer is larger
|
---|
2159 | if (!lParam)
|
---|
2160 | {
|
---|
2161 | free(windowNameA);
|
---|
2162 | free(windowNameW);
|
---|
2163 | windowNameLengthA = 0;
|
---|
2164 | windowNameLengthW = 0;
|
---|
2165 | windowNameA = NULL;
|
---|
2166 | windowNameW = NULL;
|
---|
2167 | }
|
---|
2168 | else
|
---|
2169 | {
|
---|
2170 | if (windowNameA)
|
---|
2171 | {
|
---|
2172 | free(windowNameA);
|
---|
2173 | windowNameA = NULL;
|
---|
2174 | }
|
---|
2175 |
|
---|
2176 | if (windowNameW)
|
---|
2177 | {
|
---|
2178 | free(windowNameW);
|
---|
2179 | windowNameW = NULL;
|
---|
2180 | }
|
---|
2181 |
|
---|
2182 | windowNameLengthW = lstrlenW( lpsz );
|
---|
2183 | windowNameW = (LPWSTR)_smalloc((windowNameLengthW+1)*sizeof(WCHAR));
|
---|
2184 | strcpyW(windowNameW, lpsz);
|
---|
2185 | windowNameLengthA = lstrlenWtoA( lpsz, -1 );
|
---|
2186 | windowNameA = (LPSTR)_smalloc( windowNameLengthA + 1 );
|
---|
2187 | lstrcpyWtoA( windowNameA, windowNameW );
|
---|
2188 | }
|
---|
2189 |
|
---|
2190 | dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, windowNameA));
|
---|
2191 | if ((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
2192 | {
|
---|
2193 | HandleNCPaint((HRGN)1);
|
---|
2194 | if(hTaskList) {
|
---|
2195 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
|
---|
2196 | }
|
---|
2197 | if(fOS2Look) {
|
---|
2198 | OSLibWinSetTitleBarText(OS2HwndFrame, getWindowNameA());
|
---|
2199 | }
|
---|
2200 | }
|
---|
2201 |
|
---|
2202 | return TRUE;
|
---|
2203 | }
|
---|
2204 |
|
---|
2205 | case WM_IME_CHAR:
|
---|
2206 | SendMessageW( getWindowHandle(), WM_CHAR, wParam, lParam );
|
---|
2207 | return 0;
|
---|
2208 |
|
---|
2209 | default:
|
---|
2210 | return DefWindowProcA(Msg, wParam, lParam);
|
---|
2211 | }
|
---|
2212 | }
|
---|
2213 | //******************************************************************************
|
---|
2214 | //******************************************************************************
|
---|
2215 | void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
2216 | {
|
---|
2217 | Win32BaseWindow *window = this;
|
---|
2218 | Win32BaseWindow *parentwindow;
|
---|
2219 |
|
---|
2220 | while(window)
|
---|
2221 | {
|
---|
2222 | if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
2223 | {
|
---|
2224 | /* Notify the parent window only */
|
---|
2225 | parentwindow = window->getParent();
|
---|
2226 | if(parentwindow) {
|
---|
2227 | /* PF We should map points for each window accordingly! */
|
---|
2228 | if (Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || Msg == WM_RBUTTONDOWN)
|
---|
2229 | {
|
---|
2230 | POINTS pt = MAKEPOINTS(lParam);
|
---|
2231 | POINT point;
|
---|
2232 |
|
---|
2233 | point.x = pt.x;
|
---|
2234 | point.y = pt.y;
|
---|
2235 |
|
---|
2236 | MapWindowPoints(getWindowHandle(),parentwindow->getWindowHandle(), &point, 1);
|
---|
2237 | lParam = MAKELPARAM(point.x, point.y);
|
---|
2238 | }
|
---|
2239 | SendMessageA(parentwindow->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
|
---|
2240 | }
|
---|
2241 |
|
---|
2242 | }
|
---|
2243 | else break;
|
---|
2244 |
|
---|
2245 | window = parentwindow;
|
---|
2246 | }
|
---|
2247 | }
|
---|
2248 | //******************************************************************************
|
---|
2249 | // Returns the big or small icon for the window, falling back to the
|
---|
2250 | // class as windows does.
|
---|
2251 | //******************************************************************************
|
---|
2252 | HICON Win32BaseWindow::IconForWindow(WPARAM fType)
|
---|
2253 | {
|
---|
2254 | HICON hWndIcon;
|
---|
2255 |
|
---|
2256 | if (fType == ICON_BIG)
|
---|
2257 | {
|
---|
2258 | if (hIcon)
|
---|
2259 | hWndIcon = hIcon;
|
---|
2260 | else
|
---|
2261 | if (windowClass && windowClass->getIcon())
|
---|
2262 | hWndIcon = windowClass->getIcon();
|
---|
2263 | else
|
---|
2264 | if (!(dwStyle & DS_MODALFRAME))
|
---|
2265 | {//SvL: load it as shared or else we'll leak icons
|
---|
2266 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR|LR_SHARED);
|
---|
2267 | }
|
---|
2268 | else hWndIcon = 0;
|
---|
2269 | }
|
---|
2270 | else
|
---|
2271 | {
|
---|
2272 | if (hIconSm)
|
---|
2273 | hWndIcon = hIconSm;
|
---|
2274 | else
|
---|
2275 | if (hIcon)
|
---|
2276 | hWndIcon = hIcon;
|
---|
2277 | else
|
---|
2278 | if (windowClass && windowClass->getIconSm())
|
---|
2279 | hWndIcon = windowClass->getIconSm();
|
---|
2280 | else
|
---|
2281 | if (windowClass && windowClass->getIcon())
|
---|
2282 | hWndIcon = windowClass->getIcon();
|
---|
2283 | else
|
---|
2284 | if (!(dwStyle & DS_MODALFRAME))
|
---|
2285 | {//SvL: load it as shared or else we'll leak icons
|
---|
2286 | hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR|LR_SHARED);
|
---|
2287 | }
|
---|
2288 | else hWndIcon = 0;
|
---|
2289 | }
|
---|
2290 |
|
---|
2291 | return hWndIcon;
|
---|
2292 | }
|
---|
2293 | //******************************************************************************
|
---|
2294 | //******************************************************************************
|
---|
2295 | BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
|
---|
2296 | {
|
---|
2297 | ULONG swp = 0;
|
---|
2298 | HWND hWinAfter;
|
---|
2299 | BOOL rc,wasVisible,showFlag;
|
---|
2300 | RECT newPos = {0, 0, 0, 0};
|
---|
2301 |
|
---|
2302 | dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
|
---|
2303 | wasVisible = (getStyle() & WS_VISIBLE) != 0;
|
---|
2304 |
|
---|
2305 | dwOldStyle = getStyle();
|
---|
2306 |
|
---|
2307 | /*
|
---|
2308 | * SW_SHOWDEFAULT is an reference to the startup info wShowWindow member.
|
---|
2309 | */
|
---|
2310 | if (nCmdShow == SW_SHOWDEFAULT)
|
---|
2311 | {
|
---|
2312 | nCmdShow = GetProcessDword(0, GPD_STARTF_SHOWWINDOW);
|
---|
2313 | dprintf(("ShowWindow: GetProcessDword(0, GPD_STARTF_SHOWWINDOW) -> %x", nCmdShow));
|
---|
2314 | }
|
---|
2315 |
|
---|
2316 |
|
---|
2317 | switch(nCmdShow)
|
---|
2318 | {
|
---|
2319 | case SW_HIDE:
|
---|
2320 | if (!wasVisible) goto END;
|
---|
2321 |
|
---|
2322 | swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER;
|
---|
2323 | break;
|
---|
2324 |
|
---|
2325 | case SW_SHOWMINNOACTIVE:
|
---|
2326 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
---|
2327 | /* fall through */
|
---|
2328 | case SW_SHOWMINIMIZED:
|
---|
2329 | swp |= SWP_SHOWWINDOW;
|
---|
2330 | /* fall through */
|
---|
2331 | case SW_MINIMIZE:
|
---|
2332 | swp |= SWP_FRAMECHANGED;
|
---|
2333 | if( !(getStyle() & WS_MINIMIZE) ) {
|
---|
2334 | swp |= MinMaximize(SW_MINIMIZE, &newPos );
|
---|
2335 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
---|
2336 | }
|
---|
2337 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
---|
2338 | break;
|
---|
2339 |
|
---|
2340 | case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
|
---|
2341 | swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
---|
2342 | if( !(getStyle() & WS_MAXIMIZE) ) {
|
---|
2343 | swp |= MinMaximize(SW_MAXIMIZE, &newPos );
|
---|
2344 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
---|
2345 | }
|
---|
2346 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
---|
2347 | break;
|
---|
2348 |
|
---|
2349 | case SW_SHOWNA:
|
---|
2350 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
---|
2351 | /* fall through */
|
---|
2352 | case SW_SHOW:
|
---|
2353 | swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
|
---|
2354 |
|
---|
2355 | /*
|
---|
2356 | * ShowWindow has a little peculiar behavior that if the
|
---|
2357 | * window is already the topmost window, it will not
|
---|
2358 | * activate it.
|
---|
2359 | */
|
---|
2360 | if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
|
---|
2361 | swp |= SWP_NOACTIVATE;
|
---|
2362 |
|
---|
2363 | break;
|
---|
2364 |
|
---|
2365 | case SW_SHOWNOACTIVATE:
|
---|
2366 | swp |= SWP_NOZORDER | SWP_NOACTIVATE;
|
---|
2367 | /* fall through */
|
---|
2368 | case SW_SHOWNORMAL: /* same as SW_NORMAL: */
|
---|
2369 | case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
|
---|
2370 | case SW_RESTORE:
|
---|
2371 | dprintf(("ShowWindow:restoring window"));
|
---|
2372 |
|
---|
2373 | swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
|
---|
2374 | if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) ) {
|
---|
2375 | swp |= MinMaximize(SW_RESTORE, &newPos );
|
---|
2376 | fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
|
---|
2377 | }
|
---|
2378 | else swp |= SWP_NOSIZE | SWP_NOMOVE;
|
---|
2379 | break;
|
---|
2380 | }
|
---|
2381 |
|
---|
2382 | showFlag = (nCmdShow != SW_HIDE);
|
---|
2383 | if (showFlag != wasVisible)
|
---|
2384 | {
|
---|
2385 | SendMessageA(getWindowHandle(),WM_SHOWWINDOW, showFlag, 0 );
|
---|
2386 | if (!::IsWindow( getWindowHandle() )) goto END;
|
---|
2387 | }
|
---|
2388 |
|
---|
2389 | /* We can't activate a child window */
|
---|
2390 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
|
---|
2391 | swp |= SWP_NOACTIVATE | SWP_NOZORDER;
|
---|
2392 |
|
---|
2393 | if (!(getStyle() & WS_MINIMIZE)) {
|
---|
2394 | SetWindowPos(HWND_TOP, newPos.left, newPos.top, newPos.right, newPos.bottom, LOWORD(swp), TRUE);
|
---|
2395 | }
|
---|
2396 | else OSLibWinMinimizeWindow(getOS2FrameWindowHandle());
|
---|
2397 |
|
---|
2398 | if(!(swp & SWP_NOACTIVATE) && (!(getStyle() & WS_MINIMIZE))) {
|
---|
2399 | OSLibWinSetActiveWindow(OS2HwndFrame);
|
---|
2400 | }
|
---|
2401 |
|
---|
2402 | if (flags & WIN_NEED_SIZE)
|
---|
2403 | {
|
---|
2404 | /* should happen only in CreateWindowEx() */
|
---|
2405 | int wParam = SIZE_RESTORED;
|
---|
2406 |
|
---|
2407 | flags &= ~WIN_NEED_SIZE;
|
---|
2408 | if (dwStyle & WS_MAXIMIZE)
|
---|
2409 | wParam = SIZE_MAXIMIZED;
|
---|
2410 | else
|
---|
2411 | if (dwStyle & WS_MINIMIZE)
|
---|
2412 | wParam = SIZE_MINIMIZED;
|
---|
2413 |
|
---|
2414 | SendMessageA(getWindowHandle(),WM_SIZE, wParam,
|
---|
2415 | MAKELONG(rectClient.right-rectClient.left,
|
---|
2416 | rectClient.bottom-rectClient.top));
|
---|
2417 | SendMessageA(getWindowHandle(),WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
|
---|
2418 | }
|
---|
2419 | //testestest
|
---|
2420 | //temporary workaround for file dialogs with template dialog child
|
---|
2421 | //they don't redraw when switching directories
|
---|
2422 | //For some reason the new child's (syslistview32) update rectangle stays
|
---|
2423 | //empty after its parent is made visible with ShowWindow
|
---|
2424 | //TODO: find real cause
|
---|
2425 | if(!wasVisible) {
|
---|
2426 | InvalidateRect(getWindowHandle(), NULL, TRUE);
|
---|
2427 | }
|
---|
2428 | //testestest
|
---|
2429 |
|
---|
2430 | END:
|
---|
2431 | fMinMaxChange = FALSE;
|
---|
2432 | return wasVisible;
|
---|
2433 | }
|
---|
2434 | //******************************************************************************
|
---|
2435 | //******************************************************************************
|
---|
2436 | BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx,
|
---|
2437 | int cy, UINT fuFlags, BOOL fShowWindow)
|
---|
2438 | {
|
---|
2439 | BOOL rc = FALSE;
|
---|
2440 | Win32BaseWindow *window;
|
---|
2441 | HWND hParent = 0;
|
---|
2442 | RECT oldClientRect = rectClient;
|
---|
2443 |
|
---|
2444 | if (fuFlags &
|
---|
2445 | ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
|
---|
2446 | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
|
---|
2447 | SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
|
---|
2448 | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_DEFERERASE |
|
---|
2449 | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_ASYNCWINDOWPOS))
|
---|
2450 | {
|
---|
2451 | dprintf(("ERROR: SetWindowPos; UNKNOWN flag"));
|
---|
2452 | return FALSE;
|
---|
2453 | }
|
---|
2454 |
|
---|
2455 | if( fuFlags & (SWP_DEFERERASE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_ASYNCWINDOWPOS)) {
|
---|
2456 | dprintf(("WARNING: SetWindowPos; unsupported flag"));
|
---|
2457 | }
|
---|
2458 |
|
---|
2459 | if(IsWindowDestroyed()) {
|
---|
2460 | //changing the position of a window that's being destroyed can cause crashes in PMMERGE
|
---|
2461 | dprintf(("SetWindowPos; window already destroyed"));
|
---|
2462 | return TRUE;
|
---|
2463 | }
|
---|
2464 |
|
---|
2465 | if(state >= STATE_CREATED) {
|
---|
2466 | /* Fix redundant flags */
|
---|
2467 | if(getStyle() & WS_VISIBLE) {
|
---|
2468 | fuFlags &= ~SWP_SHOWWINDOW;
|
---|
2469 | }
|
---|
2470 | else
|
---|
2471 | {
|
---|
2472 | if (!(fuFlags & SWP_SHOWWINDOW))
|
---|
2473 | fuFlags |= SWP_NOREDRAW;
|
---|
2474 | fuFlags &= ~SWP_HIDEWINDOW;
|
---|
2475 | }
|
---|
2476 |
|
---|
2477 | if((rectWindow.right - rectWindow.left == cx) && (rectWindow.bottom - rectWindow.top == cy)) {
|
---|
2478 | fuFlags |= SWP_NOSIZE; /* Already the right size */
|
---|
2479 | }
|
---|
2480 |
|
---|
2481 | if((rectWindow.left == x) && (rectWindow.top == y)) {
|
---|
2482 | fuFlags |= SWP_NOMOVE; /* Already the right position */
|
---|
2483 | }
|
---|
2484 |
|
---|
2485 | if(getWindowHandle() == GetActiveWindow()) {
|
---|
2486 | fuFlags |= SWP_NOACTIVATE; /* Already active */
|
---|
2487 | }
|
---|
2488 | else
|
---|
2489 | if((getStyle() & (WS_POPUP | WS_CHILD)) != WS_CHILD )
|
---|
2490 | {
|
---|
2491 | if(!(fuFlags & SWP_NOACTIVATE)) /* Bring to the top when activating */
|
---|
2492 | {
|
---|
2493 | fuFlags &= ~SWP_NOZORDER;
|
---|
2494 | hwndInsertAfter = HWND_TOP;
|
---|
2495 | }
|
---|
2496 | }
|
---|
2497 | }
|
---|
2498 | /* TODO: Check hwndInsertAfter */
|
---|
2499 |
|
---|
2500 | //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
|
---|
2501 | if(state < STATE_POST_WMNCCREATE)
|
---|
2502 | {//don't change size; modify internal structures only
|
---|
2503 | //TODO: not 100% correct yet (activate)
|
---|
2504 | dprintf2(("state < STATE_POST_WMNCCREATE"));
|
---|
2505 | if(!(fuFlags & SWP_NOZORDER)) {
|
---|
2506 | hwndLinkAfter = hwndInsertAfter;
|
---|
2507 | }
|
---|
2508 | if(!(fuFlags & SWP_NOMOVE)) {
|
---|
2509 | rectWindow.bottom = (rectWindow.bottom - rectWindow.top) + y;
|
---|
2510 | rectWindow.top = y;
|
---|
2511 | rectWindow.right = (rectWindow.right - rectWindow.left) + x;
|
---|
2512 | rectWindow.left = x;
|
---|
2513 | }
|
---|
2514 | if(!(fuFlags & SWP_NOSIZE)) {
|
---|
2515 | rectWindow.bottom = rectWindow.top + cy;
|
---|
2516 | rectWindow.right = rectWindow.left + cx;
|
---|
2517 | }
|
---|
2518 | return TRUE;
|
---|
2519 | }
|
---|
2520 |
|
---|
2521 | WINDOWPOS wpos;
|
---|
2522 | SWP swp, swpOld;
|
---|
2523 | wpos.flags = fuFlags;
|
---|
2524 | wpos.cy = cy;
|
---|
2525 | wpos.cx = cx;
|
---|
2526 | wpos.x = x;
|
---|
2527 | wpos.y = y;
|
---|
2528 | wpos.hwndInsertAfter = hwndInsertAfter;
|
---|
2529 | wpos.hwnd = getWindowHandle();
|
---|
2530 |
|
---|
2531 | if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
|
---|
2532 | {
|
---|
2533 | if (isChild())
|
---|
2534 | {
|
---|
2535 | if(!getParent()) {
|
---|
2536 | dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
|
---|
2537 | }
|
---|
2538 | }
|
---|
2539 | OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
|
---|
2540 | }
|
---|
2541 | if((dwOldStyle & WS_MINIMIZE) && (getStyle() & WS_MINIMIZE))
|
---|
2542 | {//don't allow size changes if the window is minimized
|
---|
2543 | //we will update the restore position at the end of this method
|
---|
2544 | if(!(wpos.flags & SWP_NOSIZE)) {
|
---|
2545 | //TODO: updating the window rectangle doesn't look right
|
---|
2546 | wpos.flags |= SWP_NOSIZE;
|
---|
2547 | rectWindow.right = rectWindow.left + wpos.cx;
|
---|
2548 | rectWindow.bottom = rectWindow.top + wpos.cy;
|
---|
2549 | dprintf(("WARNING: Don't allow size change for minimized window; only save new restore position"));
|
---|
2550 | dprintf(("new window rectangle (%d,%d)(%d,%d)", rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
---|
2551 | }
|
---|
2552 | }
|
---|
2553 |
|
---|
2554 | // Hack alert: This makes sure the tooltips windows in OpenOffice don't
|
---|
2555 | // activate the owner windows too.
|
---|
2556 | // First condition takes care of SetWindowPos during window
|
---|
2557 | // creation. The 2nd one for calls made by OpenOffice
|
---|
2558 | if(((getStyle() & WS_POPUP) && (getExStyle() & WS_EX_TOPMOST)) || (fuFlags & SWP_NOOWNERZORDER))
|
---|
2559 | {
|
---|
2560 | //SWP_NOOWNERZORDER means only the z-order of this window changes; it
|
---|
2561 | //should not affect the owner
|
---|
2562 | //PM doesn't support this feature, so this hack might work
|
---|
2563 | wpos.flags |= SWP_NOZORDER;
|
---|
2564 | }
|
---|
2565 |
|
---|
2566 | if(getParent()) {
|
---|
2567 | OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getClientHeight(),
|
---|
2568 | OS2HwndFrame);
|
---|
2569 | }
|
---|
2570 | else OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), OS2HwndFrame);
|
---|
2571 |
|
---|
2572 | if (swp.fl == 0) {
|
---|
2573 | dprintf2(("swp.fl == 0"));
|
---|
2574 | if(fuFlags & SWP_FRAMECHANGED)
|
---|
2575 | {
|
---|
2576 | NotifyFrameChanged(&wpos, &oldClientRect);
|
---|
2577 | }
|
---|
2578 | if(!fShowWindow && !(getStyle() & (WS_MINIMIZE|WS_MAXIMIZE)) && !(fuFlags & (SWP_NOSIZE | SWP_NOMOVE)))
|
---|
2579 | {
|
---|
2580 | //Restore position always changes when the window position is changed
|
---|
2581 | dprintf(("Save new restore position %x (%d,%d)(%d,%d)", getWindowHandle(), rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
---|
2582 | windowpos.rcNormalPosition = rectWindow;
|
---|
2583 | }
|
---|
2584 | return TRUE;
|
---|
2585 | }
|
---|
2586 |
|
---|
2587 | // if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
---|
2588 | if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
---|
2589 | {
|
---|
2590 | Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
|
---|
2591 | if(wndBehind) {
|
---|
2592 | swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
|
---|
2593 | RELEASE_WNDOBJ(wndBehind);
|
---|
2594 | }
|
---|
2595 | else {
|
---|
2596 | dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
|
---|
2597 | swp.hwndInsertBehind = 0;
|
---|
2598 | }
|
---|
2599 | }
|
---|
2600 | swp.hwnd = OS2HwndFrame;
|
---|
2601 |
|
---|
2602 | //SvL: Must also deactivate the window when hiding it or else focus won't
|
---|
2603 | // change. (NOTE: make sure this doesn't cause regressions (01-02-2003)
|
---|
2604 | if((swp.fl & (SWPOS_HIDE|SWPOS_DEACTIVATE)) == (SWPOS_HIDE|SWPOS_DEACTIVATE))
|
---|
2605 | {
|
---|
2606 | //we must make sure the owner is not disabled or else the focus will
|
---|
2607 | //be switched to the wrong window
|
---|
2608 | Win32BaseWindow *topOwner;
|
---|
2609 |
|
---|
2610 | if(getOwner() == NULL) {
|
---|
2611 | windowDesktop->addRef();
|
---|
2612 | topOwner = windowDesktop;
|
---|
2613 | }
|
---|
2614 | else topOwner = GetWindowFromHandle(getOwner()->GetTopParent());
|
---|
2615 |
|
---|
2616 | if(topOwner != NULL) {
|
---|
2617 | DWORD dwStyle = topOwner->GetWindowLong(GWL_STYLE, FALSE);
|
---|
2618 | if(dwStyle & WS_DISABLED) {
|
---|
2619 | swp.fl &= ~SWPOS_DEACTIVATE;
|
---|
2620 | }
|
---|
2621 | }
|
---|
2622 | else DebugInt3();
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 | if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible(getWindowHandle())) {
|
---|
2626 | setStyle(getStyle() | WS_VISIBLE);
|
---|
2627 | if(hTaskList) {
|
---|
2628 | dprintf(("Adding window %x to tasklist", getWindowHandle()));
|
---|
2629 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 1);
|
---|
2630 | }
|
---|
2631 | }
|
---|
2632 | else
|
---|
2633 | if((fuFlags & SWP_HIDEWINDOW) && IsWindowVisible(getWindowHandle())) {
|
---|
2634 | setStyle(getStyle() & ~WS_VISIBLE);
|
---|
2635 | if(hTaskList && !(getStyle() & WS_MINIMIZE)) {
|
---|
2636 | dprintf(("Removing window %x from tasklist", getWindowHandle()));
|
---|
2637 | OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 0);
|
---|
2638 | }
|
---|
2639 | }
|
---|
2640 | dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
|
---|
2641 |
|
---|
2642 | rc = OSLibWinSetMultWindowPos(&swp, 1);
|
---|
2643 | if(rc == FALSE)
|
---|
2644 | {
|
---|
2645 | dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
|
---|
2646 | return 0;
|
---|
2647 | }
|
---|
2648 |
|
---|
2649 | if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
|
---|
2650 | {
|
---|
2651 | NotifyFrameChanged(&wpos, &oldClientRect);
|
---|
2652 | }
|
---|
2653 | if(!fShowWindow && !(getStyle() & (WS_MINIMIZE|WS_MAXIMIZE)))
|
---|
2654 | {
|
---|
2655 | //Restore position always changes when the window position is changed
|
---|
2656 | dprintf(("Save new restore position %x (%d,%d)(%d,%d)", getWindowHandle(), rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
|
---|
2657 | windowpos.rcNormalPosition = rectWindow;
|
---|
2658 | }
|
---|
2659 | //MSDN says the entire client area will be invalidated when SWP_NOCOPYBITS
|
---|
2660 | //is specified (fixes repaint issues when window is made smaller)
|
---|
2661 | if((fuFlags & (SWP_NOCOPYBITS|SWP_NOREDRAW)) == SWP_NOCOPYBITS) {
|
---|
2662 | InvalidateRect(getWindowHandle(), NULL, TRUE);
|
---|
2663 | }
|
---|
2664 |
|
---|
2665 | if(!(fuFlags & SWP_NOSIZE))
|
---|
2666 | {
|
---|
2667 | // We must call this function or open DC will get out of sync
|
---|
2668 | // (PM will not always send us a WM_VRNENABLED message)
|
---|
2669 | RecalcVisibleRegion(this);
|
---|
2670 | }
|
---|
2671 | return (rc);
|
---|
2672 | }
|
---|
2673 | //******************************************************************************
|
---|
2674 | //Called by ScrollWindowEx (dc.cpp) to notify child window that it has moved
|
---|
2675 | //******************************************************************************
|
---|
2676 | BOOL Win32BaseWindow::ScrollWindow(int dx, int dy)
|
---|
2677 | {
|
---|
2678 | rectWindow.left += dx;
|
---|
2679 | rectWindow.right += dx;
|
---|
2680 | rectWindow.top += dy;
|
---|
2681 | rectWindow.bottom += dy;
|
---|
2682 | SendMessageA(getWindowHandle(),WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
|
---|
2683 | return TRUE;
|
---|
2684 | }
|
---|
2685 | //******************************************************************************
|
---|
2686 | //******************************************************************************
|
---|
2687 | void Win32BaseWindow::NotifyFrameChanged(WINDOWPOS *wpos, RECT *oldClientRect)
|
---|
2688 | {
|
---|
2689 | HRGN hrgn, hrgnClient;
|
---|
2690 | RECT rect;
|
---|
2691 |
|
---|
2692 | MsgFormatFrame(NULL);
|
---|
2693 |
|
---|
2694 | if(RECT_WIDTH(rectClient) != RECT_WIDTH(*oldClientRect) ||
|
---|
2695 | RECT_HEIGHT(rectClient) != RECT_HEIGHT(*oldClientRect))
|
---|
2696 | {
|
---|
2697 | wpos->flags &= ~(SWP_NOSIZE|SWP_NOCLIENTSIZE);
|
---|
2698 | wpos->cx = RECT_WIDTH(rectWindow);
|
---|
2699 | wpos->cy = RECT_HEIGHT(rectWindow);
|
---|
2700 | }
|
---|
2701 |
|
---|
2702 | if(rectClient.left != oldClientRect->left ||
|
---|
2703 | rectClient.top != oldClientRect->top)
|
---|
2704 | {
|
---|
2705 | wpos->flags &= ~(SWP_NOMOVE|SWP_NOCLIENTMOVE);
|
---|
2706 | wpos->x = rectWindow.left;
|
---|
2707 | wpos->y = rectWindow.top;
|
---|
2708 | }
|
---|
2709 |
|
---|
2710 | WINDOWPOS wpOld = *wpos;
|
---|
2711 | if(!(wpos->flags & SWP_NOSENDCHANGING))
|
---|
2712 | SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGING, 0, (LPARAM)wpos);
|
---|
2713 |
|
---|
2714 | if ((wpos->hwndInsertAfter != wpOld.hwndInsertAfter) ||
|
---|
2715 | (wpos->x != wpOld.x) || (wpos->y != wpOld.y) || (wpos->cx != wpOld.cx) || (wpos->cy != wpOld.cy) || (wpos->flags != wpOld.flags))
|
---|
2716 | {
|
---|
2717 | dprintf(("WARNING, NotifyFrameChanged: TODO -> adjust flags!!!!"));
|
---|
2718 | SetWindowPos(wpos->hwndInsertAfter, wpos->x, wpos->y, wpos->cx, wpos->cy, wpos->flags | SWP_NOSENDCHANGING);
|
---|
2719 | }
|
---|
2720 | else SendMessageA(getWindowHandle(),WM_WINDOWPOSCHANGED, 0, (LPARAM)wpos);
|
---|
2721 |
|
---|
2722 | //Calculate invalid areas
|
---|
2723 | rect = rectWindow;
|
---|
2724 | OffsetRect(&rect, -rectWindow.left, -rectWindow.top);
|
---|
2725 | hrgn = CreateRectRgnIndirect(&rect);
|
---|
2726 | if (!hrgn) {
|
---|
2727 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
---|
2728 | return;
|
---|
2729 | }
|
---|
2730 | rect = rectClient;
|
---|
2731 | hrgnClient = CreateRectRgnIndirect(&rect);
|
---|
2732 | if (!hrgn) {
|
---|
2733 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
---|
2734 | return;
|
---|
2735 | }
|
---|
2736 | CombineRgn(hrgn, hrgn, hrgnClient, RGN_DIFF);
|
---|
2737 | DeleteObject(hrgnClient);
|
---|
2738 |
|
---|
2739 | if(!EqualRect(oldClientRect, &rectClient)) {
|
---|
2740 | UnionRect(oldClientRect, oldClientRect, &rectClient);
|
---|
2741 | hrgnClient = CreateRectRgnIndirect(oldClientRect);
|
---|
2742 | if (!hrgn) {
|
---|
2743 | dprintf(("ERROR: NotifyFrameChanged, CreateRectRgnIndirect failed!!"));
|
---|
2744 | return;
|
---|
2745 | }
|
---|
2746 | CombineRgn(hrgn, hrgn, hrgnClient, RGN_OR);
|
---|
2747 | DeleteObject(hrgnClient);
|
---|
2748 | }
|
---|
2749 | RedrawWindow(getWindowHandle(), NULL, hrgn, RDW_ALLCHILDREN |
|
---|
2750 | RDW_INVALIDATE | RDW_ERASE | RDW_FRAME);
|
---|
2751 | DeleteObject(hrgn);
|
---|
2752 | }
|
---|
2753 | //******************************************************************************
|
---|
2754 | //TODO: Check how this api really works in NT
|
---|
2755 | //******************************************************************************
|
---|
2756 | BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
|
---|
2757 | {
|
---|
2758 | dprintf(("SetWindowPlacement %x min (%d,%d)", getWindowHandle(), wndpl->ptMinPosition.x, wndpl->ptMinPosition.y));
|
---|
2759 | dprintf(("SetWindowPlacement %x max (%d,%d)", getWindowHandle(), wndpl->ptMaxPosition.x, wndpl->ptMaxPosition.y));
|
---|
2760 | dprintf(("SetWindowPlacement %x norm (%d,%d)(%d,%d)", getWindowHandle(), wndpl->rcNormalPosition.left, wndpl->rcNormalPosition.top, wndpl->rcNormalPosition.right, wndpl->rcNormalPosition.bottom));
|
---|
2761 | windowpos.ptMinPosition = wndpl->ptMinPosition;
|
---|
2762 | windowpos.ptMaxPosition = wndpl->ptMaxPosition;
|
---|
2763 | windowpos.rcNormalPosition = wndpl->rcNormalPosition;
|
---|
2764 |
|
---|
2765 | if(getStyle() & WS_MINIMIZE )
|
---|
2766 | {
|
---|
2767 | //TODO: Why can't this be (0,0)?
|
---|
2768 | if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
|
---|
2769 | SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
|
---|
2770 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
2771 | }
|
---|
2772 | }
|
---|
2773 | else
|
---|
2774 | if(getStyle() & WS_MAXIMIZE )
|
---|
2775 | {
|
---|
2776 | //TODO: Why can't this be (0,0)?
|
---|
2777 | if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
|
---|
2778 | SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
|
---|
2779 | 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
|
---|
2780 | }
|
---|
2781 | else {
|
---|
2782 | SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
|
---|
2783 | windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
|
---|
2784 | windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
|
---|
2785 | SWP_NOZORDER | SWP_NOACTIVATE );
|
---|
2786 | }
|
---|
2787 | ShowWindow(wndpl->showCmd);
|
---|
2788 | if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
|
---|
2789 | {
|
---|
2790 | /* SDK: ...valid only the next time... */
|
---|
2791 | if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
|
---|
2792 | setFlags(getFlags() | WIN_RESTORE_MAX);
|
---|
2793 | }
|
---|
2794 | return TRUE;
|
---|
2795 | }
|
---|
2796 | //******************************************************************************
|
---|
2797 | //******************************************************************************
|
---|
2798 | BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
|
---|
2799 | {
|
---|
2800 | wndpl->length = sizeof(*wndpl);
|
---|
2801 | if(getStyle() & WS_MINIMIZE )
|
---|
2802 | wndpl->showCmd = SW_SHOWMINIMIZED;
|
---|
2803 | else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
|
---|
2804 |
|
---|
2805 | //TODO: Verify if this is correct -> SDK docs claim this flag must always be set to 0
|
---|
2806 | if(getFlags() & WIN_RESTORE_MAX )
|
---|
2807 | wndpl->flags = WPF_RESTORETOMAXIMIZED;
|
---|
2808 | else wndpl->flags = 0;
|
---|
2809 |
|
---|
2810 | wndpl->ptMinPosition = windowpos.ptMinPosition;
|
---|
2811 | wndpl->ptMaxPosition = windowpos.ptMaxPosition;
|
---|
2812 | //Must be in parent coordinates (or screen if no parent); verified in NT4, SP6
|
---|
2813 | wndpl->rcNormalPosition = windowpos.rcNormalPosition;
|
---|
2814 |
|
---|
2815 | return TRUE;
|
---|
2816 | }
|
---|
2817 | //******************************************************************************
|
---|
2818 | //Also destroys all the child windows (destroy children first, parent last)
|
---|
2819 | //TODO: Don't rely on PM to do the right thing. Send WM_(NC)DESTROY &
|
---|
2820 | // destroy children ourselves (see Wine)
|
---|
2821 | //******************************************************************************
|
---|
2822 | BOOL Win32BaseWindow::DestroyWindow()
|
---|
2823 | {
|
---|
2824 | HWND hwnd = getWindowHandle();
|
---|
2825 |
|
---|
2826 | dprintf(("DestroyWindow %x", hwnd));
|
---|
2827 |
|
---|
2828 | #if 0
|
---|
2829 | /* Look whether the focus is within the tree of windows we will
|
---|
2830 | * be destroying.
|
---|
2831 | */
|
---|
2832 | HWND hwndFocus = GetFocus();
|
---|
2833 | if (hwndFocus == hwnd || ::IsChild( hwnd, hwndFocus ))
|
---|
2834 | {
|
---|
2835 | HWND parent = GetAncestor( hwnd, GA_PARENT );
|
---|
2836 | if (parent == GetDesktopWindow()) parent = 0;
|
---|
2837 | SetFocus( parent );
|
---|
2838 | }
|
---|
2839 | #endif
|
---|
2840 | /* Call hooks */
|
---|
2841 | if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
|
---|
2842 | {
|
---|
2843 | return FALSE;
|
---|
2844 | }
|
---|
2845 |
|
---|
2846 | if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
|
---|
2847 | {
|
---|
2848 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
|
---|
2849 | /* FIXME: clean up palette - see "Internals" p.352 */
|
---|
2850 | }
|
---|
2851 |
|
---|
2852 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
---|
2853 | {
|
---|
2854 | if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
|
---|
2855 | {
|
---|
2856 | /* Notify the parent window only */
|
---|
2857 | SendMessageA(getParent()->getWindowHandle(), WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
---|
2858 | if(!::IsWindow(hwnd) )
|
---|
2859 | {
|
---|
2860 | return TRUE;
|
---|
2861 | }
|
---|
2862 | }
|
---|
2863 | //// else DebugInt3();
|
---|
2864 | }
|
---|
2865 | //Must remove the switch entry here to avoid problems with XWorkPlace
|
---|
2866 | if(hTaskList) {
|
---|
2867 | OSLibWinRemoveFromTasklist(hTaskList);
|
---|
2868 | hTaskList = 0;
|
---|
2869 | }
|
---|
2870 |
|
---|
2871 | /* Hide the window */
|
---|
2872 | if(IsWindowVisible(getWindowHandle()))
|
---|
2873 | {
|
---|
2874 | SetWindowPos(0, 0, 0, 0, 0, SWP_HIDEWINDOW |
|
---|
2875 | SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE);
|
---|
2876 | if(!::IsWindow(hwnd))
|
---|
2877 | {
|
---|
2878 | return TRUE;
|
---|
2879 | }
|
---|
2880 | }
|
---|
2881 | dprintf(("DestroyWindow %x -> HIDDEN", hwnd));
|
---|
2882 |
|
---|
2883 | // check the handle for the last active popup window
|
---|
2884 | Win32BaseWindow* owner = getOwner();
|
---|
2885 | if (NULL != owner)
|
---|
2886 | {
|
---|
2887 | if (owner->getLastActive() == hwnd)
|
---|
2888 | owner->setLastActive( owner->getWindowHandle() );
|
---|
2889 |
|
---|
2890 | //SvL: Not sure this is correct, but it solves the problem of reassigning
|
---|
2891 | // activation. A disabled window will never be activated ->
|
---|
2892 | // possible that the wrong window is chosen by PM.
|
---|
2893 | // PM chooses another window to be activated before WM_DESTROY is
|
---|
2894 | // sent. VPC enables the owner when it receives that message,
|
---|
2895 | // but by then it's too late.
|
---|
2896 | // (MFC created modeless dialog)
|
---|
2897 | //TODO: This might be the wrong place to do it. EndDialog is called,
|
---|
2898 | // so perhaps it should be done there. (although Wine only
|
---|
2899 | // enables the owner if the dialog is modal)
|
---|
2900 | ::EnableWindow(owner->getWindowHandle(), 1);
|
---|
2901 | }
|
---|
2902 |
|
---|
2903 | fDestroyWindowCalled = TRUE;
|
---|
2904 |
|
---|
2905 | //hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
|
---|
2906 | // handler; must postpone it
|
---|
2907 | if(fChildDestructionInProgress) {
|
---|
2908 | dprintf(("Postponing parent destruction because of dying child"));
|
---|
2909 | OSLibPostMessageDirect(OS2HwndFrame, WIN32APP_POSTPONEDESTROY, 0, 0);
|
---|
2910 | return TRUE;
|
---|
2911 | }
|
---|
2912 |
|
---|
2913 | BOOL fOldChildDestructionInProgress = FALSE;
|
---|
2914 | if(GetParent()) {
|
---|
2915 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(GetParent());
|
---|
2916 | if(window) {
|
---|
2917 | fOldChildDestructionInProgress = window->IsChildDestructionInProgress();
|
---|
2918 | window->SetChildDestructionInProgress(TRUE);
|
---|
2919 | RELEASE_WNDOBJ(window);
|
---|
2920 | }
|
---|
2921 | }
|
---|
2922 | //hack end
|
---|
2923 |
|
---|
2924 | BOOL ret = OSLibWinDestroyWindow(OS2HwndFrame);
|
---|
2925 |
|
---|
2926 | //hack alert; PM crashes if child calls DestroyWindow for parent/owner in WM_DESTROY
|
---|
2927 | // handler; must postpone it
|
---|
2928 | if(GetParent()) {
|
---|
2929 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(GetParent());
|
---|
2930 | if(window) {
|
---|
2931 | window->SetChildDestructionInProgress(fOldChildDestructionInProgress);
|
---|
2932 | RELEASE_WNDOBJ(window);
|
---|
2933 | }
|
---|
2934 | }
|
---|
2935 | //hack end
|
---|
2936 | return ret;
|
---|
2937 | }
|
---|
2938 | //******************************************************************************
|
---|
2939 | //******************************************************************************
|
---|
2940 | Win32BaseWindow *Win32BaseWindow::getParent()
|
---|
2941 | {
|
---|
2942 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
---|
2943 | //experiment
|
---|
2944 | #if 0
|
---|
2945 | return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
|
---|
2946 | #else
|
---|
2947 | return wndparent;
|
---|
2948 | #endif
|
---|
2949 | }
|
---|
2950 | //******************************************************************************
|
---|
2951 | // Win32BaseWindow::GetParent
|
---|
2952 | //
|
---|
2953 | // If the window is a child window, then return the parent window handle.
|
---|
2954 | // If it's a popup window, then return the owner
|
---|
2955 | //
|
---|
2956 | // Returns window handle of parent or owner window
|
---|
2957 | //
|
---|
2958 | // Note: does not set last error if no parent (verified in NT4, SP6)
|
---|
2959 | //******************************************************************************
|
---|
2960 | HWND Win32BaseWindow::GetParent()
|
---|
2961 | {
|
---|
2962 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
---|
2963 |
|
---|
2964 | if(getStyle() & WS_CHILD)
|
---|
2965 | {
|
---|
2966 | if(wndparent) {
|
---|
2967 | return wndparent->getWindowHandle();
|
---|
2968 | }
|
---|
2969 | dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
|
---|
2970 | DebugInt3();
|
---|
2971 | return 0;
|
---|
2972 | }
|
---|
2973 | else
|
---|
2974 | if(getStyle() & WS_POPUP)
|
---|
2975 | return (getOwner()) ? getOwner()->getWindowHandle() : 0;
|
---|
2976 | else return 0;
|
---|
2977 | }
|
---|
2978 | //******************************************************************************
|
---|
2979 | //******************************************************************************
|
---|
2980 | HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
|
---|
2981 | {
|
---|
2982 | HWND oldhwnd;
|
---|
2983 | Win32BaseWindow *newparent;
|
---|
2984 | Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
|
---|
2985 | BOOL fShow = FALSE;
|
---|
2986 |
|
---|
2987 | if(oldparent) {
|
---|
2988 | oldhwnd = oldparent->getWindowHandle();
|
---|
2989 | oldparent->removeChild(this);
|
---|
2990 | }
|
---|
2991 | else oldhwnd = 0;
|
---|
2992 |
|
---|
2993 | /* Windows hides the window first, then shows it again
|
---|
2994 | * including the WM_SHOWWINDOW messages and all */
|
---|
2995 | if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
|
---|
2996 | ShowWindow(SW_HIDE);
|
---|
2997 | fShow = TRUE;
|
---|
2998 | }
|
---|
2999 | if(oldparent) {
|
---|
3000 | //release parent here (increased refcount during creation)
|
---|
3001 | RELEASE_WNDOBJ(oldparent);
|
---|
3002 | }
|
---|
3003 | newparent = GetWindowFromHandle(hwndNewParent);
|
---|
3004 | if(newparent && !newparent->isDesktopWindow())
|
---|
3005 | {
|
---|
3006 | setParent(newparent);
|
---|
3007 | getParent()->addChild(this);
|
---|
3008 | fParentChange = TRUE;
|
---|
3009 | // in case we haven't finished creating the window whose parent we're
|
---|
3010 | // setting here, the OS/2 HWND might not exist yet and we call the PM
|
---|
3011 | // API with a NULLHANDLE - no problem
|
---|
3012 | // when we create the OS/2 window lateron, we will create it with the
|
---|
3013 | // right parent anyway.
|
---|
3014 | OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
|
---|
3015 | if(!(getStyle() & WS_CHILD))
|
---|
3016 | {
|
---|
3017 | if(getWindowId())
|
---|
3018 | {
|
---|
3019 | DestroyMenu( (HMENU) getWindowId() );
|
---|
3020 | setWindowId(0);
|
---|
3021 | }
|
---|
3022 | }
|
---|
3023 | //SvL: Even though the win32 coordinates might not change, the PM
|
---|
3024 | // coordinates can. We must make sure the control stays at the
|
---|
3025 | // same position (y) relative to the (new) parent.
|
---|
3026 | // TODO: shouldn't we check the state of the window and not do it in INIT state?
|
---|
3027 | SetWindowPos(HWND_TOPMOST, rectWindow.left, rectWindow.top, 0, 0,
|
---|
3028 | SWP_NOACTIVATE|SWP_NOSIZE);
|
---|
3029 | fParentChange = FALSE;
|
---|
3030 | }
|
---|
3031 | else {
|
---|
3032 | if(newparent) RELEASE_WNDOBJ(newparent);
|
---|
3033 |
|
---|
3034 | setParent(windowDesktop);
|
---|
3035 | windowDesktop->addRef();
|
---|
3036 | windowDesktop->addChild(this);
|
---|
3037 | OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
|
---|
3038 |
|
---|
3039 | //Do not change the window id!
|
---|
3040 | //// setWindowId(0);
|
---|
3041 | }
|
---|
3042 | /* SetParent additionally needs to make hwndChild the topmost window
|
---|
3043 | in the x-order and send the expected WM_WINDOWPOSCHANGING and
|
---|
3044 | WM_WINDOWPOSCHANGED notification messages.
|
---|
3045 | */
|
---|
3046 | if(state >= STATE_PRE_WMNCCREATE) {
|
---|
3047 | SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
|
---|
3048 | SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
|
---|
3049 |
|
---|
3050 | /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
|
---|
3051 | * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
|
---|
3052 | }
|
---|
3053 | return oldhwnd;
|
---|
3054 | }
|
---|
3055 | //******************************************************************************
|
---|
3056 | //******************************************************************************
|
---|
3057 | BOOL Win32BaseWindow::IsChild(HWND hwndParent)
|
---|
3058 | {
|
---|
3059 | // PH: Optimizer won't unroll calls to getParent() even
|
---|
3060 | // in release build.
|
---|
3061 | Win32BaseWindow *_parent = getParent();
|
---|
3062 |
|
---|
3063 | if(_parent)
|
---|
3064 | {
|
---|
3065 | if(_parent->getWindowHandle() == hwndParent)
|
---|
3066 | return TRUE;
|
---|
3067 |
|
---|
3068 | return _parent->IsChild(hwndParent);
|
---|
3069 | }
|
---|
3070 | else
|
---|
3071 | return 0;
|
---|
3072 | }
|
---|
3073 | //******************************************************************************
|
---|
3074 | //******************************************************************************
|
---|
3075 | HWND Win32BaseWindow::GetTopWindow()
|
---|
3076 | {
|
---|
3077 | HWND hwndTop;
|
---|
3078 | Win32BaseWindow *topwindow;
|
---|
3079 |
|
---|
3080 | hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
|
---|
3081 | if(!isDesktopWindow())
|
---|
3082 | {
|
---|
3083 | topwindow = GetWindowFromOS2FrameHandle(hwndTop);
|
---|
3084 | //Note: GetTopWindow can't return a window that hasn't processed
|
---|
3085 | // WM_NCCREATE yet (verified in NT4, SP6)
|
---|
3086 | if(topwindow) {
|
---|
3087 | if(topwindow->state >= STATE_POST_WMNCCREATE) {
|
---|
3088 | hwndTop = topwindow->getWindowHandle();
|
---|
3089 | }
|
---|
3090 | else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
|
---|
3091 | RELEASE_WNDOBJ(topwindow);
|
---|
3092 | return hwndTop;
|
---|
3093 | }
|
---|
3094 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
---|
3095 | return 0;
|
---|
3096 | }
|
---|
3097 | while(hwndTop) {
|
---|
3098 | topwindow = GetWindowFromOS2FrameHandle(hwndTop);
|
---|
3099 | //Note: GetTopWindow can't return a window that hasn't processed
|
---|
3100 | // WM_NCCREATE yet (verified in NT4, SP6)
|
---|
3101 | if(topwindow) {
|
---|
3102 | if(topwindow->state >= STATE_POST_WMNCCREATE) {
|
---|
3103 | hwndTop = topwindow->getWindowHandle();
|
---|
3104 | }
|
---|
3105 | else hwndTop = topwindow->GetWindow(GW_HWNDNEXT);
|
---|
3106 | RELEASE_WNDOBJ(topwindow);
|
---|
3107 | return hwndTop;
|
---|
3108 | }
|
---|
3109 | if(topwindow) RELEASE_WNDOBJ(topwindow);
|
---|
3110 | hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
|
---|
3111 | }
|
---|
3112 |
|
---|
3113 | return 0;
|
---|
3114 | }
|
---|
3115 | //******************************************************************************
|
---|
3116 | // Get the top-level parent for a child window.
|
---|
3117 | //******************************************************************************
|
---|
3118 | HWND Win32BaseWindow::GetTopParent()
|
---|
3119 | {
|
---|
3120 | Win32BaseWindow *window = this;
|
---|
3121 | HWND hwndTopParent = 0;
|
---|
3122 |
|
---|
3123 | lock();
|
---|
3124 | while(window && (window->getStyle() & WS_CHILD))
|
---|
3125 | {
|
---|
3126 | window = window->getParent();
|
---|
3127 | }
|
---|
3128 | if(window) {
|
---|
3129 | hwndTopParent = window->getWindowHandle();
|
---|
3130 | }
|
---|
3131 | unlock();
|
---|
3132 | return hwndTopParent;
|
---|
3133 | }
|
---|
3134 | //******************************************************************************
|
---|
3135 | //TODO: Should not enumerate children that are created during the enumeration!
|
---|
3136 | //TODO: Do this more efficiently
|
---|
3137 | //******************************************************************************
|
---|
3138 | BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
3139 | {
|
---|
3140 | BOOL rc = TRUE;
|
---|
3141 | HWND hwnd;
|
---|
3142 | Win32BaseWindow *prevchild = 0, *child = 0;
|
---|
3143 |
|
---|
3144 | dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
|
---|
3145 | lock();
|
---|
3146 | for (child = (Win32BaseWindow *)getFirstChild(); child != NULL; child = (Win32BaseWindow *)child->getNextChild())
|
---|
3147 | {
|
---|
3148 | dprintf(("EnumChildWindows: enumerating child %x (owner %x; parent %x)", child->getWindowHandle(), (child->getOwner()) ? child->getOwner()->getWindowHandle() : 0, getWindowHandle()));
|
---|
3149 | hwnd = child->getWindowHandle();
|
---|
3150 | if(child->IsWindowDestroyed() || child->getOwner()) {
|
---|
3151 | continue; //shouldn't have an owner (Wine)
|
---|
3152 | }
|
---|
3153 | child->addRef();
|
---|
3154 | unlock();
|
---|
3155 | if(WrapCallback2((WNDPROC)lpfn, hwnd, lParam) == FALSE)
|
---|
3156 | {
|
---|
3157 | child->release();
|
---|
3158 | return FALSE;
|
---|
3159 | }
|
---|
3160 | child->release();
|
---|
3161 | lock();
|
---|
3162 | //check if the window still exists
|
---|
3163 | if(!::IsWindow(hwnd))
|
---|
3164 | {
|
---|
3165 | child = prevchild;
|
---|
3166 | if(child == NULL) break;
|
---|
3167 | continue;
|
---|
3168 | }
|
---|
3169 | if(child->getFirstChild() != NULL)
|
---|
3170 | {
|
---|
3171 | dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
|
---|
3172 | child->addRef();
|
---|
3173 | unlock();
|
---|
3174 | if(child->EnumChildWindows(lpfn, lParam) == FALSE)
|
---|
3175 | {
|
---|
3176 | child->release();
|
---|
3177 | return FALSE;
|
---|
3178 | }
|
---|
3179 | child->release();
|
---|
3180 | lock();
|
---|
3181 | }
|
---|
3182 | prevchild = child;
|
---|
3183 | }
|
---|
3184 | unlock();
|
---|
3185 | return rc;
|
---|
3186 | }
|
---|
3187 | //******************************************************************************
|
---|
3188 | //Enumerate first-level children only and check thread id
|
---|
3189 | //NOTE: NT4 returns first-level children in Z-order!
|
---|
3190 | //******************************************************************************
|
---|
3191 | BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
3192 | {
|
---|
3193 | Win32BaseWindow *wnd = NULL;
|
---|
3194 | HWND henum, hwnd, hwndWin32;
|
---|
3195 | ULONG tid, pid;
|
---|
3196 | BOOL rc;
|
---|
3197 |
|
---|
3198 | //Enumerate all top-level windows and check the process and thread ids
|
---|
3199 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
---|
3200 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
3201 |
|
---|
3202 | while(hwnd)
|
---|
3203 | {
|
---|
3204 | wnd = GetWindowFromOS2FrameHandle(hwnd);
|
---|
3205 | if(wnd) {
|
---|
3206 | hwndWin32 = wnd->getWindowHandle();
|
---|
3207 | }
|
---|
3208 | else hwndWin32 = 0;
|
---|
3209 |
|
---|
3210 | if(wnd) RELEASE_WNDOBJ(wnd);
|
---|
3211 |
|
---|
3212 | if(hwndWin32) {
|
---|
3213 | OSLibWinQueryWindowProcess(hwnd, &pid, &tid);
|
---|
3214 |
|
---|
3215 | if(dwThreadId == tid) {
|
---|
3216 | dprintf(("EnumThreadWindows: Found Window %x", hwndWin32));
|
---|
3217 | if((rc = WrapCallback2((WNDPROC)lpfn, hwndWin32, lParam)) == FALSE) {
|
---|
3218 | break;
|
---|
3219 | }
|
---|
3220 | }
|
---|
3221 | }
|
---|
3222 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
3223 | }
|
---|
3224 | OSLibWinEndEnumWindows(henum);
|
---|
3225 | return TRUE;
|
---|
3226 | }
|
---|
3227 | //******************************************************************************
|
---|
3228 | //Enumerate first-level children only
|
---|
3229 | //******************************************************************************
|
---|
3230 | BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
3231 | {
|
---|
3232 | Win32BaseWindow *window;
|
---|
3233 | BOOL rc;
|
---|
3234 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
|
---|
3235 | DWORD dwStyle;
|
---|
3236 |
|
---|
3237 | dprintf(("EnumWindows %x %x", lpfn, lParam));
|
---|
3238 |
|
---|
3239 | for(int i=0;i<MAX_WINDOW_HANDLES;i++)
|
---|
3240 | {
|
---|
3241 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
3242 | if(window) {
|
---|
3243 | if(window->getWindowHandle() != hwnd) {
|
---|
3244 | dprintf(("CORRUPT WINDOW %x %x", window, hwnd));
|
---|
3245 | }
|
---|
3246 | RELEASE_WNDOBJ(window);
|
---|
3247 | dwStyle = ::GetWindowLongA(hwnd, GWL_STYLE);
|
---|
3248 | if ((dwStyle & WS_POPUP) || ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
---|
3249 | {
|
---|
3250 | dprintf2(("EnumWindows: Found Window %x", hwnd));
|
---|
3251 | if((rc = WrapCallback2((WNDPROC)lpfn, hwnd, lParam)) == FALSE) {
|
---|
3252 | break;
|
---|
3253 | }
|
---|
3254 | }
|
---|
3255 | }
|
---|
3256 | hwnd++;
|
---|
3257 | }
|
---|
3258 | return TRUE;
|
---|
3259 | }
|
---|
3260 | //******************************************************************************
|
---|
3261 | //******************************************************************************
|
---|
3262 | HWND Win32BaseWindow::FindWindowById(int id)
|
---|
3263 | {
|
---|
3264 | HWND hwnd;
|
---|
3265 |
|
---|
3266 | lock();
|
---|
3267 | for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
---|
3268 | {
|
---|
3269 | if (child->getWindowId() == id)
|
---|
3270 | {
|
---|
3271 | hwnd = child->getWindowHandle();
|
---|
3272 | unlock();
|
---|
3273 | return hwnd;
|
---|
3274 | }
|
---|
3275 | }
|
---|
3276 | unlock();
|
---|
3277 | return 0;
|
---|
3278 | }
|
---|
3279 | //******************************************************************************
|
---|
3280 | //TODO:
|
---|
3281 | //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
|
---|
3282 | //the current process owns them.
|
---|
3283 | //******************************************************************************
|
---|
3284 | HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
|
---|
3285 | {
|
---|
3286 | Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
|
---|
3287 | Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
|
---|
3288 | Win32BaseWindow *firstchild = child;
|
---|
3289 |
|
---|
3290 | dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
|
---|
3291 | if((hwndParent != 0 && !parent) ||
|
---|
3292 | (hwndChildAfter != 0 && !child) ||
|
---|
3293 | (hwndParent == 0 && hwndChildAfter != 0))
|
---|
3294 | {
|
---|
3295 | if(parent) RELEASE_WNDOBJ(parent);
|
---|
3296 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
---|
3297 | dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
|
---|
3298 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
3299 | return 0;
|
---|
3300 | }
|
---|
3301 | SetLastError(0);
|
---|
3302 | if(hwndParent != 0)
|
---|
3303 | {//if the current process owns the window, just do a quick search
|
---|
3304 | lock(&critsect);
|
---|
3305 | child = (Win32BaseWindow *)parent->getFirstChild();
|
---|
3306 | if(hwndChildAfter != 0)
|
---|
3307 | {
|
---|
3308 | while(child)
|
---|
3309 | {
|
---|
3310 | if(child->getWindowHandle() == hwndChildAfter)
|
---|
3311 | {
|
---|
3312 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
3313 | break;
|
---|
3314 | }
|
---|
3315 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
3316 | }
|
---|
3317 | }
|
---|
3318 | while(child)
|
---|
3319 | {
|
---|
3320 | //According to Wine, the class doesn't need to be specified
|
---|
3321 | if((!atom || child->getWindowClass()->getAtom() == atom) &&
|
---|
3322 | (!lpszWindow || child->hasWindowName(lpszWindow)))
|
---|
3323 | {
|
---|
3324 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
---|
3325 | HWND hwndChild = child->getWindowHandle();
|
---|
3326 | unlock(&critsect);
|
---|
3327 | if(parent) RELEASE_WNDOBJ(parent);
|
---|
3328 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
---|
3329 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
---|
3330 | return hwndChild;
|
---|
3331 | }
|
---|
3332 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
3333 | }
|
---|
3334 | unlock(&critsect);
|
---|
3335 | if(parent) RELEASE_WNDOBJ(parent);
|
---|
3336 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
---|
3337 | }
|
---|
3338 | else {
|
---|
3339 | Win32BaseWindow *wnd;
|
---|
3340 | HWND henum, hwnd;
|
---|
3341 |
|
---|
3342 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
---|
3343 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
3344 |
|
---|
3345 | while(hwnd)
|
---|
3346 | {
|
---|
3347 | wnd = GetWindowFromOS2FrameHandle(hwnd);
|
---|
3348 | if(wnd) {
|
---|
3349 | //According to Wine, the class doesn't need to be specified
|
---|
3350 | if((!atom || wnd->getWindowClass()->getAtom() == atom) &&
|
---|
3351 | (!lpszWindow || wnd->hasWindowName(lpszWindow)))
|
---|
3352 | {
|
---|
3353 | OSLibWinEndEnumWindows(henum);
|
---|
3354 | dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
|
---|
3355 | HWND hwndret = wnd->getWindowHandle();
|
---|
3356 | RELEASE_WNDOBJ(wnd);
|
---|
3357 | return hwndret;
|
---|
3358 | }
|
---|
3359 | RELEASE_WNDOBJ(wnd);
|
---|
3360 | }
|
---|
3361 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
3362 | }
|
---|
3363 | OSLibWinEndEnumWindows(henum);
|
---|
3364 | if(parent) RELEASE_WNDOBJ(parent);
|
---|
3365 | if(firstchild) RELEASE_WNDOBJ(firstchild);
|
---|
3366 | }
|
---|
3367 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
|
---|
3368 | return 0;
|
---|
3369 | }
|
---|
3370 | //******************************************************************************
|
---|
3371 | //******************************************************************************
|
---|
3372 | HWND Win32BaseWindow::GetWindow(UINT uCmd)
|
---|
3373 | {
|
---|
3374 | HWND hwndRelated = 0;
|
---|
3375 | Win32BaseWindow *window;
|
---|
3376 |
|
---|
3377 | switch(uCmd)
|
---|
3378 | {
|
---|
3379 | case GW_HWNDFIRST:
|
---|
3380 | window = (Win32BaseWindow *)getParent();
|
---|
3381 | if(window)
|
---|
3382 | {
|
---|
3383 | hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
|
---|
3384 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
3385 | if(window) {
|
---|
3386 | hwndRelated = window->getWindowHandle();
|
---|
3387 | RELEASE_WNDOBJ(window);
|
---|
3388 | }
|
---|
3389 | else hwndRelated = 0;
|
---|
3390 | }
|
---|
3391 | else {
|
---|
3392 | dprintf(("WARNING: GW_HWNDFIRST not correctly implemented for toplevel/most windows!"));
|
---|
3393 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
---|
3394 | }
|
---|
3395 | break;
|
---|
3396 |
|
---|
3397 | case GW_HWNDLAST:
|
---|
3398 | window = (Win32BaseWindow *)getParent();
|
---|
3399 | if(window) {
|
---|
3400 | hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_BOTTOM);
|
---|
3401 | dprintf(("os2 handle %x", hwndRelated));
|
---|
3402 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
3403 | if(window) {
|
---|
3404 | hwndRelated = window->getWindowHandle();
|
---|
3405 | RELEASE_WNDOBJ(window);
|
---|
3406 | }
|
---|
3407 | else hwndRelated = 0;
|
---|
3408 | }
|
---|
3409 | else {
|
---|
3410 | dprintf(("WARNING: GW_HWNDLAST not correctly implemented for toplevel/most windows!"));
|
---|
3411 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
---|
3412 | }
|
---|
3413 | break;
|
---|
3414 |
|
---|
3415 | case GW_HWNDNEXT:
|
---|
3416 | if(getParent()) {
|
---|
3417 | hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_NEXT);
|
---|
3418 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
3419 | if(window) {
|
---|
3420 | hwndRelated = window->getWindowHandle();
|
---|
3421 | RELEASE_WNDOBJ(window);
|
---|
3422 | }
|
---|
3423 | else hwndRelated = 0;
|
---|
3424 | }
|
---|
3425 | else {
|
---|
3426 | dprintf(("WARNING: GW_HWNDNEXT not correctly implemented for toplevel/most windows!"));
|
---|
3427 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
---|
3428 | }
|
---|
3429 | break;
|
---|
3430 |
|
---|
3431 | case GW_HWNDPREV:
|
---|
3432 | if(getParent()) {
|
---|
3433 | hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_PREV);
|
---|
3434 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
3435 | if(window) {
|
---|
3436 | hwndRelated = window->getWindowHandle();
|
---|
3437 | RELEASE_WNDOBJ(window);
|
---|
3438 | }
|
---|
3439 | else hwndRelated = 0;
|
---|
3440 | }
|
---|
3441 | else {
|
---|
3442 | dprintf(("WARNING: GW_HWNDPREV not correctly implemented for toplevel/most windows!"));
|
---|
3443 | hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
|
---|
3444 | }
|
---|
3445 | break;
|
---|
3446 |
|
---|
3447 | case GW_OWNER:
|
---|
3448 | {
|
---|
3449 | Win32BaseWindow *owner = getOwner();
|
---|
3450 | if(owner) {
|
---|
3451 | hwndRelated = owner->getWindowHandle();
|
---|
3452 | }
|
---|
3453 | break;
|
---|
3454 | }
|
---|
3455 |
|
---|
3456 | case GW_CHILD:
|
---|
3457 | hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
|
---|
3458 | window = GetWindowFromOS2FrameHandle(hwndRelated);
|
---|
3459 |
|
---|
3460 | //Before a window has processed WM_NCCREATE:
|
---|
3461 | //- GetWindow(parent, GW_CHILD) can't return that window handle
|
---|
3462 | //(verified in NT4, SP6)
|
---|
3463 | if(window) {
|
---|
3464 | if(window->state >= STATE_POST_WMNCCREATE) {
|
---|
3465 | hwndRelated = window->getWindowHandle();
|
---|
3466 | RELEASE_WNDOBJ(window);
|
---|
3467 | }
|
---|
3468 | else {
|
---|
3469 | hwndRelated = window->GetWindow(GW_HWNDNEXT);
|
---|
3470 | RELEASE_WNDOBJ(window);
|
---|
3471 | }
|
---|
3472 | }
|
---|
3473 | else hwndRelated = 0;
|
---|
3474 |
|
---|
3475 | break;
|
---|
3476 |
|
---|
3477 | //for internal use only
|
---|
3478 | case GW_HWNDNEXTCHILD:
|
---|
3479 | lock();
|
---|
3480 | window = (Win32BaseWindow *)getNextChild();
|
---|
3481 | if(window) {
|
---|
3482 | hwndRelated = window->getWindowHandle();
|
---|
3483 | }
|
---|
3484 | else hwndRelated = 0;
|
---|
3485 | unlock();
|
---|
3486 | break;
|
---|
3487 |
|
---|
3488 | case GW_HWNDPREVCHILD:
|
---|
3489 | DebugInt3();
|
---|
3490 | break;
|
---|
3491 |
|
---|
3492 | case GW_HWNDFIRSTCHILD:
|
---|
3493 | lock();
|
---|
3494 | window = (Win32BaseWindow *)getFirstChild();
|
---|
3495 | if(window) {
|
---|
3496 | hwndRelated = window->getWindowHandle();
|
---|
3497 | }
|
---|
3498 | else hwndRelated = 0;
|
---|
3499 | unlock();
|
---|
3500 | break;
|
---|
3501 |
|
---|
3502 | case GW_HWNDLASTCHILD:
|
---|
3503 | lock();
|
---|
3504 | window = (Win32BaseWindow *)getFirstChild();
|
---|
3505 | if(window) {
|
---|
3506 | while (window->getNextChild())
|
---|
3507 | {
|
---|
3508 | window = (Win32BaseWindow *)window->getNextChild();
|
---|
3509 | }
|
---|
3510 | hwndRelated = window->getWindowHandle();
|
---|
3511 | }
|
---|
3512 | else hwndRelated = 0;
|
---|
3513 | unlock();
|
---|
3514 | break;
|
---|
3515 | }
|
---|
3516 | end:
|
---|
3517 | dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
|
---|
3518 | return hwndRelated;
|
---|
3519 | }
|
---|
3520 | //******************************************************************************
|
---|
3521 | //******************************************************************************
|
---|
3522 | PRECT Win32BaseWindow::getWindowRect()
|
---|
3523 | {
|
---|
3524 | return &rectWindow;
|
---|
3525 | }
|
---|
3526 | //******************************************************************************
|
---|
3527 | //******************************************************************************
|
---|
3528 | HWND Win32BaseWindow::SetActiveWindow()
|
---|
3529 | {
|
---|
3530 | HWND hwndActive;
|
---|
3531 |
|
---|
3532 | dprintf(("SetActiveWindow %x", getWindowHandle()));
|
---|
3533 | if(getStyle() & WS_CHILD) {
|
---|
3534 | // if(getStyle() & (WS_DISABLED | WS_CHILD)) {
|
---|
3535 | dprintf(("WARNING: Window is a child or disabled"));
|
---|
3536 | return 0;
|
---|
3537 | }
|
---|
3538 |
|
---|
3539 | if(GetActiveWindow() == getWindowHandle()) {
|
---|
3540 | dprintf(("Window already active"));
|
---|
3541 | return getWindowHandle();
|
---|
3542 | }
|
---|
3543 | if (HOOK_IsHooked( WH_CBT ))
|
---|
3544 | {
|
---|
3545 | CBTACTIVATESTRUCT cbta;
|
---|
3546 | LRESULT ret;
|
---|
3547 |
|
---|
3548 | cbta.fMouse = FALSE;
|
---|
3549 | cbta.hWndActive = GetActiveWindow();
|
---|
3550 | ret = HOOK_CallHooksA(WH_CBT, HCBT_ACTIVATE, getWindowHandle(), (LPARAM)&cbta);
|
---|
3551 | if(ret)
|
---|
3552 | {
|
---|
3553 | dprintf(("SetActiveWindow %x, CBT hook cancelled operation", getWindowHandle()));
|
---|
3554 | return cbta.hWndActive;
|
---|
3555 | }
|
---|
3556 | }
|
---|
3557 | SetWindowPos(HWND_TOP, 0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
|
---|
3558 |
|
---|
3559 | // if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) {
|
---|
3560 | // dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd));
|
---|
3561 | // }
|
---|
3562 | hwndActive = GetActiveWindow();
|
---|
3563 | return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
|
---|
3564 | }
|
---|
3565 | //******************************************************************************
|
---|
3566 | //Used to change active status of an mdi window
|
---|
3567 | //******************************************************************************
|
---|
3568 | BOOL Win32BaseWindow::DeactivateChildWindow()
|
---|
3569 | {
|
---|
3570 | /* child windows get a WM_CHILDACTIVATE message */
|
---|
3571 | if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
|
---|
3572 | {
|
---|
3573 | ULONG flags = OSLibWinGetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS);
|
---|
3574 | OSLibWinSetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS, (flags & ~WINDOWFLAG_ACTIVE));
|
---|
3575 | return TRUE;
|
---|
3576 | }
|
---|
3577 | DebugInt3(); //should not be called for non-child window
|
---|
3578 | return FALSE;
|
---|
3579 | }
|
---|
3580 | //******************************************************************************
|
---|
3581 | //WM_ENABLE is sent to hwnd, but not to its children (as it should be)
|
---|
3582 | //******************************************************************************
|
---|
3583 | BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
|
---|
3584 | {
|
---|
3585 | BOOL rc;
|
---|
3586 |
|
---|
3587 | dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
|
---|
3588 | //return true if previous state was disabled, else false (sdk docs)
|
---|
3589 | rc = (getStyle() & WS_DISABLED) != 0;
|
---|
3590 | if(rc && !fEnable) {
|
---|
3591 | SendMessageA(getWindowHandle(), WM_CANCELMODE, 0, 0);
|
---|
3592 | }
|
---|
3593 | OSLibWinEnableWindow(OS2HwndFrame, fEnable);
|
---|
3594 | if(fEnable == FALSE) {
|
---|
3595 | //SvL: No need to clear focus as PM already does this
|
---|
3596 | if(getWindowHandle() == GetCapture()) {
|
---|
3597 | ReleaseCapture(); /* A disabled window can't capture the mouse */
|
---|
3598 | dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
|
---|
3599 | }
|
---|
3600 | }
|
---|
3601 | return rc;
|
---|
3602 | }
|
---|
3603 | //******************************************************************************
|
---|
3604 | //******************************************************************************
|
---|
3605 | BOOL Win32BaseWindow::CloseWindow()
|
---|
3606 | {
|
---|
3607 | if (::GetWindowLongW( getWindowHandle() , GWL_STYLE ) & WS_CHILD) return FALSE;
|
---|
3608 | ShowWindow( SW_MINIMIZE );
|
---|
3609 | return TRUE;
|
---|
3610 | }
|
---|
3611 | //******************************************************************************
|
---|
3612 | //TODO: Not be 100% correct; should return active window of current thread
|
---|
3613 | // or NULL when there is none -> WinQueryActiveWindow just returns
|
---|
3614 | // the current active window
|
---|
3615 | //******************************************************************************
|
---|
3616 | HWND Win32BaseWindow::GetActiveWindow()
|
---|
3617 | {
|
---|
3618 | HWND hwndActive;
|
---|
3619 |
|
---|
3620 | hwndActive = OSLibWinQueryActiveWindow();
|
---|
3621 | return OS2ToWin32Handle(hwndActive);
|
---|
3622 | }
|
---|
3623 | //******************************************************************************
|
---|
3624 | //******************************************************************************
|
---|
3625 | BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
|
---|
3626 | {
|
---|
3627 | INT len = GetWindowTextLength(fUnicode);
|
---|
3628 | BOOL res;
|
---|
3629 |
|
---|
3630 | if (wndname == NULL)
|
---|
3631 | return (len == 0);
|
---|
3632 |
|
---|
3633 | len++;
|
---|
3634 | if (fUnicode)
|
---|
3635 | {
|
---|
3636 | WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
---|
3637 |
|
---|
3638 | GetWindowTextW(text,len);
|
---|
3639 | res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
|
---|
3640 | free(text);
|
---|
3641 | }
|
---|
3642 | else
|
---|
3643 | {
|
---|
3644 | CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
|
---|
3645 |
|
---|
3646 | GetWindowTextA(text,len);
|
---|
3647 | res = (strcmp(text,wndname) == 0);
|
---|
3648 | free(text);
|
---|
3649 | }
|
---|
3650 |
|
---|
3651 | return res;
|
---|
3652 | }
|
---|
3653 | //******************************************************************************
|
---|
3654 | //******************************************************************************
|
---|
3655 | CHAR *Win32BaseWindow::getWindowNamePtrA()
|
---|
3656 | {
|
---|
3657 | INT len = GetWindowTextLength(FALSE);
|
---|
3658 | CHAR *text;
|
---|
3659 |
|
---|
3660 | if (len == 0) return NULL;
|
---|
3661 | len++;
|
---|
3662 | text = (CHAR*)malloc(len*sizeof(CHAR));
|
---|
3663 | GetWindowTextA(text,len);
|
---|
3664 |
|
---|
3665 | return text;
|
---|
3666 | }
|
---|
3667 | //******************************************************************************
|
---|
3668 | //******************************************************************************
|
---|
3669 | WCHAR *Win32BaseWindow::getWindowNamePtrW()
|
---|
3670 | {
|
---|
3671 | INT len = GetWindowTextLength(TRUE);
|
---|
3672 | WCHAR *text;
|
---|
3673 |
|
---|
3674 | if (len == 0) return NULL;
|
---|
3675 | len++;
|
---|
3676 | text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
---|
3677 | GetWindowTextW(text,len);
|
---|
3678 |
|
---|
3679 | return text;
|
---|
3680 | }
|
---|
3681 | //******************************************************************************
|
---|
3682 | //******************************************************************************
|
---|
3683 | VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
|
---|
3684 | {
|
---|
3685 | if (namePtr) free(namePtr);
|
---|
3686 | }
|
---|
3687 | //******************************************************************************
|
---|
3688 | //When using this API for a window that was created by a different process, NT
|
---|
3689 | //does NOT send WM_GETTEXTLENGTH.
|
---|
3690 | //******************************************************************************
|
---|
3691 | int Win32BaseWindow::GetWindowTextLength(BOOL fUnicode)
|
---|
3692 | {
|
---|
3693 | //if the destination window is created by this process, send message
|
---|
3694 | if(dwProcessId == currentProcessId)
|
---|
3695 | {
|
---|
3696 | if(fUnicode) {
|
---|
3697 | return SendMessageW(getWindowHandle(), WM_GETTEXTLENGTH,0,0);
|
---|
3698 | }
|
---|
3699 | else return SendMessageA(getWindowHandle(), WM_GETTEXTLENGTH,0,0);
|
---|
3700 | }
|
---|
3701 | //else get data directory from window structure
|
---|
3702 | //TODO: must lock window structure.... (TODO)
|
---|
3703 | return fUnicode ? windowNameLengthW : windowNameLengthA;
|
---|
3704 | }
|
---|
3705 | //******************************************************************************
|
---|
3706 | //When using this API for a window that was created by a different process, NT
|
---|
3707 | //does NOT send WM_GETTEXT.
|
---|
3708 | //******************************************************************************
|
---|
3709 | int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
|
---|
3710 | {
|
---|
3711 | //if the destination window is created by this process, send message
|
---|
3712 | if(dwProcessId == currentProcessId) {
|
---|
3713 | return SendMessageA(getWindowHandle(),WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
---|
3714 | }
|
---|
3715 |
|
---|
3716 | //else get data directory from window structure
|
---|
3717 | if (!lpsz || !cch) return 0;
|
---|
3718 | if (!windowNameA) lpsz[0] = 0;
|
---|
3719 | else lstrcpynA( lpsz, windowNameA, cch );
|
---|
3720 | return strlen( lpsz );
|
---|
3721 | }
|
---|
3722 | //******************************************************************************
|
---|
3723 | //When using this API for a window that was created by a different process, NT
|
---|
3724 | //does NOT send WM_GETTEXT.
|
---|
3725 | //******************************************************************************
|
---|
3726 | int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
|
---|
3727 | {
|
---|
3728 | //if the destination window is created by this process, send message
|
---|
3729 | if(dwProcessId == currentProcessId) {
|
---|
3730 | return ::SendMessageW(getWindowHandle(), WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
---|
3731 | }
|
---|
3732 | //else get data directory from window structure
|
---|
3733 | if (!lpsz || !cch)
|
---|
3734 | return 0;
|
---|
3735 | if (!windowNameW)
|
---|
3736 | lpsz[0] = 0;
|
---|
3737 | else
|
---|
3738 | lstrcpynW( lpsz, windowNameW, cch );
|
---|
3739 |
|
---|
3740 | return strlenW( lpsz );
|
---|
3741 | }
|
---|
3742 | //******************************************************************************
|
---|
3743 | //TODO: How does this work when the target window belongs to a different process???
|
---|
3744 | //******************************************************************************
|
---|
3745 | BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
|
---|
3746 | {
|
---|
3747 | return SendMessageA(getWindowHandle(),WM_SETTEXT,0,(LPARAM)lpsz);
|
---|
3748 | }
|
---|
3749 | //******************************************************************************
|
---|
3750 | //******************************************************************************
|
---|
3751 | BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
|
---|
3752 | {
|
---|
3753 | return SendMessageW(getWindowHandle(), WM_SETTEXT,0,(LPARAM)lpsz);
|
---|
3754 | }
|
---|
3755 | //******************************************************************************
|
---|
3756 | //******************************************************************************
|
---|
3757 | LONG Win32BaseWindow::SetWindowLong(int index, ULONG value, BOOL fUnicode)
|
---|
3758 | {
|
---|
3759 | LONG oldval;
|
---|
3760 |
|
---|
3761 | switch(index) {
|
---|
3762 | case GWL_EXSTYLE:
|
---|
3763 | {
|
---|
3764 | STYLESTRUCT ss;
|
---|
3765 |
|
---|
3766 | if(dwExStyle == value) {
|
---|
3767 | oldval = value;
|
---|
3768 | break;
|
---|
3769 | }
|
---|
3770 | ss.styleOld = dwExStyle;
|
---|
3771 | ss.styleNew = value;
|
---|
3772 | dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
|
---|
3773 | SendMessageA(getWindowHandle(),WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
|
---|
3774 | setExStyle(ss.styleNew);
|
---|
3775 | SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
|
---|
3776 |
|
---|
3777 | OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(),
|
---|
3778 | getStyle(), getExStyle(),ss.styleOld);
|
---|
3779 |
|
---|
3780 | oldval = ss.styleOld;
|
---|
3781 | break;
|
---|
3782 | }
|
---|
3783 | case GWL_STYLE:
|
---|
3784 | {
|
---|
3785 | STYLESTRUCT ss;
|
---|
3786 |
|
---|
3787 | //SvL: TODO: Can you change minimize or maximize status here too?
|
---|
3788 |
|
---|
3789 | if(dwStyle == value) {
|
---|
3790 | oldval = value;
|
---|
3791 | break;
|
---|
3792 | }
|
---|
3793 | dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x (%x)", getWindowHandle(), dwStyle, value));
|
---|
3794 |
|
---|
3795 | //Changing WS_CHILD style is allowed
|
---|
3796 | ss.styleOld = getStyle();
|
---|
3797 | ss.styleNew = value;
|
---|
3798 | SendMessageA(getWindowHandle(),WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
|
---|
3799 | setStyle(ss.styleNew);
|
---|
3800 | SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
|
---|
3801 |
|
---|
3802 | OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(),
|
---|
3803 | getStyle(), getExStyle(),ss.styleOld);
|
---|
3804 |
|
---|
3805 | //TODO: Might not be correct to use ShowWindow here
|
---|
3806 | if((ss.styleOld & WS_VISIBLE) != (ss.styleNew & WS_VISIBLE)) {
|
---|
3807 | if(ss.styleNew & WS_VISIBLE)
|
---|
3808 | ShowWindow(SW_SHOWNOACTIVATE);
|
---|
3809 | else ShowWindow(SW_HIDE);
|
---|
3810 | }
|
---|
3811 |
|
---|
3812 | #ifdef DEBUG
|
---|
3813 | PrintWindowStyle(ss.styleNew, 0);
|
---|
3814 | #endif
|
---|
3815 | oldval = ss.styleOld;
|
---|
3816 | break;
|
---|
3817 | }
|
---|
3818 | case GWL_WNDPROC:
|
---|
3819 | {
|
---|
3820 | //Note: Type of SetWindowLong determines new window proc type
|
---|
3821 | // UNLESS the new window proc has already been registered
|
---|
3822 | // (use the old type in that case)
|
---|
3823 | // (VERIFIED in NT 4, SP6)
|
---|
3824 | WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
|
---|
3825 | if(type == WIN_PROC_INVALID) {
|
---|
3826 | type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
|
---|
3827 | }
|
---|
3828 | oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
---|
3829 | dprintf(("SetWindowLong%c GWL_WNDPROC %x old %x new wndproc %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), oldval, value));
|
---|
3830 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
|
---|
3831 | break;
|
---|
3832 | }
|
---|
3833 | case GWL_HINSTANCE:
|
---|
3834 | oldval = hInstance;
|
---|
3835 | hInstance = value;
|
---|
3836 | break;
|
---|
3837 |
|
---|
3838 | case GWL_HWNDPARENT:
|
---|
3839 | dprintf(("GWL_ID GWL_HWNDPARENT %x, new %x", GetParent(), value));
|
---|
3840 | oldval = SetParent((HWND)value);
|
---|
3841 | break;
|
---|
3842 |
|
---|
3843 | case GWL_ID:
|
---|
3844 | dprintf(("GWL_ID old %x, new %x", getWindowId(), value));
|
---|
3845 | oldval = getWindowId();
|
---|
3846 | setWindowId(value);
|
---|
3847 | break;
|
---|
3848 |
|
---|
3849 | case GWL_USERDATA:
|
---|
3850 | oldval = userData;
|
---|
3851 | userData = value;
|
---|
3852 | break;
|
---|
3853 |
|
---|
3854 | default:
|
---|
3855 | if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
|
---|
3856 | {
|
---|
3857 | oldval = *(ULONG *)(userWindowBytes + index);
|
---|
3858 | *(ULONG *)(userWindowBytes + index) = value;
|
---|
3859 | break;
|
---|
3860 | }
|
---|
3861 | dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
---|
3862 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
---|
3863 | return 0;
|
---|
3864 | }
|
---|
3865 | //Note: NT4, SP6 does not set the last error to 0
|
---|
3866 | SetLastError(ERROR_SUCCESS);
|
---|
3867 | dprintf2(("SetWindowLong%c %x %d %x returned %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value, oldval));
|
---|
3868 | return oldval;
|
---|
3869 | }
|
---|
3870 | //******************************************************************************
|
---|
3871 | //******************************************************************************
|
---|
3872 | ULONG Win32BaseWindow::GetWindowLong(int index, BOOL fUnicode)
|
---|
3873 | {
|
---|
3874 | ULONG value;
|
---|
3875 |
|
---|
3876 | switch(index) {
|
---|
3877 | case GWL_EXSTYLE:
|
---|
3878 | value = dwExStyle;
|
---|
3879 | break;
|
---|
3880 | case GWL_STYLE:
|
---|
3881 | value = dwStyle;
|
---|
3882 | break;
|
---|
3883 | case GWL_WNDPROC:
|
---|
3884 | value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
---|
3885 | break;
|
---|
3886 | case GWL_HINSTANCE:
|
---|
3887 | value = hInstance;
|
---|
3888 | break;
|
---|
3889 | case GWL_HWNDPARENT:
|
---|
3890 | value = GetParent();
|
---|
3891 | break;
|
---|
3892 | case GWL_ID:
|
---|
3893 | value = getWindowId();
|
---|
3894 | break;
|
---|
3895 | case GWL_USERDATA:
|
---|
3896 | value = userData;
|
---|
3897 | break;
|
---|
3898 | default:
|
---|
3899 | if(index >= 0 && index + sizeof(ULONG) <= nrUserWindowBytes)
|
---|
3900 | {
|
---|
3901 | value = *(ULONG *)(userWindowBytes + index);
|
---|
3902 | break;
|
---|
3903 | }
|
---|
3904 | dprintf(("WARNING: GetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
---|
3905 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
---|
3906 | return 0;
|
---|
3907 | }
|
---|
3908 | dprintf2(("GetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
---|
3909 | //Note: NT4, SP6 does not set the last error to 0
|
---|
3910 | SetLastError(ERROR_SUCCESS);
|
---|
3911 | return value;
|
---|
3912 | }
|
---|
3913 | //******************************************************************************
|
---|
3914 | //******************************************************************************
|
---|
3915 | WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
|
---|
3916 | {
|
---|
3917 | WORD oldval;
|
---|
3918 |
|
---|
3919 | if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
|
---|
3920 | {
|
---|
3921 | oldval = *(WORD *)(userWindowBytes + index);
|
---|
3922 | *(WORD *)(userWindowBytes + index) = value;
|
---|
3923 | //Note: NT4, SP6 does not set the last error to 0
|
---|
3924 | dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
|
---|
3925 | SetLastError(ERROR_SUCCESS);
|
---|
3926 | return oldval;
|
---|
3927 | }
|
---|
3928 | switch(index)
|
---|
3929 | {
|
---|
3930 | case GWW_HINSTANCE:
|
---|
3931 | oldval = hInstance;
|
---|
3932 | hInstance = value;
|
---|
3933 | break;
|
---|
3934 |
|
---|
3935 | case GWW_HWNDPARENT:
|
---|
3936 | oldval = SetParent((HWND)(WNDHANDLE_MAGIC_HIGHWORD | value));
|
---|
3937 | break;
|
---|
3938 |
|
---|
3939 | case GWW_ID:
|
---|
3940 | oldval = getWindowId();
|
---|
3941 | setWindowId(value);
|
---|
3942 | break;
|
---|
3943 |
|
---|
3944 | default:
|
---|
3945 | dprintf(("WARNING: SetWindowWord %x %d %x returned %x INVALID index!", getWindowHandle(), index, value));
|
---|
3946 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
---|
3947 | return 0;
|
---|
3948 | }
|
---|
3949 | //Note: NT4, SP6 does not set the last error to 0
|
---|
3950 | SetLastError(ERROR_SUCCESS);
|
---|
3951 | dprintf2(("SetWindowWord %x %d %x returned %x", getWindowHandle(), index, value, oldval));
|
---|
3952 | return oldval;
|
---|
3953 | }
|
---|
3954 | //******************************************************************************
|
---|
3955 | //******************************************************************************
|
---|
3956 | WORD Win32BaseWindow::GetWindowWord(int index)
|
---|
3957 | {
|
---|
3958 | if(index >= 0 && index + sizeof(WORD) <= nrUserWindowBytes)
|
---|
3959 | {
|
---|
3960 | //Note: NT4, SP6 does not set the last error to 0
|
---|
3961 | SetLastError(ERROR_SUCCESS);
|
---|
3962 | dprintf2(("GetWindowWord %x %d %x", getWindowHandle(), index, *(WORD *)(userWindowBytes + index)));
|
---|
3963 | return *(WORD *)(userWindowBytes + index);
|
---|
3964 | }
|
---|
3965 | switch(index)
|
---|
3966 | {
|
---|
3967 | case GWW_ID:
|
---|
3968 | if(HIWORD(getWindowId()))
|
---|
3969 | dprintf(("WARNING: GWW_ID: discards high bits of 0x%08x!\n", getWindowId()));
|
---|
3970 | return (WORD)getWindowId();
|
---|
3971 |
|
---|
3972 | case GWW_HWNDPARENT:
|
---|
3973 | dprintf(("WARNING: GWW_HWNDPARENT: discards high bits of 0x%08x!\n", GetParent()));
|
---|
3974 | return (WORD) GetParent();
|
---|
3975 |
|
---|
3976 | case GWW_HINSTANCE:
|
---|
3977 | if (HIWORD(hInstance))
|
---|
3978 | dprintf(("WARNING: GWW_HINSTANCE: discards high bits of 0x%08x!\n", hInstance));
|
---|
3979 | return (WORD)hInstance;
|
---|
3980 | }
|
---|
3981 |
|
---|
3982 | dprintf(("WARNING: GetWindowWord %x %d returned %x INVALID index!", getWindowHandle(), index));
|
---|
3983 | SetLastError(ERROR_INVALID_INDEX); //verified in NT4, SP6
|
---|
3984 | return 0;
|
---|
3985 | }
|
---|
3986 | //******************************************************************************
|
---|
3987 | // Win32BaseWindow::setVisibleRgnNotifyProc
|
---|
3988 | //
|
---|
3989 | // Sets the visible region change notification handler. Called when
|
---|
3990 | // the window receives a WM_VRNDISABLED or WM_VRNENABLED message (PM).
|
---|
3991 | //
|
---|
3992 | // Parameters:
|
---|
3993 | // VISRGN_NOTIFY_PROC lpNotifyProc - notification handler
|
---|
3994 | // DWORD dwUserData - caller supplied parameter for handler invocations
|
---|
3995 | //
|
---|
3996 | // Returns:
|
---|
3997 | // TRUE - Success
|
---|
3998 | // FALSE - Failure
|
---|
3999 | //
|
---|
4000 | //******************************************************************************
|
---|
4001 | BOOL Win32BaseWindow::setVisibleRgnNotifyProc(VISRGN_NOTIFY_PROC lpNotifyProc, DWORD dwUserData)
|
---|
4002 | {
|
---|
4003 | lpVisRgnNotifyProc = lpNotifyProc;
|
---|
4004 | dwVisRgnNotifyParam = dwUserData;
|
---|
4005 | return TRUE;
|
---|
4006 | }
|
---|
4007 | //******************************************************************************
|
---|
4008 | // Win32BaseWindow::callVisibleRgnNotifyProc
|
---|
4009 | //
|
---|
4010 | // Call the visible region change notification handler. Called when
|
---|
4011 | // the window receives a WM_VRNDISABLED or WM_VRNENABLED message (PM).
|
---|
4012 | //
|
---|
4013 | // Parameters:
|
---|
4014 | // BOOL fDrawingAllowed - drawing is allowed or not
|
---|
4015 | //
|
---|
4016 | // Returns:
|
---|
4017 | // TRUE - Success
|
---|
4018 | // FALSE - Failure
|
---|
4019 | //
|
---|
4020 | //******************************************************************************
|
---|
4021 | void Win32BaseWindow::callVisibleRgnNotifyProc(BOOL fDrawingAllowed)
|
---|
4022 | {
|
---|
4023 | if(fDrawingAllowed) {
|
---|
4024 | fWindowLocked = TRUE;
|
---|
4025 | }
|
---|
4026 | else {
|
---|
4027 | fWindowLocked = FALSE;
|
---|
4028 | }
|
---|
4029 | if(lpVisRgnNotifyProc) {
|
---|
4030 | lpVisRgnNotifyProc(getWindowHandle(), fDrawingAllowed, dwVisRgnNotifyParam);
|
---|
4031 | }
|
---|
4032 | }
|
---|
4033 | //******************************************************************************
|
---|
4034 | // Win32BaseWindow::queryOpenDCs
|
---|
4035 | //
|
---|
4036 | // Return the DCs that are currently open for this window
|
---|
4037 | //
|
---|
4038 | // Parameters:
|
---|
4039 | // HDC *phdcWindow - pointer to HDC array (IN)
|
---|
4040 | // int chdcWindow - size of HDC array (IN)
|
---|
4041 | // int *pnrdcs - number of HDCs returned (OUT)
|
---|
4042 | //
|
---|
4043 | // Returns:
|
---|
4044 | // TRUE - Success
|
---|
4045 | // FALSE - Failure
|
---|
4046 | //
|
---|
4047 | //******************************************************************************
|
---|
4048 | BOOL Win32BaseWindow::queryOpenDCs(HDC *phdcWindow, int chdcWindow, int *pnrdcs)
|
---|
4049 | {
|
---|
4050 | if(nrOpenDCs == 0) return FALSE;
|
---|
4051 |
|
---|
4052 | if(chdcWindow < nrOpenDCs) {
|
---|
4053 | DebugInt3();
|
---|
4054 | return FALSE;
|
---|
4055 | }
|
---|
4056 |
|
---|
4057 | lock(&critsect);
|
---|
4058 | int j = 0;
|
---|
4059 | for(int i=0;i<MAX_OPENDCS && j<nrOpenDCs;i++) {
|
---|
4060 | if(hdcWindow[i] != 0) {
|
---|
4061 | phdcWindow[j] = hdcWindow[i];
|
---|
4062 | j++;
|
---|
4063 | }
|
---|
4064 | }
|
---|
4065 | unlock(&critsect);
|
---|
4066 | *pnrdcs = nrOpenDCs;
|
---|
4067 | return TRUE;
|
---|
4068 | }
|
---|
4069 | //******************************************************************************
|
---|
4070 | // Win32BaseWindow::addOpenDC
|
---|
4071 | //
|
---|
4072 | // Add DC to list of open DCS
|
---|
4073 | //
|
---|
4074 | // Parameters:
|
---|
4075 | // HDC hdc - HDC to be added to our list of open DCs
|
---|
4076 | //
|
---|
4077 | // Returns:
|
---|
4078 | //
|
---|
4079 | //******************************************************************************
|
---|
4080 | void Win32BaseWindow::addOpenDC(HDC hdc)
|
---|
4081 | {
|
---|
4082 | lock(&critsect);
|
---|
4083 | for(int i=0;i<MAX_OPENDCS;i++) {
|
---|
4084 | if(hdcWindow[i] == 0) {
|
---|
4085 | hdcWindow[i] = hdc;
|
---|
4086 | break;
|
---|
4087 | }
|
---|
4088 | }
|
---|
4089 | unlock(&critsect);
|
---|
4090 | if(i == MAX_OPENDCS) {
|
---|
4091 | dprintf(("Open DCs:"));
|
---|
4092 | for(int i=0;i<MAX_OPENDCS;i++) {
|
---|
4093 | dprintf(("Window %x DC %x", WindowFromDC(hdcWindow[i]), hdcWindow[i]));
|
---|
4094 | }
|
---|
4095 | DebugInt3(); //no room!
|
---|
4096 | return;
|
---|
4097 | }
|
---|
4098 |
|
---|
4099 | dprintf2(("Win32BaseWindow::addOpenDC %x %x %d", getWindowHandle(), hdc, nrOpenDCs+1));
|
---|
4100 | nrOpenDCs++;
|
---|
4101 | }
|
---|
4102 | //******************************************************************************
|
---|
4103 | // Win32BaseWindow::removeOpenDC
|
---|
4104 | //
|
---|
4105 | // Remove DC from list of open DCS
|
---|
4106 | //
|
---|
4107 | // Parameters:
|
---|
4108 | // HDC hdc - HDC to be removed from our list of open DCs
|
---|
4109 | //
|
---|
4110 | // Returns:
|
---|
4111 | //
|
---|
4112 | //******************************************************************************
|
---|
4113 | void Win32BaseWindow::removeOpenDC(HDC hdc)
|
---|
4114 | {
|
---|
4115 | if(nrOpenDCs == 0) {
|
---|
4116 | dprintf(("Win32BaseWindow::removeOpenDC %x hdc %x not found!! (1)", getWindowHandle(), hdc));
|
---|
4117 | //Some applications call ReleaseDC before EndPaint
|
---|
4118 | // DebugInt3();
|
---|
4119 | return;
|
---|
4120 | }
|
---|
4121 | lock(&critsect);
|
---|
4122 | for(int i=0;i<MAX_OPENDCS;i++) {
|
---|
4123 | if(hdcWindow[i] == hdc) {
|
---|
4124 | hdcWindow[i] = 0;
|
---|
4125 | break;
|
---|
4126 | }
|
---|
4127 | }
|
---|
4128 | unlock(&critsect);
|
---|
4129 | if(i == MAX_OPENDCS) {
|
---|
4130 | dprintf(("Win32BaseWindow::removeOpenDC hdc %x not found!!", hdc));
|
---|
4131 | DebugInt3(); //not found
|
---|
4132 | return;
|
---|
4133 | }
|
---|
4134 | dprintf2(("Win32BaseWindow::removeOpenDC %x %x", getWindowHandle(), hdc, nrOpenDCs-1));
|
---|
4135 | nrOpenDCs--;
|
---|
4136 | }
|
---|
4137 | //******************************************************************************
|
---|
4138 | //Locates window in linked list and increases reference count (if found)
|
---|
4139 | //Window object must be unreferenced after usage
|
---|
4140 | //******************************************************************************
|
---|
4141 | Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
|
---|
4142 | {
|
---|
4143 | Win32BaseWindow *window;
|
---|
4144 |
|
---|
4145 | ////TODO: temporary workaround for crashes in Opera (pmwinx; releasesemaphore)
|
---|
4146 | //// while browsing
|
---|
4147 | //// Not thread safe now!
|
---|
4148 | //// lock(&critsect);
|
---|
4149 | if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
|
---|
4150 | if(window) {
|
---|
4151 | //// dprintf(("addRef %x; refcount %d", hwnd, window->getRefCount()+1));
|
---|
4152 | window->addRef();
|
---|
4153 | }
|
---|
4154 | //// unlock(&critsect);
|
---|
4155 | return window;
|
---|
4156 | }
|
---|
4157 | //// unlock(&critsect);
|
---|
4158 | // dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
|
---|
4159 | return NULL;
|
---|
4160 | }
|
---|
4161 | //******************************************************************************
|
---|
4162 | //Locates window in linked list and increases reference count (if found)
|
---|
4163 | //Window object must be unreferenced after usage
|
---|
4164 | //******************************************************************************
|
---|
4165 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwndOS2)
|
---|
4166 | {
|
---|
4167 | DWORD magic;
|
---|
4168 | HWND hwnd;
|
---|
4169 |
|
---|
4170 | if(hwndOS2 == OSLIB_HWND_DESKTOP)
|
---|
4171 | {
|
---|
4172 | windowDesktop->addRef();
|
---|
4173 | return windowDesktop;
|
---|
4174 | }
|
---|
4175 |
|
---|
4176 | hwnd = (HWND)OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32WNDPTR);
|
---|
4177 | magic = OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32PM_MAGIC);
|
---|
4178 |
|
---|
4179 | if(hwnd && CheckMagicDword(magic)) {
|
---|
4180 | return GetWindowFromHandle(hwnd);
|
---|
4181 | }
|
---|
4182 | // dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwndOS2));
|
---|
4183 |
|
---|
4184 | //Now check if it's a fake window
|
---|
4185 | Win32FakeWindow *window = Win32FakeWindow::GetWindowFromOS2Handle(hwndOS2);
|
---|
4186 | if(window) {
|
---|
4187 | return window;
|
---|
4188 | }
|
---|
4189 | return 0;
|
---|
4190 | }
|
---|
4191 | //******************************************************************************
|
---|
4192 | //Locates window in linked list and increases reference count (if found)
|
---|
4193 | //Window object must be unreferenced after usage
|
---|
4194 | //******************************************************************************
|
---|
4195 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
|
---|
4196 | {
|
---|
4197 | return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
|
---|
4198 | }
|
---|
4199 | //******************************************************************************
|
---|
4200 | //******************************************************************************
|
---|
4201 | HWND WIN32API Win32ToOS2Handle(HWND hwnd)
|
---|
4202 | {
|
---|
4203 | HWND hwndOS2;
|
---|
4204 |
|
---|
4205 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
4206 |
|
---|
4207 | if(window) {
|
---|
4208 | hwndOS2 = window->getOS2WindowHandle();
|
---|
4209 | RELEASE_WNDOBJ(window);
|
---|
4210 | return hwndOS2;
|
---|
4211 | }
|
---|
4212 | // dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
|
---|
4213 | return hwnd;
|
---|
4214 | }
|
---|
4215 | //******************************************************************************
|
---|
4216 | //******************************************************************************
|
---|
4217 | HWND WIN32API Win32ToOS2FrameHandle(HWND hwnd)
|
---|
4218 | {
|
---|
4219 | HWND hwndOS2;
|
---|
4220 |
|
---|
4221 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
4222 |
|
---|
4223 | if(window) {
|
---|
4224 | hwndOS2 = window->getOS2FrameWindowHandle();
|
---|
4225 | RELEASE_WNDOBJ(window);
|
---|
4226 | return hwndOS2;
|
---|
4227 | }
|
---|
4228 | // dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
|
---|
4229 | return hwnd;
|
---|
4230 | }
|
---|
4231 | //******************************************************************************
|
---|
4232 | //******************************************************************************
|
---|
4233 | HWND WIN32API OS2ToWin32Handle(HWND hwnd)
|
---|
4234 | {
|
---|
4235 | Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
---|
4236 | HWND hwndWin32;
|
---|
4237 |
|
---|
4238 | if(window) {
|
---|
4239 | hwndWin32 = window->getWindowHandle();
|
---|
4240 | RELEASE_WNDOBJ(window);
|
---|
4241 | return hwndWin32;
|
---|
4242 | }
|
---|
4243 | window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
|
---|
4244 | if(window) {
|
---|
4245 | hwndWin32 = window->getWindowHandle();
|
---|
4246 | RELEASE_WNDOBJ(window);
|
---|
4247 | return hwndWin32;
|
---|
4248 | }
|
---|
4249 |
|
---|
4250 | // dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
|
---|
4251 | return 0;
|
---|
4252 | // else return hwnd; //OS/2 window handle
|
---|
4253 | }
|
---|
4254 | #ifdef DEBUG
|
---|
4255 | LONG Win32BaseWindow::addRef()
|
---|
4256 | {
|
---|
4257 | // dprintf2(("addRef %x %d", getWindowHandle(), getRefCount()+1));
|
---|
4258 | return GenericObject::addRef();
|
---|
4259 | }
|
---|
4260 | //******************************************************************************
|
---|
4261 | //******************************************************************************
|
---|
4262 | LONG Win32BaseWindow::release(char *function, int line)
|
---|
4263 | {
|
---|
4264 | // dprintf2(("release %s %d %x %d", function, line, getWindowHandle(), getRefCount()-1));
|
---|
4265 | return GenericObject::release();
|
---|
4266 | }
|
---|
4267 | #endif
|
---|
4268 | //******************************************************************************
|
---|
4269 | //******************************************************************************
|
---|
4270 | GenericObject *Win32BaseWindow::windows = NULL;
|
---|
4271 | CRITICAL_SECTION Win32BaseWindow::critsect = {0};
|
---|
4272 |
|
---|
4273 | //******************************************************************************
|
---|
4274 | //******************************************************************************
|
---|
4275 | #ifdef DEBUG
|
---|
4276 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
|
---|
4277 | {
|
---|
4278 | char style[256] = "";
|
---|
4279 | char exstyle[256] = "";
|
---|
4280 |
|
---|
4281 | /* Window styles */
|
---|
4282 | if(dwStyle & WS_CHILD)
|
---|
4283 | strcat(style, "WS_CHILD ");
|
---|
4284 | if(dwStyle & WS_POPUP)
|
---|
4285 | strcat(style, "WS_POPUP ");
|
---|
4286 | if(dwStyle & WS_VISIBLE)
|
---|
4287 | strcat(style, "WS_VISIBLE ");
|
---|
4288 | if(dwStyle & WS_DISABLED)
|
---|
4289 | strcat(style, "WS_DISABLED ");
|
---|
4290 | if(dwStyle & WS_CLIPSIBLINGS)
|
---|
4291 | strcat(style, "WS_CLIPSIBLINGS ");
|
---|
4292 | if(dwStyle & WS_CLIPCHILDREN)
|
---|
4293 | strcat(style, "WS_CLIPCHILDREN ");
|
---|
4294 | if(dwStyle & WS_MAXIMIZE)
|
---|
4295 | strcat(style, "WS_MAXIMIZE ");
|
---|
4296 | if(dwStyle & WS_MINIMIZE)
|
---|
4297 | strcat(style, "WS_MINIMIZE ");
|
---|
4298 | if(dwStyle & WS_GROUP)
|
---|
4299 | strcat(style, "WS_GROUP ");
|
---|
4300 | if(dwStyle & WS_TABSTOP)
|
---|
4301 | strcat(style, "WS_TABSTOP ");
|
---|
4302 |
|
---|
4303 | if((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
4304 | strcat(style, "WS_CAPTION ");
|
---|
4305 | if(dwStyle & WS_DLGFRAME)
|
---|
4306 | strcat(style, "WS_DLGFRAME ");
|
---|
4307 | if(dwStyle & WS_BORDER)
|
---|
4308 | strcat(style, "WS_BORDER ");
|
---|
4309 |
|
---|
4310 | if(dwStyle & WS_VSCROLL)
|
---|
4311 | strcat(style, "WS_VSCROLL ");
|
---|
4312 | if(dwStyle & WS_HSCROLL)
|
---|
4313 | strcat(style, "WS_HSCROLL ");
|
---|
4314 | if(dwStyle & WS_SYSMENU)
|
---|
4315 | strcat(style, "WS_SYSMENU ");
|
---|
4316 | if(dwStyle & WS_THICKFRAME)
|
---|
4317 | strcat(style, "WS_THICKFRAME ");
|
---|
4318 | if(dwStyle & WS_MINIMIZEBOX)
|
---|
4319 | strcat(style, "WS_MINIMIZEBOX ");
|
---|
4320 | if(dwStyle & WS_MAXIMIZEBOX)
|
---|
4321 | strcat(style, "WS_MAXIMIZEBOX ");
|
---|
4322 |
|
---|
4323 | if(dwExStyle & WS_EX_DLGMODALFRAME)
|
---|
4324 | strcat(exstyle, "WS_EX_DLGMODALFRAME ");
|
---|
4325 | if(dwExStyle & WS_EX_ACCEPTFILES)
|
---|
4326 | strcat(exstyle, "WS_EX_ACCEPTFILES ");
|
---|
4327 | if(dwExStyle & WS_EX_NOPARENTNOTIFY)
|
---|
4328 | strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
|
---|
4329 | if(dwExStyle & WS_EX_TOPMOST)
|
---|
4330 | strcat(exstyle, "WS_EX_TOPMOST ");
|
---|
4331 | if(dwExStyle & WS_EX_TRANSPARENT)
|
---|
4332 | strcat(exstyle, "WS_EX_TRANSPARENT ");
|
---|
4333 |
|
---|
4334 | if(dwExStyle & WS_EX_MDICHILD)
|
---|
4335 | strcat(exstyle, "WS_EX_MDICHILD ");
|
---|
4336 | if(dwExStyle & WS_EX_TOOLWINDOW)
|
---|
4337 | strcat(exstyle, "WS_EX_TOOLWINDOW ");
|
---|
4338 | if(dwExStyle & WS_EX_WINDOWEDGE)
|
---|
4339 | strcat(exstyle, "WS_EX_WINDOWEDGE ");
|
---|
4340 | if(dwExStyle & WS_EX_CLIENTEDGE)
|
---|
4341 | strcat(exstyle, "WS_EX_CLIENTEDGE ");
|
---|
4342 | if(dwExStyle & WS_EX_CONTEXTHELP)
|
---|
4343 | strcat(exstyle, "WS_EX_CONTEXTHELP ");
|
---|
4344 | if(dwExStyle & WS_EX_RIGHT)
|
---|
4345 | strcat(exstyle, "WS_EX_RIGHT ");
|
---|
4346 | if(dwExStyle & WS_EX_LEFT)
|
---|
4347 | strcat(exstyle, "WS_EX_LEFT ");
|
---|
4348 | if(dwExStyle & WS_EX_RTLREADING)
|
---|
4349 | strcat(exstyle, "WS_EX_RTLREADING ");
|
---|
4350 | if(dwExStyle & WS_EX_LTRREADING)
|
---|
4351 | strcat(exstyle, "WS_EX_LTRREADING ");
|
---|
4352 | if(dwExStyle & WS_EX_LEFTSCROLLBAR)
|
---|
4353 | strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
|
---|
4354 | if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
|
---|
4355 | strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
|
---|
4356 | if(dwExStyle & WS_EX_CONTROLPARENT)
|
---|
4357 | strcat(exstyle, "WS_EX_CONTROLPARENT ");
|
---|
4358 | if(dwExStyle & WS_EX_STATICEDGE)
|
---|
4359 | strcat(exstyle, "WS_EX_STATICEDGE ");
|
---|
4360 | if(dwExStyle & WS_EX_APPWINDOW)
|
---|
4361 | strcat(exstyle, "WS_EX_APPWINDOW ");
|
---|
4362 |
|
---|
4363 | dprintf(("Window style: %x %s", dwStyle, style));
|
---|
4364 | dprintf(("Window exStyle: %x %s", dwExStyle, exstyle));
|
---|
4365 | }
|
---|
4366 | #endif
|
---|
4367 | //******************************************************************************
|
---|
4368 | //******************************************************************************
|
---|