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