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