1 | /* $Id: win32wbase.cpp,v 1.135 2000-01-09 14:37:11 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window Base Class for OS/2
|
---|
4 | *
|
---|
5 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
|
---|
6 | * Copyright 1999 Daniela Engert (dani@ngrt.de)
|
---|
7 | *
|
---|
8 | * Parts based on Wine Windows code (windows\win.c)
|
---|
9 | *
|
---|
10 | * Copyright 1993, 1994, 1996 Alexandre Julliard
|
---|
11 | * 1995 Alex Korobka
|
---|
12 | *
|
---|
13 | * TODO: Not thread/process safe
|
---|
14 | *
|
---|
15 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
16 | *
|
---|
17 | */
|
---|
18 | #include <os2win.h>
|
---|
19 | #include <win.h>
|
---|
20 | #include <stdlib.h>
|
---|
21 | #include <string.h>
|
---|
22 | #include <stdarg.h>
|
---|
23 | #include <assert.h>
|
---|
24 | #include <misc.h>
|
---|
25 | #include <heapstring.h>
|
---|
26 | #include <win32wbase.h>
|
---|
27 | #include <winres.h>
|
---|
28 | #include "wndmsg.h"
|
---|
29 | #include "oslibwin.h"
|
---|
30 | #include "oslibmsg.h"
|
---|
31 | #include "oslibutil.h"
|
---|
32 | #include "oslibgdi.h"
|
---|
33 | #include "oslibres.h"
|
---|
34 | #include "oslibmenu.h"
|
---|
35 | #include "oslibdos.h"
|
---|
36 | #include "syscolor.h"
|
---|
37 | #include "win32wndhandle.h"
|
---|
38 | #include "dc.h"
|
---|
39 | #include "pmframe.h"
|
---|
40 | #include "pmtitlebar.h"
|
---|
41 | #include "win32wdesktop.h"
|
---|
42 | #include "pmwindow.h"
|
---|
43 | #include "controls.h"
|
---|
44 | #include <wprocess.h>
|
---|
45 | #include "winmouse.h"
|
---|
46 | #include <win\hook.h>
|
---|
47 | #define INCL_TIMERWIN32
|
---|
48 | #include "timer.h"
|
---|
49 |
|
---|
50 | #define HAS_DLGFRAME(style,exStyle) \
|
---|
51 | (((exStyle) & WS_EX_DLGMODALFRAME) || \
|
---|
52 | (((style) & WS_DLGFRAME) && !((style) & WS_THICKFRAME)))
|
---|
53 |
|
---|
54 | #define HAS_THICKFRAME(style,exStyle) \
|
---|
55 | (((style) & WS_THICKFRAME) && \
|
---|
56 | !((exStyle) & WS_EX_DLGMODALFRAME))
|
---|
57 |
|
---|
58 | #define HAS_THINFRAME(style) \
|
---|
59 | (((style) & WS_BORDER) || !((style) & (WS_CHILD | WS_POPUP)))
|
---|
60 |
|
---|
61 | #define HAS_BIGFRAME(style,exStyle) \
|
---|
62 | (((style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
|
---|
63 | ((exStyle) & WS_EX_DLGMODALFRAME))
|
---|
64 |
|
---|
65 | #define HAS_ANYFRAME(style,exStyle) \
|
---|
66 | (((style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
|
---|
67 | ((exStyle) & WS_EX_DLGMODALFRAME) || \
|
---|
68 | !((style) & (WS_CHILD | WS_POPUP)))
|
---|
69 |
|
---|
70 | #define HAS_3DFRAME(exStyle) \
|
---|
71 | ((exStyle & WS_EX_CLIENTEDGE) || (exStyle & WS_EX_STATICEDGE) || (exStyle & WS_EX_WINDOWEDGE))
|
---|
72 |
|
---|
73 | #define HAS_BORDER(style, exStyle) \
|
---|
74 | ((style & WS_BORDER) || HAS_THICKFRAME(style) || HAS_DLGFRAME(style,exStyle))
|
---|
75 |
|
---|
76 | #define IS_OVERLAPPED(style) \
|
---|
77 | !(style & (WS_CHILD | WS_POPUP))
|
---|
78 |
|
---|
79 | /* bits in the dwKeyData */
|
---|
80 | #define KEYDATA_ALT 0x2000
|
---|
81 | #define KEYDATA_PREVSTATE 0x4000
|
---|
82 |
|
---|
83 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle);
|
---|
84 |
|
---|
85 | static fDestroyAll = FALSE;
|
---|
86 | //For quick lookup of current process id
|
---|
87 | static ULONG currentProcessId = -1;
|
---|
88 |
|
---|
89 | //******************************************************************************
|
---|
90 | //******************************************************************************
|
---|
91 | Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
|
---|
92 | {
|
---|
93 | Init();
|
---|
94 | }
|
---|
95 | //******************************************************************************
|
---|
96 | //******************************************************************************
|
---|
97 | Win32BaseWindow::Win32BaseWindow(HWND os2Handle,VOID* win32WndProc) : GenericObject(&windows,OBJTYPE_WINDOW)
|
---|
98 | {
|
---|
99 | Init();
|
---|
100 | OS2Hwnd = OS2HwndFrame = os2Handle;
|
---|
101 | dwStyle = WS_VISIBLE;
|
---|
102 | setWindowProc((WNDPROC)win32WndProc);
|
---|
103 | fIsSubclassedOS2Wnd = TRUE;
|
---|
104 | fFirstShow = FALSE;
|
---|
105 |
|
---|
106 | SetLastError(0);
|
---|
107 |
|
---|
108 | //CB: replace by a secure method
|
---|
109 |
|
---|
110 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
|
---|
111 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
|
---|
112 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
113 | return;
|
---|
114 | }
|
---|
115 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
---|
116 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
---|
117 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
118 | return;
|
---|
119 | }
|
---|
120 |
|
---|
121 | OSLibWinQueryWindowRect(OS2Hwnd,&rectClient,RELATIVE_TO_WINDOW);
|
---|
122 | OSLibWinQueryWindowRect(OS2Hwnd,&rectWindow,RELATIVE_TO_SCREEN);
|
---|
123 |
|
---|
124 | setOldWndProc(SubclassWithDefHandler(OS2Hwnd));
|
---|
125 | }
|
---|
126 | //******************************************************************************
|
---|
127 | //******************************************************************************
|
---|
128 | Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
|
---|
129 | : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
|
---|
130 | {
|
---|
131 | Init();
|
---|
132 | this->isUnicode = isUnicode;
|
---|
133 | CreateWindowExA(lpCreateStructA, classAtom);
|
---|
134 | }
|
---|
135 | //******************************************************************************
|
---|
136 | //******************************************************************************
|
---|
137 | void Win32BaseWindow::Init()
|
---|
138 | {
|
---|
139 | isUnicode = FALSE;
|
---|
140 | fIsSubclassedOS2Wnd = FALSE;
|
---|
141 | fFirstShow = TRUE;
|
---|
142 | fIsDialog = FALSE;
|
---|
143 | fIsModalDialogOwner = FALSE;
|
---|
144 | OS2HwndModalDialog = 0;
|
---|
145 | fInternalMsg = FALSE;
|
---|
146 | fNoSizeMsg = FALSE;
|
---|
147 | fIsDestroyed = FALSE;
|
---|
148 | fDestroyWindowCalled = FALSE;
|
---|
149 | fCreated = FALSE;
|
---|
150 | fTaskList = FALSE;
|
---|
151 | fParentDC = FALSE;
|
---|
152 | fDefWndProcCalled = FALSE;
|
---|
153 | fWindowRectChanged = FALSE; //Set when parent window has been moved; cleared when window rect is updated
|
---|
154 |
|
---|
155 | windowNameA = NULL;
|
---|
156 | windowNameW = NULL;
|
---|
157 | wndNameLength = 0;
|
---|
158 |
|
---|
159 | userWindowLong = NULL;;
|
---|
160 | nrUserWindowLong = 0;
|
---|
161 |
|
---|
162 | magic = WIN32PM_MAGIC;
|
---|
163 | OS2Hwnd = 0;
|
---|
164 | OS2HwndFrame = 0;
|
---|
165 | OS2HwndMenu = 0;
|
---|
166 | Win32Hwnd = 0;
|
---|
167 |
|
---|
168 | if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
|
---|
169 | {
|
---|
170 | dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
|
---|
171 | DebugInt3();
|
---|
172 | }
|
---|
173 |
|
---|
174 | posx = posy = 0;
|
---|
175 | width = height = 0;
|
---|
176 |
|
---|
177 | dwExStyle = 0;
|
---|
178 | dwStyle = 0;
|
---|
179 | win32wndproc = 0;
|
---|
180 | hInstance = 0;
|
---|
181 | windowId = 0xFFFFFFFF; //default = -1
|
---|
182 | userData = 0;
|
---|
183 | contextHelpId = 0;
|
---|
184 |
|
---|
185 | pOldFrameProc = NULL;
|
---|
186 | pOldTitleBarProc = NULL;
|
---|
187 | pOldMenuProc = NULL;
|
---|
188 |
|
---|
189 | borderWidth = 0;
|
---|
190 | borderHeight = 0;
|
---|
191 |
|
---|
192 | hwndLinkAfter = HWND_BOTTOM;
|
---|
193 | flags = 0;
|
---|
194 | isIcon = FALSE;
|
---|
195 | lastHitTestVal = HTOS_NORMAL;
|
---|
196 | owner = NULL;
|
---|
197 | windowClass = 0;
|
---|
198 |
|
---|
199 | iconResource = NULL;
|
---|
200 |
|
---|
201 | EraseBkgndFlag = TRUE;
|
---|
202 | PSEraseFlag = FALSE;
|
---|
203 | SuppressEraseFlag = FALSE;
|
---|
204 |
|
---|
205 | horzScrollInfo = NULL;
|
---|
206 | vertScrollInfo = NULL;
|
---|
207 | hwndHorzScroll = 0;
|
---|
208 | hwndVertScroll = 0;
|
---|
209 |
|
---|
210 | ownDC = 0;
|
---|
211 | hWindowRegion = 0;
|
---|
212 |
|
---|
213 | if(currentProcessId == -1)
|
---|
214 | {
|
---|
215 | currentProcessId = GetCurrentProcessId();
|
---|
216 | }
|
---|
217 | dwThreadId = GetCurrentThreadId();
|
---|
218 | dwProcessId = currentProcessId;
|
---|
219 | }
|
---|
220 | //******************************************************************************
|
---|
221 | //todo get rid of resources (menu, icon etc)
|
---|
222 | //******************************************************************************
|
---|
223 | Win32BaseWindow::~Win32BaseWindow()
|
---|
224 | {
|
---|
225 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
|
---|
226 | OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
|
---|
227 |
|
---|
228 | if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
|
---|
229 | {
|
---|
230 | //if we're the last child that's being destroyed and our
|
---|
231 | //parent window was also destroyed, then we delete the parent object
|
---|
232 | if(getParent()->IsWindowDestroyed())
|
---|
233 | {
|
---|
234 | dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
|
---|
235 | delete getParent();
|
---|
236 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
---|
237 | }
|
---|
238 | }
|
---|
239 | else
|
---|
240 | if(fDestroyAll) {
|
---|
241 | dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
|
---|
242 | setParent(NULL); //or else we'll crash in the dtor of the ChildWindow class
|
---|
243 | }
|
---|
244 |
|
---|
245 | if (isOwnDC())
|
---|
246 | releaseOwnDC (ownDC);
|
---|
247 |
|
---|
248 | if(Win32Hwnd)
|
---|
249 | HwFreeWindowHandle(Win32Hwnd);
|
---|
250 |
|
---|
251 | if(userWindowLong)
|
---|
252 | free(userWindowLong);
|
---|
253 | if(windowNameA) {
|
---|
254 | free(windowNameA);
|
---|
255 | windowNameA = NULL;
|
---|
256 | }
|
---|
257 | if(windowNameW) {
|
---|
258 | free(windowNameW);
|
---|
259 | windowNameW = NULL;
|
---|
260 | }
|
---|
261 | if(vertScrollInfo) {
|
---|
262 | free(vertScrollInfo);
|
---|
263 | vertScrollInfo = NULL;
|
---|
264 | }
|
---|
265 | if(horzScrollInfo) {
|
---|
266 | free(horzScrollInfo);
|
---|
267 | horzScrollInfo = NULL;
|
---|
268 | }
|
---|
269 | }
|
---|
270 | //******************************************************************************
|
---|
271 | //******************************************************************************
|
---|
272 | void Win32BaseWindow::DestroyAll()
|
---|
273 | {
|
---|
274 | fDestroyAll = TRUE;
|
---|
275 | GenericObject::DestroyAll(windows);
|
---|
276 | }
|
---|
277 | //******************************************************************************
|
---|
278 | //******************************************************************************
|
---|
279 | BOOL Win32BaseWindow::isChild()
|
---|
280 | {
|
---|
281 | return ((dwStyle & WS_CHILD) != 0);
|
---|
282 | }
|
---|
283 | //******************************************************************************
|
---|
284 | //******************************************************************************
|
---|
285 | BOOL Win32BaseWindow::IsWindowUnicode()
|
---|
286 | {
|
---|
287 | dprintf2(("IsWindowUnicode %x %d", getWindowHandle(), WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W));
|
---|
288 | return (WINPROC_GetProcType(getWindowProc()) == WIN_PROC_32W);
|
---|
289 | }
|
---|
290 | //******************************************************************************
|
---|
291 | //******************************************************************************
|
---|
292 | BOOL Win32BaseWindow::CreateWindowExA(CREATESTRUCTA *cs, ATOM classAtom)
|
---|
293 | {
|
---|
294 | char buffer[256];
|
---|
295 | POINT maxSize, maxPos, minTrack, maxTrack;
|
---|
296 |
|
---|
297 | #ifdef DEBUG
|
---|
298 | PrintWindowStyle(cs->style, cs->dwExStyle);
|
---|
299 | #endif
|
---|
300 |
|
---|
301 | sw = SW_SHOW;
|
---|
302 | SetLastError(0);
|
---|
303 |
|
---|
304 | /* Find the parent window */
|
---|
305 | if (cs->hwndParent)
|
---|
306 | {
|
---|
307 | Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
|
---|
308 | if(!window) {
|
---|
309 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
---|
310 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
311 | return FALSE;
|
---|
312 | }
|
---|
313 | /* Make sure parent is valid */
|
---|
314 | if (!window->IsWindow() )
|
---|
315 | {
|
---|
316 | dprintf(("Bad parent %04x\n", cs->hwndParent ));
|
---|
317 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
318 | return FALSE;
|
---|
319 | }
|
---|
320 | }
|
---|
321 | else
|
---|
322 | if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
|
---|
323 | dprintf(("No parent for child window\n" ));
|
---|
324 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
325 | return FALSE; /* WS_CHILD needs a parent, but WS_POPUP doesn't */
|
---|
326 | }
|
---|
327 |
|
---|
328 | /* Find the window class */
|
---|
329 | windowClass = Win32WndClass::FindClass(cs->hInstance, (LPSTR)classAtom);
|
---|
330 | if (!windowClass)
|
---|
331 | {
|
---|
332 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
---|
333 | dprintf(("Bad class '%s'\n", buffer ));
|
---|
334 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
335 | return 0;
|
---|
336 | }
|
---|
337 | #ifdef DEBUG
|
---|
338 | if(HIWORD(cs->lpszClass))
|
---|
339 | {
|
---|
340 | char *astring;
|
---|
341 |
|
---|
342 | if(isUnicode) astring = UnicodeToAsciiString((LPWSTR)cs->lpszClass);
|
---|
343 | else astring = (char *)cs->lpszClass;
|
---|
344 |
|
---|
345 | dprintf(("Window class %s", astring));
|
---|
346 | if(isUnicode) FreeAsciiString(astring);
|
---|
347 | }
|
---|
348 | else dprintf(("Window class %x", cs->lpszClass));
|
---|
349 | #endif
|
---|
350 |
|
---|
351 | /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
|
---|
352 | * with an atom as the class name, put some programs expect to have a *REAL* string in
|
---|
353 | * lpszClass when the CREATESTRUCT is sent with WM_CREATE
|
---|
354 | */
|
---|
355 | if (!HIWORD(cs->lpszClass) ) {
|
---|
356 | if (isUnicode) {
|
---|
357 | GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
|
---|
358 | }
|
---|
359 | else {
|
---|
360 | GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
|
---|
361 | }
|
---|
362 | cs->lpszClass = buffer;
|
---|
363 | }
|
---|
364 |
|
---|
365 | /* Fix the coordinates */
|
---|
366 | if ((cs->x == CW_USEDEFAULT) || (cs->x == CW_USEDEFAULT16))
|
---|
367 | {
|
---|
368 | // PDB *pdb = PROCESS_Current();
|
---|
369 |
|
---|
370 | /* Never believe Microsoft's documentation... CreateWindowEx doc says
|
---|
371 | * that if an overlapped window is created with WS_VISIBLE style bit
|
---|
372 | * set and the x parameter is set to CW_USEDEFAULT, the system ignores
|
---|
373 | * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
|
---|
374 | * reveals that
|
---|
375 | *
|
---|
376 | * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
|
---|
377 | * 2) it does not ignore the y parameter as the docs claim; instead, it
|
---|
378 | * uses it as second parameter to ShowWindow() unless y is either
|
---|
379 | * CW_USEDEFAULT or CW_USEDEFAULT16.
|
---|
380 | *
|
---|
381 | * The fact that we didn't do 2) caused bogus windows pop up when wine
|
---|
382 | * was running apps that were using this obscure feature. Example -
|
---|
383 | * calc.exe that comes with Win98 (only Win98, it's different from
|
---|
384 | * the one that comes with Win95 and NT)
|
---|
385 | */
|
---|
386 | if ((cs->y != CW_USEDEFAULT) && (cs->y != CW_USEDEFAULT16)) sw = cs->y;
|
---|
387 |
|
---|
388 | /* We have saved cs->y, now we can trash it */
|
---|
389 | #if 0
|
---|
390 | if ( !(cs->style & (WS_CHILD | WS_POPUP))
|
---|
391 | && (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
|
---|
392 | {
|
---|
393 | cs->x = pdb->env_db->startup_info->dwX;
|
---|
394 | cs->y = pdb->env_db->startup_info->dwY;
|
---|
395 | }
|
---|
396 | #endif
|
---|
397 | cs->x = 0;
|
---|
398 | cs->y = 0;
|
---|
399 | // }
|
---|
400 | }
|
---|
401 | if ((cs->cx == CW_USEDEFAULT) || (cs->cx == CW_USEDEFAULT16))
|
---|
402 | {
|
---|
403 | #if 0
|
---|
404 | PDB *pdb = PROCESS_Current();
|
---|
405 | if ( !(cs->style & (WS_CHILD | WS_POPUP))
|
---|
406 | && (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
|
---|
407 | {
|
---|
408 | cs->cx = pdb->env_db->startup_info->dwXSize;
|
---|
409 | cs->cy = pdb->env_db->startup_info->dwYSize;
|
---|
410 | }
|
---|
411 | else
|
---|
412 | {
|
---|
413 | #endif
|
---|
414 | cs->cx = 600; /* FIXME */
|
---|
415 | cs->cy = 400;
|
---|
416 | // }
|
---|
417 | }
|
---|
418 |
|
---|
419 | if (cs->x < 0) cs->x = 0;
|
---|
420 | if (cs->y < 0) cs->y = 0;
|
---|
421 |
|
---|
422 | //Allocate window words
|
---|
423 | nrUserWindowLong = windowClass->getExtraWndWords();
|
---|
424 | if(nrUserWindowLong) {
|
---|
425 | userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
|
---|
426 | memset(userWindowLong, 0, nrUserWindowLong);
|
---|
427 | }
|
---|
428 |
|
---|
429 | if ((cs->style & WS_CHILD) && cs->hwndParent)
|
---|
430 | {
|
---|
431 | SetParent(cs->hwndParent);
|
---|
432 | owner = GetWindowFromHandle(cs->hwndParent);
|
---|
433 | if(owner == NULL)
|
---|
434 | {
|
---|
435 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
---|
436 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
437 | return FALSE;
|
---|
438 | }
|
---|
439 | }
|
---|
440 | else
|
---|
441 | {
|
---|
442 | SetParent(0);
|
---|
443 | if (!cs->hwndParent || (cs->hwndParent == windowDesktop->getWindowHandle())) {
|
---|
444 | owner = NULL;
|
---|
445 | }
|
---|
446 | else
|
---|
447 | {
|
---|
448 | owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
|
---|
449 | if(owner == NULL)
|
---|
450 | {
|
---|
451 | dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
|
---|
452 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
453 | return FALSE;
|
---|
454 | }
|
---|
455 | }
|
---|
456 | }
|
---|
457 |
|
---|
458 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, windowClass->getWindowProc(), WINPROC_GetProcType(windowClass->getWindowProc()), WIN_PROC_WINDOW);
|
---|
459 | hInstance = cs->hInstance;
|
---|
460 | dwStyle = cs->style & ~WS_VISIBLE;
|
---|
461 | dwExStyle = cs->dwExStyle;
|
---|
462 |
|
---|
463 | hwndLinkAfter = HWND_TOP;
|
---|
464 | if(WIDGETS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
|
---|
465 | {
|
---|
466 | hwndLinkAfter = HWND_BOTTOM;
|
---|
467 | dwStyle |= WS_CLIPSIBLINGS;
|
---|
468 | }
|
---|
469 | else
|
---|
470 | if(WIDGETS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
|
---|
471 | dwStyle |= WS_CLIPSIBLINGS;
|
---|
472 | }
|
---|
473 |
|
---|
474 | /* Increment class window counter */
|
---|
475 | windowClass->IncreaseWindowCount();
|
---|
476 |
|
---|
477 | if (HOOK_IsHooked( WH_CBT ))
|
---|
478 | {
|
---|
479 | CBT_CREATEWNDA cbtc;
|
---|
480 | LRESULT ret;
|
---|
481 |
|
---|
482 | cbtc.lpcs = cs;
|
---|
483 | cbtc.hwndInsertAfter = hwndLinkAfter;
|
---|
484 | ret = HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, getWindowHandle(), (LPARAM)&cbtc);
|
---|
485 | if(ret)
|
---|
486 | {
|
---|
487 | dprintf(("CBT-hook returned 0!!"));
|
---|
488 | SetLastError(ERROR_CAN_NOT_COMPLETE); //todo: wrong error
|
---|
489 | return FALSE;
|
---|
490 | }
|
---|
491 | }
|
---|
492 |
|
---|
493 | /* Correct the window style */
|
---|
494 | if (!(cs->style & WS_CHILD))
|
---|
495 | {
|
---|
496 | dwStyle |= WS_CLIPSIBLINGS;
|
---|
497 | if (!(cs->style & WS_POPUP))
|
---|
498 | {
|
---|
499 | dwStyle |= WS_CAPTION;
|
---|
500 | flags |= WIN_NEED_SIZE;
|
---|
501 | }
|
---|
502 | }
|
---|
503 | if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
|
---|
504 |
|
---|
505 | if (cs->style & WS_HSCROLL)
|
---|
506 | {
|
---|
507 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
508 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
---|
509 | horzScrollInfo->MaxVal = 100;
|
---|
510 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
511 | }
|
---|
512 |
|
---|
513 | if (cs->style & WS_VSCROLL)
|
---|
514 | {
|
---|
515 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
516 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
---|
517 | vertScrollInfo->MaxVal = 100;
|
---|
518 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
519 | }
|
---|
520 |
|
---|
521 | /* Send the WM_GETMINMAXINFO message and fix the size if needed */
|
---|
522 | if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
---|
523 | {
|
---|
524 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
---|
525 | if (maxSize.x < cs->cx) cs->cx = maxSize.x;
|
---|
526 | if (maxSize.y < cs->cy) cs->cy = maxSize.y;
|
---|
527 | if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
|
---|
528 | if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
|
---|
529 | }
|
---|
530 |
|
---|
531 | if(cs->style & WS_CHILD)
|
---|
532 | {
|
---|
533 | if(cs->cx < 0) cs->cx = 0;
|
---|
534 | if(cs->cy < 0) cs->cy = 0;
|
---|
535 | }
|
---|
536 | else
|
---|
537 | {
|
---|
538 | if (cs->cx <= 0) cs->cx = 1;
|
---|
539 | if (cs->cy <= 0) cs->cy = 1;
|
---|
540 | }
|
---|
541 |
|
---|
542 | if(((dwStyle & 0xC0000000) == WS_OVERLAPPED) && ((dwStyle & WS_CAPTION) == WS_CAPTION) && owner == NULL
|
---|
543 | && dwStyle & WS_SYSMENU)
|
---|
544 | {
|
---|
545 | fTaskList = TRUE;
|
---|
546 | }
|
---|
547 |
|
---|
548 | DWORD dwOSWinStyle, dwOSFrameStyle;
|
---|
549 |
|
---|
550 | OSLibWinConvertStyle(dwStyle, &dwExStyle, &dwOSWinStyle, &dwOSFrameStyle, &borderWidth, &borderHeight);
|
---|
551 |
|
---|
552 | if(HIWORD(cs->lpszName))
|
---|
553 | {
|
---|
554 | if (!isUnicode)
|
---|
555 | {
|
---|
556 | wndNameLength = strlen(cs->lpszName);
|
---|
557 | windowNameA = (LPSTR)_smalloc(wndNameLength+1);
|
---|
558 | strcpy(windowNameA,cs->lpszName);
|
---|
559 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
|
---|
560 | lstrcpyAtoW(windowNameW,windowNameA);
|
---|
561 | windowNameA[wndNameLength] = 0;
|
---|
562 | windowNameW[wndNameLength] = 0;
|
---|
563 | }
|
---|
564 | else
|
---|
565 | {
|
---|
566 | wndNameLength = lstrlenW((LPWSTR)cs->lpszName);
|
---|
567 | windowNameA = (LPSTR)_smalloc(wndNameLength+1);
|
---|
568 | lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName);
|
---|
569 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
|
---|
570 | lstrcpyW(windowNameW,(LPWSTR)cs->lpszName);
|
---|
571 | windowNameA[wndNameLength] = 0;
|
---|
572 | windowNameW[wndNameLength] = 0;
|
---|
573 | }
|
---|
574 | }
|
---|
575 |
|
---|
576 | //copy pointer of CREATESTRUCT for usage in MsgCreate method
|
---|
577 | tmpcs = cs;
|
---|
578 |
|
---|
579 | //Store our window object pointer in thread local memory, so PMWINDOW.CPP can retrieve it
|
---|
580 | THDB *thdb = GetThreadTHDB();
|
---|
581 |
|
---|
582 | if(thdb == NULL) {
|
---|
583 | dprintf(("Window creation failed - thdb == NULL")); //this is VERY bad
|
---|
584 | ExitProcess(666);
|
---|
585 | return FALSE;
|
---|
586 | }
|
---|
587 |
|
---|
588 | thdb->newWindow = (ULONG)this;
|
---|
589 |
|
---|
590 | OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
|
---|
591 | dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
|
---|
592 | (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
|
---|
593 | (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
|
---|
594 | &OS2HwndFrame, 0, fTaskList);
|
---|
595 |
|
---|
596 | if(OS2Hwnd == 0) {
|
---|
597 | dprintf(("Window creation failed!!"));
|
---|
598 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
599 | return FALSE;
|
---|
600 | }
|
---|
601 |
|
---|
602 | SetLastError(0);
|
---|
603 | return TRUE;
|
---|
604 | }
|
---|
605 | //******************************************************************************
|
---|
606 | //******************************************************************************
|
---|
607 | BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
|
---|
608 | {
|
---|
609 | POINT maxPos;
|
---|
610 | CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method
|
---|
611 |
|
---|
612 | OS2Hwnd = hwndClient;
|
---|
613 | OS2HwndFrame = hwndFrame;
|
---|
614 |
|
---|
615 | fNoSizeMsg = TRUE;
|
---|
616 |
|
---|
617 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
|
---|
618 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
|
---|
619 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
620 | return FALSE;
|
---|
621 | }
|
---|
622 | if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
---|
623 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
|
---|
624 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
625 | return FALSE;
|
---|
626 | }
|
---|
627 | #if 0
|
---|
628 | if(OS2Hwnd != OS2HwndFrame) {
|
---|
629 | if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
|
---|
630 | dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
|
---|
631 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
632 | return FALSE;
|
---|
633 | }
|
---|
634 | if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
|
---|
635 | dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
|
---|
636 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
637 | return FALSE;
|
---|
638 | }
|
---|
639 | }
|
---|
640 | #endif
|
---|
641 |
|
---|
642 | OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
|
---|
643 |
|
---|
644 | FrameGetScrollBarHandles(this,dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
|
---|
645 | subclassScrollBars(dwStyle & WS_HSCROLL,dwStyle & WS_VSCROLL);
|
---|
646 |
|
---|
647 | if(!fOS2Look)
|
---|
648 | FrameSubclassTitleBar(this);
|
---|
649 |
|
---|
650 | fakeWinBase.hwndThis = OS2Hwnd;
|
---|
651 | fakeWinBase.pWindowClass = windowClass;
|
---|
652 |
|
---|
653 | //Set icon from class
|
---|
654 | if(windowClass->getIcon())
|
---|
655 | SetIcon(windowClass->getIcon());
|
---|
656 |
|
---|
657 | /* Get class or window DC if needed */
|
---|
658 | if(windowClass->getStyle() & CS_OWNDC) {
|
---|
659 | dprintf(("Class with CS_OWNDC style"));
|
---|
660 | // ownDC = GetWindowDC(getWindowHandle());
|
---|
661 | }
|
---|
662 | else
|
---|
663 | if (windowClass->getStyle() & CS_PARENTDC) {
|
---|
664 | dprintf(("WARNING: Class with CS_PARENTDC style!"));
|
---|
665 | fParentDC = TRUE;
|
---|
666 | ownDC = 0;
|
---|
667 | }
|
---|
668 | else
|
---|
669 | if (windowClass->getStyle() & CS_CLASSDC) {
|
---|
670 | dprintf(("WARNING: Class with CS_CLASSDC style!"));
|
---|
671 | ownDC = 0;
|
---|
672 | }
|
---|
673 | /* Set the window menu */
|
---|
674 | if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
|
---|
675 | {
|
---|
676 | if (cs->hMenu) {
|
---|
677 | SetMenu(cs->hMenu);
|
---|
678 | }
|
---|
679 | else {
|
---|
680 | if (windowClass->getMenuNameA()) {
|
---|
681 | cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
|
---|
682 | if (cs->hMenu) SetMenu(cs->hMenu );
|
---|
683 | }
|
---|
684 | }
|
---|
685 | }
|
---|
686 | else
|
---|
687 | {
|
---|
688 | setWindowId((DWORD)cs->hMenu);
|
---|
689 | }
|
---|
690 |
|
---|
691 | // Subclass frame
|
---|
692 | pOldFrameProc = FrameSubclassFrameWindow(this);
|
---|
693 | if (isChild()) FrameSetBorderSize(this,TRUE);
|
---|
694 |
|
---|
695 | /* Send the WM_CREATE message
|
---|
696 | * Perhaps we shouldn't allow width/height changes as well.
|
---|
697 | * See p327 in "Internals".
|
---|
698 | */
|
---|
699 | maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
|
---|
700 |
|
---|
701 | SetWindowPos(hwndLinkAfter,cs->x,cs->y,cs->cx,cs->cy,SWP_NOACTIVATE | SWP_NOREDRAW);
|
---|
702 |
|
---|
703 | //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
|
---|
704 | fNoSizeMsg = FALSE;
|
---|
705 |
|
---|
706 | if(SendInternalMessageA(WM_NCCREATE, 0, (LPARAM)cs) )
|
---|
707 | {
|
---|
708 | fCreated = TRUE;
|
---|
709 |
|
---|
710 | SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
|
---|
711 | // OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
|
---|
712 | if( (SendInternalMessageA(WM_CREATE, 0, (LPARAM)cs )) != -1 )
|
---|
713 | {
|
---|
714 | if(!(flags & WIN_NEED_SIZE)) {
|
---|
715 | SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
|
---|
716 | MAKELONG(rectClient.right-rectClient.left,
|
---|
717 | rectClient.bottom-rectClient.top));
|
---|
718 | SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
|
---|
719 | }
|
---|
720 |
|
---|
721 | if( getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
722 | {
|
---|
723 | /* Notify the parent window only */
|
---|
724 | SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
|
---|
725 | if(!::IsWindow(getWindowHandle()))
|
---|
726 | {
|
---|
727 | dprintf(("Createwindow: WM_PARENTNOTIFY destroyed window"));
|
---|
728 | goto end;
|
---|
729 | }
|
---|
730 | }
|
---|
731 |
|
---|
732 | if (cs->style & WS_VISIBLE) ShowWindow( sw );
|
---|
733 |
|
---|
734 | /* Call WH_SHELL hook */
|
---|
735 | if (!(getStyle() & WS_CHILD) && !owner)
|
---|
736 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWCREATED, getWindowHandle(), 0 );
|
---|
737 |
|
---|
738 | SetLastError(0);
|
---|
739 | return TRUE;
|
---|
740 | }
|
---|
741 | }
|
---|
742 | dprintf(("Window creation FAILED (NCCREATE cancelled creation)"));
|
---|
743 | SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
|
---|
744 | end:
|
---|
745 | return FALSE;
|
---|
746 | }
|
---|
747 | //******************************************************************************
|
---|
748 | //******************************************************************************
|
---|
749 | ULONG Win32BaseWindow::MsgQuit()
|
---|
750 | {
|
---|
751 | return SendInternalMessageA(WM_QUIT, 0, 0);
|
---|
752 | }
|
---|
753 | //******************************************************************************
|
---|
754 | //******************************************************************************
|
---|
755 | ULONG Win32BaseWindow::MsgClose()
|
---|
756 | {
|
---|
757 | return SendInternalMessageA(WM_CLOSE,0,0);
|
---|
758 | }
|
---|
759 | //******************************************************************************
|
---|
760 | //******************************************************************************
|
---|
761 | ULONG Win32BaseWindow::MsgDestroy()
|
---|
762 | {
|
---|
763 | ULONG rc;
|
---|
764 | Win32BaseWindow *child;
|
---|
765 | HWND hwnd = getWindowHandle();
|
---|
766 |
|
---|
767 | if (isSubclassedOS2Wnd) OSLibWinSubclassWindow(OS2Hwnd,pOldWndProc);
|
---|
768 |
|
---|
769 | fIsDestroyed = TRUE;
|
---|
770 |
|
---|
771 | if(fDestroyWindowCalled == FALSE)
|
---|
772 | {//this window was destroyed because DestroyWindow was called for it's parent
|
---|
773 | //so: send a WM_PARENTNOTIFY now as that hasn't happened yet
|
---|
774 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
---|
775 | {
|
---|
776 | if(getParent())
|
---|
777 | {
|
---|
778 | /* Notify the parent window only */
|
---|
779 | getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
---|
780 | }
|
---|
781 | else DebugInt3();
|
---|
782 | }
|
---|
783 | }
|
---|
784 | SendInternalMessageA(WM_DESTROY, 0, 0);
|
---|
785 | if(::IsWindow(hwnd) == FALSE) {
|
---|
786 | //object already destroyed, so return immediately
|
---|
787 | return 1;
|
---|
788 | }
|
---|
789 | SendInternalMessageA(WM_NCDESTROY, 0, 0);
|
---|
790 |
|
---|
791 | if (hwndHorzScroll && (OSLibWinQueryWindow(hwndHorzScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow())) OSLibWinDestroyWindow(hwndHorzScroll);
|
---|
792 | if (hwndVertScroll && (OSLibWinQueryWindow(hwndVertScroll,QWOS_PARENT) == OSLibWinQueryObjectWindow())) OSLibWinDestroyWindow(hwndVertScroll);
|
---|
793 |
|
---|
794 | TIMER_KillTimerFromWindow(OS2Hwnd);
|
---|
795 |
|
---|
796 | if(getFirstChild() == NULL) {
|
---|
797 | delete this;
|
---|
798 | }
|
---|
799 | return 1;
|
---|
800 | }
|
---|
801 | //******************************************************************************
|
---|
802 | //******************************************************************************
|
---|
803 | ULONG Win32BaseWindow::MsgEnable(BOOL fEnable)
|
---|
804 | {
|
---|
805 | if(fEnable) {
|
---|
806 | dwStyle &= ~WS_DISABLED;
|
---|
807 | }
|
---|
808 | else dwStyle |= WS_DISABLED;
|
---|
809 |
|
---|
810 | return SendInternalMessageA(WM_ENABLE, fEnable, 0);
|
---|
811 | }
|
---|
812 | //******************************************************************************
|
---|
813 | //TODO: SW_PARENTCLOSING/OPENING flag (lParam)
|
---|
814 | //******************************************************************************
|
---|
815 | ULONG Win32BaseWindow::MsgShow(BOOL fShow)
|
---|
816 | {
|
---|
817 | if(fNoSizeMsg) {
|
---|
818 | return 1;
|
---|
819 | }
|
---|
820 |
|
---|
821 | if(fShow) {
|
---|
822 | setStyle(getStyle() | WS_VISIBLE);
|
---|
823 | }
|
---|
824 | else setStyle(getStyle() & ~WS_VISIBLE);
|
---|
825 |
|
---|
826 | return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
|
---|
827 | }
|
---|
828 | //******************************************************************************
|
---|
829 | //******************************************************************************
|
---|
830 | ULONG Win32BaseWindow::MsgPosChanging(LPARAM lp)
|
---|
831 | {
|
---|
832 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
---|
833 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
---|
834 | if(fNoSizeMsg || fDestroyWindowCalled)
|
---|
835 | return 1;
|
---|
836 |
|
---|
837 | return SendInternalMessageA(WM_WINDOWPOSCHANGING, 0, lp);
|
---|
838 | }
|
---|
839 | //******************************************************************************
|
---|
840 | //******************************************************************************
|
---|
841 | ULONG Win32BaseWindow::MsgPosChanged(LPARAM lp)
|
---|
842 | {
|
---|
843 | //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
|
---|
844 | // a WM_WINDOWPOSCHANGED msg -> crash)
|
---|
845 | if(fNoSizeMsg || fDestroyWindowCalled)
|
---|
846 | return 1;
|
---|
847 |
|
---|
848 | return SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, lp);
|
---|
849 | }
|
---|
850 | //******************************************************************************
|
---|
851 | //******************************************************************************
|
---|
852 | #if 0
|
---|
853 | ULONG Win32BaseWindow::MsgMinMax()
|
---|
854 | {
|
---|
855 |
|
---|
856 | }
|
---|
857 | #endif
|
---|
858 | //******************************************************************************
|
---|
859 | //******************************************************************************
|
---|
860 | ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
|
---|
861 | {
|
---|
862 | //According to the SDK docs, the scrollbar handle (lParam) is 0 when the standard
|
---|
863 | //window scrollbars send these messages
|
---|
864 | return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
|
---|
865 | }
|
---|
866 | //******************************************************************************
|
---|
867 | // NOTE: WM_NCHITTEST messages are sent whenever the mouse cursor moves or a mouse button is clicked/released
|
---|
868 | // (directly when receiving those messages)
|
---|
869 | //******************************************************************************
|
---|
870 | ULONG Win32BaseWindow::MsgHitTest(ULONG x, ULONG y)
|
---|
871 | {
|
---|
872 | lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, MAKELONG((USHORT)x, (USHORT)y));
|
---|
873 | dprintf(("MsgHitTest (%d,%d) (%d,%d) (%d,%d) returned %x", x, y, rectWindow.left, rectWindow.right, rectWindow.top, rectWindow.bottom, lastHitTestVal));
|
---|
874 | return lastHitTestVal;
|
---|
875 | }
|
---|
876 | //******************************************************************************
|
---|
877 | //******************************************************************************
|
---|
878 | ULONG Win32BaseWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd)
|
---|
879 | {
|
---|
880 | ULONG rc, curprocid, procidhwnd = -1, threadidhwnd = 0;
|
---|
881 |
|
---|
882 |
|
---|
883 | //According to SDK docs, if app returns FALSE & window is being deactivated,
|
---|
884 | //default processing is cancelled
|
---|
885 | //TODO: According to Wine we should proceed anyway if window is sysmodal
|
---|
886 | if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
|
---|
887 | {
|
---|
888 | return 0;
|
---|
889 | }
|
---|
890 | rc = SendInternalMessageA(WM_ACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd);
|
---|
891 |
|
---|
892 | curprocid = GetCurrentProcessId();
|
---|
893 | if(hwnd) {
|
---|
894 | threadidhwnd = GetWindowThreadProcessId(hwnd, &procidhwnd);
|
---|
895 | }
|
---|
896 |
|
---|
897 | if(curprocid != procidhwnd && fActivate) {
|
---|
898 | SendInternalMessageA(WM_ACTIVATEAPP, 1, threadidhwnd);
|
---|
899 | }
|
---|
900 | return rc;
|
---|
901 | }
|
---|
902 | //******************************************************************************
|
---|
903 | //TODO: Is this correct and complete?
|
---|
904 | //Add print screen, break & numlock
|
---|
905 | //******************************************************************************
|
---|
906 | void Win32BaseWindow::setExtendedKey(ULONG virtualkey, ULONG *lParam)
|
---|
907 | {
|
---|
908 | switch(virtualkey) {
|
---|
909 | case VK_DOWN:
|
---|
910 | case VK_UP:
|
---|
911 | case VK_PRIOR:
|
---|
912 | case VK_NEXT:
|
---|
913 | case VK_END:
|
---|
914 | case VK_DIVIDE:
|
---|
915 | case VK_DELETE:
|
---|
916 | case VK_EXECUTE: //Numeric enter key?
|
---|
917 | case VK_HOME:
|
---|
918 | case VK_INSERT:
|
---|
919 | case VK_RCONTROL:
|
---|
920 | case VK_RMENU: //is this the right alt???
|
---|
921 | *lParam = *lParam | (1<<24);
|
---|
922 | }
|
---|
923 | }
|
---|
924 | //******************************************************************************
|
---|
925 | //******************************************************************************
|
---|
926 | ULONG Win32BaseWindow::DispatchMsgA(MSG *msg)
|
---|
927 | {
|
---|
928 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
|
---|
929 | }
|
---|
930 | //******************************************************************************
|
---|
931 | //******************************************************************************
|
---|
932 | ULONG Win32BaseWindow::DispatchMsgW(MSG *msg)
|
---|
933 | {
|
---|
934 | return SendInternalMessageW(msg->message, msg->wParam, msg->lParam);
|
---|
935 | }
|
---|
936 | //******************************************************************************
|
---|
937 | //******************************************************************************
|
---|
938 | ULONG Win32BaseWindow::MsgSetFocus(HWND hwnd)
|
---|
939 | {
|
---|
940 | return SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
|
---|
941 | }
|
---|
942 | //******************************************************************************
|
---|
943 | //******************************************************************************
|
---|
944 | ULONG Win32BaseWindow::MsgKillFocus(HWND hwnd)
|
---|
945 | {
|
---|
946 | return SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
|
---|
947 | }
|
---|
948 | //******************************************************************************
|
---|
949 | //******************************************************************************
|
---|
950 | ULONG Win32BaseWindow::MsgButton(MSG *msg)
|
---|
951 | {
|
---|
952 | BOOL fClick = FALSE;
|
---|
953 |
|
---|
954 | dprintf(("MsgButton at (%d,%d)", msg->pt.x, msg->pt.y));
|
---|
955 | switch(msg->message) {
|
---|
956 | case WM_LBUTTONDBLCLK:
|
---|
957 | case WM_RBUTTONDBLCLK:
|
---|
958 | case WM_MBUTTONDBLCLK:
|
---|
959 | case WM_NCLBUTTONDBLCLK:
|
---|
960 | case WM_NCRBUTTONDBLCLK:
|
---|
961 | case WM_NCMBUTTONDBLCLK:
|
---|
962 | if (!(windowClass && windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS))
|
---|
963 | {
|
---|
964 | msg->message = msg->message - (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN); //dblclick -> down
|
---|
965 | MsgButton(msg);
|
---|
966 | msg->message++; //button-up
|
---|
967 | return MsgButton(msg);
|
---|
968 | }
|
---|
969 | break;
|
---|
970 | case WM_LBUTTONDOWN:
|
---|
971 | case WM_RBUTTONDOWN:
|
---|
972 | case WM_MBUTTONDOWN:
|
---|
973 | case WM_NCLBUTTONDOWN:
|
---|
974 | case WM_NCRBUTTONDOWN:
|
---|
975 | case WM_NCMBUTTONDOWN:
|
---|
976 | fClick = TRUE;
|
---|
977 | break;
|
---|
978 | }
|
---|
979 |
|
---|
980 | if(ISMOUSE_CAPTURED())
|
---|
981 | {
|
---|
982 | if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_BUTTON, msg->pt.x, msg->pt.y))
|
---|
983 | return 0;
|
---|
984 | }
|
---|
985 |
|
---|
986 | if(fClick)
|
---|
987 | {
|
---|
988 | HWND hwndTop;
|
---|
989 |
|
---|
990 | /* Activate the window if needed */
|
---|
991 | if(isSubclassedOS2Wnd()) {
|
---|
992 | Win32BaseWindow *parentwnd = GetWindowFromOS2FrameHandle(OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT));
|
---|
993 | if(parentwnd) {
|
---|
994 | hwndTop = (parentwnd->GetTopParent()) ? parentwnd->GetTopParent()->getWindowHandle() : 0;
|
---|
995 | }
|
---|
996 | else hwndTop = 0;
|
---|
997 | }
|
---|
998 | else hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
|
---|
999 |
|
---|
1000 | HWND hwndActive = GetActiveWindow();
|
---|
1001 | if (hwndTop && (getWindowHandle() != hwndActive))
|
---|
1002 | {
|
---|
1003 | LONG ret = SendInternalMessageA(WM_MOUSEACTIVATE, hwndTop,
|
---|
1004 | MAKELONG( lastHitTestVal, msg->message) );
|
---|
1005 |
|
---|
1006 | #if 0
|
---|
1007 | if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
|
---|
1008 | eatMsg = TRUE;
|
---|
1009 | #endif
|
---|
1010 | if(((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
|
---|
1011 | && hwndTop != GetForegroundWindow() )
|
---|
1012 | {
|
---|
1013 | ::SetActiveWindow(hwndTop);
|
---|
1014 | }
|
---|
1015 | }
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | SendInternalMessageA(WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
|
---|
1019 |
|
---|
1020 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
|
---|
1021 | }
|
---|
1022 | //******************************************************************************
|
---|
1023 | //******************************************************************************
|
---|
1024 | ULONG Win32BaseWindow::MsgPaint(ULONG tmp1, BOOL select)
|
---|
1025 | {
|
---|
1026 | if (select && isIcon)
|
---|
1027 | return SendInternalMessageA(WM_PAINTICON, 0, 0);
|
---|
1028 | else
|
---|
1029 | return SendInternalMessageA(WM_PAINT, 0, 0);
|
---|
1030 | }
|
---|
1031 | //******************************************************************************
|
---|
1032 | //TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
|
---|
1033 | // (or are we simply erasing too much here)
|
---|
1034 | //******************************************************************************
|
---|
1035 | ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
|
---|
1036 | {
|
---|
1037 | ULONG rc;
|
---|
1038 | HDC hdcErase = hdc;
|
---|
1039 |
|
---|
1040 | if (hdcErase == 0)
|
---|
1041 | hdcErase = O32_GetDC(OS2Hwnd);
|
---|
1042 |
|
---|
1043 | if(isIcon)
|
---|
1044 | rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
|
---|
1045 | else
|
---|
1046 | rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
|
---|
1047 | if (hdc == 0)
|
---|
1048 | O32_ReleaseDC(OS2Hwnd, hdcErase);
|
---|
1049 | return (rc);
|
---|
1050 | }
|
---|
1051 | //******************************************************************************
|
---|
1052 | //******************************************************************************
|
---|
1053 | ULONG Win32BaseWindow::MsgMouseMove(MSG *msg)
|
---|
1054 | {
|
---|
1055 | if(ISMOUSE_CAPTURED()) {
|
---|
1056 | if(DInputMouseHandler(getWindowHandle(), MOUSEMSG_MOVE, msg->pt.x, msg->pt.y))
|
---|
1057 | return 0;
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | //SvL: Correct??
|
---|
1061 | if(msg->message != WM_NCMOUSEMOVE) {
|
---|
1062 | //TODO: hiword should be 0 if window enters menu mode (SDK docs)
|
---|
1063 | SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, msg->message));
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | //translated message == WM_(NC)MOUSEMOVE
|
---|
1067 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
|
---|
1068 | }
|
---|
1069 | //******************************************************************************
|
---|
1070 | //TODO: Depending on menu type, we should send WM_INITMENU or WM_INITPOPUPMENU
|
---|
1071 | //TODO: PM sends it for each submenu that gets activated; Windows only for the first
|
---|
1072 | // submenu; once the menu bar is active, moving the cursor doesn't generate other
|
---|
1073 | // WM_INITMENU msgs. Not really a problem, but might need to fix this later on.
|
---|
1074 | //******************************************************************************
|
---|
1075 | ULONG Win32BaseWindow::MsgInitMenu(MSG *msg)
|
---|
1076 | {
|
---|
1077 | return SendInternalMessageA(msg->message, msg->wParam, msg->lParam);
|
---|
1078 | }
|
---|
1079 | //******************************************************************************
|
---|
1080 | //******************************************************************************
|
---|
1081 | ULONG Win32BaseWindow::MsgNCPaint()
|
---|
1082 | {
|
---|
1083 | return SendInternalMessageA(WM_PAINT, 0, 0);
|
---|
1084 | }
|
---|
1085 | //******************************************************************************
|
---|
1086 | //******************************************************************************
|
---|
1087 | ULONG Win32BaseWindow::MsgSetText(LPSTR lpsz, LONG cch)
|
---|
1088 | {
|
---|
1089 | return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
|
---|
1090 | }
|
---|
1091 | //******************************************************************************
|
---|
1092 | //******************************************************************************
|
---|
1093 | ULONG Win32BaseWindow::MsgGetTextLength()
|
---|
1094 | {
|
---|
1095 | return SendInternalMessageA(WM_GETTEXTLENGTH, 0, 0);
|
---|
1096 | }
|
---|
1097 | //******************************************************************************
|
---|
1098 | //******************************************************************************
|
---|
1099 | char *Win32BaseWindow::MsgGetText()
|
---|
1100 | {
|
---|
1101 | SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
|
---|
1102 | return windowNameA;
|
---|
1103 | }
|
---|
1104 | //******************************************************************************
|
---|
1105 | //******************************************************************************
|
---|
1106 | ULONG Win32BaseWindow::MsgContextMenu(ULONG x,ULONG y)
|
---|
1107 | {
|
---|
1108 | return SendInternalMessageA(WM_CONTEXTMENU,Win32Hwnd,MAKELPARAM(x,y));
|
---|
1109 | }
|
---|
1110 | //******************************************************************************
|
---|
1111 | //******************************************************************************
|
---|
1112 | BOOL Win32BaseWindow::isMDIClient()
|
---|
1113 | {
|
---|
1114 | return FALSE;
|
---|
1115 | }
|
---|
1116 | //******************************************************************************
|
---|
1117 | //******************************************************************************
|
---|
1118 | BOOL Win32BaseWindow::isMDIChild()
|
---|
1119 | {
|
---|
1120 | return FALSE;
|
---|
1121 | }
|
---|
1122 | //******************************************************************************
|
---|
1123 | //TODO: Not complete
|
---|
1124 | //******************************************************************************
|
---|
1125 | BOOL Win32BaseWindow::isFrameWindow()
|
---|
1126 | {
|
---|
1127 | // if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
|
---|
1128 | if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
|
---|
1129 | return TRUE;
|
---|
1130 |
|
---|
1131 | return FALSE;
|
---|
1132 | }
|
---|
1133 | //******************************************************************************
|
---|
1134 | //******************************************************************************
|
---|
1135 | SCROLLBAR_INFO *Win32BaseWindow::getScrollInfo(int nBar)
|
---|
1136 | {
|
---|
1137 | switch(nBar)
|
---|
1138 | {
|
---|
1139 | case SB_HORZ:
|
---|
1140 | return horzScrollInfo;
|
---|
1141 |
|
---|
1142 | case SB_VERT:
|
---|
1143 | return vertScrollInfo;
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | return NULL;
|
---|
1147 | }
|
---|
1148 | //******************************************************************************
|
---|
1149 | //******************************************************************************
|
---|
1150 | VOID Win32BaseWindow::subclassScrollBars(BOOL subHorz,BOOL subVert)
|
---|
1151 | {
|
---|
1152 | SCROLL_SubclassScrollBars(subHorz ? hwndHorzScroll:0,subVert ? hwndVertScroll:0);
|
---|
1153 | }
|
---|
1154 | //******************************************************************************
|
---|
1155 | //******************************************************************************
|
---|
1156 | BOOL Win32BaseWindow::showScrollBars(BOOL changeHorz,BOOL changeVert,BOOL fShow)
|
---|
1157 | {
|
---|
1158 | BOOL rc = TRUE;
|
---|
1159 | DWORD flags = 0;
|
---|
1160 |
|
---|
1161 | if (fShow)
|
---|
1162 | {
|
---|
1163 | BOOL createHorz = FALSE,createVert = FALSE;
|
---|
1164 | BOOL showHorz = FALSE,showVert = FALSE;
|
---|
1165 |
|
---|
1166 | if (changeHorz)
|
---|
1167 | {
|
---|
1168 | if (!hwndHorzScroll)
|
---|
1169 | createHorz = TRUE;
|
---|
1170 | else
|
---|
1171 | showHorz = TRUE;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | if (changeVert)
|
---|
1175 | {
|
---|
1176 | if (!hwndVertScroll)
|
---|
1177 | createVert = TRUE;
|
---|
1178 | else
|
---|
1179 | showVert = TRUE;
|
---|
1180 | }
|
---|
1181 |
|
---|
1182 | if (createHorz || createVert)
|
---|
1183 | {
|
---|
1184 | if (createHorz && !horzScrollInfo)
|
---|
1185 | {
|
---|
1186 | horzScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
1187 | horzScrollInfo->MinVal = horzScrollInfo->CurVal = horzScrollInfo->Page = 0;
|
---|
1188 | horzScrollInfo->MaxVal = 100;
|
---|
1189 | horzScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | if (createVert && !vertScrollInfo)
|
---|
1193 | {
|
---|
1194 | vertScrollInfo = (SCROLLBAR_INFO*)malloc(sizeof(SCROLLBAR_INFO));
|
---|
1195 | vertScrollInfo->MinVal = vertScrollInfo->CurVal = vertScrollInfo->Page = 0;
|
---|
1196 | vertScrollInfo->MaxVal = 100;
|
---|
1197 | vertScrollInfo->flags = ESB_ENABLE_BOTH;
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | rc = FrameCreateScrollBars(this,createHorz,createVert,FALSE,&flags);
|
---|
1201 |
|
---|
1202 | if (!rc) return FALSE;
|
---|
1203 | if (createHorz) dwStyle |= WS_HSCROLL;
|
---|
1204 | if (createVert) dwStyle |= WS_VSCROLL;
|
---|
1205 | }
|
---|
1206 |
|
---|
1207 | if (showVert || showHorz)
|
---|
1208 | {
|
---|
1209 | DWORD newFlags;
|
---|
1210 |
|
---|
1211 | rc = FrameShowScrollBars(this,showHorz,showVert,fShow,FALSE,&newFlags);
|
---|
1212 | flags |= newFlags;
|
---|
1213 | if (rc)
|
---|
1214 | {
|
---|
1215 | if (showHorz) dwStyle |= WS_HSCROLL;
|
---|
1216 | if (showVert) dwStyle |= WS_VSCROLL;
|
---|
1217 | }
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 | if (flags) FrameUpdateFrame(this,flags);
|
---|
1221 | } else
|
---|
1222 | {
|
---|
1223 | rc = FrameShowScrollBars(this,changeHorz && hwndHorzScroll,changeVert && hwndVertScroll,fShow,TRUE);
|
---|
1224 |
|
---|
1225 | if (rc)
|
---|
1226 | {
|
---|
1227 | if (changeHorz) dwStyle &= ~WS_HSCROLL;
|
---|
1228 | if (changeVert) dwStyle &= ~WS_VSCROLL;
|
---|
1229 | }
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | return rc;
|
---|
1233 | }
|
---|
1234 | /***********************************************************************
|
---|
1235 | * NC_HandleSysCommand
|
---|
1236 | *
|
---|
1237 | * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
|
---|
1238 | *
|
---|
1239 | * TODO: Not done (see #if 0)
|
---|
1240 | */
|
---|
1241 | LONG Win32BaseWindow::HandleSysCommand(WPARAM wParam, POINT *pt32)
|
---|
1242 | {
|
---|
1243 | UINT uCommand = wParam & 0xFFF0;
|
---|
1244 |
|
---|
1245 | if ((getStyle() & WS_CHILD) && (uCommand != SC_KEYMENU))
|
---|
1246 | ScreenToClient(getParent()->getWindowHandle(), pt32 );
|
---|
1247 |
|
---|
1248 | switch (uCommand)
|
---|
1249 | {
|
---|
1250 |
|
---|
1251 | case SC_SIZE:
|
---|
1252 | {
|
---|
1253 | DWORD flags = 0;
|
---|
1254 |
|
---|
1255 | switch ((wParam & 0xF)+2)
|
---|
1256 | {
|
---|
1257 | case HTLEFT:
|
---|
1258 | flags = TFOS_LEFT;
|
---|
1259 | break;
|
---|
1260 |
|
---|
1261 | case HTRIGHT:
|
---|
1262 | flags = TFOS_RIGHT;
|
---|
1263 | break;
|
---|
1264 |
|
---|
1265 | case HTTOP:
|
---|
1266 | flags = TFOS_TOP;
|
---|
1267 | break;
|
---|
1268 |
|
---|
1269 | case HTTOPLEFT:
|
---|
1270 | flags = TFOS_TOP | TFOS_LEFT;
|
---|
1271 | break;
|
---|
1272 |
|
---|
1273 | case HTTOPRIGHT:
|
---|
1274 | flags = TFOS_TOP | TFOS_RIGHT;
|
---|
1275 | break;
|
---|
1276 |
|
---|
1277 | case HTBOTTOM:
|
---|
1278 | flags = TFOS_BOTTOM;
|
---|
1279 | break;
|
---|
1280 |
|
---|
1281 | case HTBOTTOMLEFT:
|
---|
1282 | flags = TFOS_BOTTOM | TFOS_LEFT;
|
---|
1283 | break;
|
---|
1284 |
|
---|
1285 | case HTBOTTOMRIGHT:
|
---|
1286 | flags = TFOS_BOTTOM | TFOS_RIGHT;
|
---|
1287 | break;
|
---|
1288 | }
|
---|
1289 | if (flags) FrameTrackFrame(this,flags);
|
---|
1290 | break;
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 | case SC_MOVE:
|
---|
1294 | FrameTrackFrame(this,TFOS_MOVE);
|
---|
1295 | break;
|
---|
1296 |
|
---|
1297 | case SC_MINIMIZE:
|
---|
1298 | ShowWindow(SW_MINIMIZE);
|
---|
1299 | break;
|
---|
1300 |
|
---|
1301 | case SC_MAXIMIZE:
|
---|
1302 | ShowWindow(SW_MAXIMIZE);
|
---|
1303 | break;
|
---|
1304 |
|
---|
1305 | case SC_RESTORE:
|
---|
1306 | ShowWindow(SW_RESTORE);
|
---|
1307 | break;
|
---|
1308 |
|
---|
1309 | case SC_CLOSE:
|
---|
1310 | return SendInternalMessageA(WM_CLOSE, 0, 0);
|
---|
1311 |
|
---|
1312 | #if 0
|
---|
1313 | case SC_VSCROLL:
|
---|
1314 | case SC_HSCROLL:
|
---|
1315 | NC_TrackScrollBar( hwnd, wParam, pt32 );
|
---|
1316 | break;
|
---|
1317 |
|
---|
1318 | case SC_MOUSEMENU:
|
---|
1319 | MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt32 );
|
---|
1320 | break;
|
---|
1321 |
|
---|
1322 | case SC_KEYMENU:
|
---|
1323 | MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
|
---|
1324 | break;
|
---|
1325 |
|
---|
1326 | case SC_TASKLIST:
|
---|
1327 | WinExec( "taskman.exe", SW_SHOWNORMAL );
|
---|
1328 | break;
|
---|
1329 |
|
---|
1330 | case SC_SCREENSAVE:
|
---|
1331 | if (wParam == SC_ABOUTWINE)
|
---|
1332 | ShellAboutA(hwnd, "Odin", WINE_RELEASE_INFO, 0);
|
---|
1333 | else
|
---|
1334 | if (wParam == SC_PUTMARK)
|
---|
1335 | dprintf(("Mark requested by user\n"));
|
---|
1336 | break;
|
---|
1337 |
|
---|
1338 | case SC_HOTKEY:
|
---|
1339 | case SC_ARRANGE:
|
---|
1340 | case SC_NEXTWINDOW:
|
---|
1341 | case SC_PREVWINDOW:
|
---|
1342 | break;
|
---|
1343 | #endif
|
---|
1344 | }
|
---|
1345 | return 0;
|
---|
1346 | }
|
---|
1347 | //******************************************************************************
|
---|
1348 | //******************************************************************************
|
---|
1349 | LRESULT Win32BaseWindow::DefWndControlColor(UINT ctlType, HDC hdc)
|
---|
1350 | {
|
---|
1351 | //SvL: Set background color to default button color (not window (white))
|
---|
1352 | if(ctlType == CTLCOLOR_BTN)
|
---|
1353 | {
|
---|
1354 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
---|
1355 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1356 | return GetSysColorBrush(COLOR_BTNFACE);
|
---|
1357 | }
|
---|
1358 | //SvL: Set background color to default dialog color if window is dialog
|
---|
1359 | if((ctlType == CTLCOLOR_DLG || ctlType == CTLCOLOR_STATIC) && IsDialog()) {
|
---|
1360 | SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
---|
1361 | SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1362 | return GetSysColorBrush(COLOR_BTNFACE);
|
---|
1363 | }
|
---|
1364 |
|
---|
1365 | if( ctlType == CTLCOLOR_SCROLLBAR)
|
---|
1366 | {
|
---|
1367 | HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR);
|
---|
1368 | COLORREF bk = GetSysColor(COLOR_3DHILIGHT);
|
---|
1369 | SetTextColor( hdc, GetSysColor(COLOR_3DFACE));
|
---|
1370 | SetBkColor( hdc, bk);
|
---|
1371 |
|
---|
1372 | //TODO?
|
---|
1373 | #if 0
|
---|
1374 | /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
|
---|
1375 | * we better use 0x55aa bitmap brush to make scrollbar's background
|
---|
1376 | * look different from the window background.
|
---|
1377 | */
|
---|
1378 | if (bk == GetSysColor(COLOR_WINDOW)) {
|
---|
1379 | return CACHE_GetPattern55AABrush();
|
---|
1380 | }
|
---|
1381 | #endif
|
---|
1382 | UnrealizeObject( hb );
|
---|
1383 | return (LRESULT)hb;
|
---|
1384 | }
|
---|
1385 |
|
---|
1386 | SetTextColor( hdc, GetSysColor(COLOR_WINDOWTEXT));
|
---|
1387 |
|
---|
1388 | if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
|
---|
1389 | {
|
---|
1390 | SetBkColor( hdc, GetSysColor(COLOR_WINDOW) );
|
---|
1391 | }
|
---|
1392 | else
|
---|
1393 | {
|
---|
1394 | SetBkColor( hdc, GetSysColor(COLOR_3DFACE) );
|
---|
1395 | return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
|
---|
1396 | }
|
---|
1397 | return (LRESULT)GetSysColorBrush(COLOR_WINDOW);
|
---|
1398 | }
|
---|
1399 | //******************************************************************************
|
---|
1400 | //******************************************************************************
|
---|
1401 | LRESULT Win32BaseWindow::DefWndPrint(HDC hdc,ULONG uFlags)
|
---|
1402 | {
|
---|
1403 | /*
|
---|
1404 | * Visibility flag.
|
---|
1405 | */
|
---|
1406 | if ( (uFlags & PRF_CHECKVISIBLE) &&
|
---|
1407 | !IsWindowVisible() )
|
---|
1408 | return 0;
|
---|
1409 |
|
---|
1410 | /*
|
---|
1411 | * Unimplemented flags.
|
---|
1412 | */
|
---|
1413 | if ( (uFlags & PRF_CHILDREN) ||
|
---|
1414 | (uFlags & PRF_OWNED) ||
|
---|
1415 | (uFlags & PRF_NONCLIENT) )
|
---|
1416 | {
|
---|
1417 | dprintf(("WM_PRINT message with unsupported flags\n"));
|
---|
1418 | }
|
---|
1419 |
|
---|
1420 | /*
|
---|
1421 | * Background
|
---|
1422 | */
|
---|
1423 | if ( uFlags & PRF_ERASEBKGND)
|
---|
1424 | SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
|
---|
1425 |
|
---|
1426 | /*
|
---|
1427 | * Client area
|
---|
1428 | */
|
---|
1429 | if ( uFlags & PRF_CLIENT)
|
---|
1430 | SendInternalMessageA(WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
|
---|
1431 |
|
---|
1432 |
|
---|
1433 | return 0;
|
---|
1434 | }
|
---|
1435 | //******************************************************************************
|
---|
1436 | //******************************************************************************
|
---|
1437 | LRESULT Win32BaseWindow::DefWindowProcA(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
1438 | {
|
---|
1439 | fDefWndProcCalled = TRUE;
|
---|
1440 | switch(Msg)
|
---|
1441 | {
|
---|
1442 | case WM_CLOSE:
|
---|
1443 | dprintf(("DefWindowProcA: WM_CLOSE %x", getWindowHandle()));
|
---|
1444 | DestroyWindow();
|
---|
1445 | return 0;
|
---|
1446 |
|
---|
1447 | case WM_GETTEXTLENGTH:
|
---|
1448 | return wndNameLength;
|
---|
1449 |
|
---|
1450 | case WM_GETTEXT:
|
---|
1451 | if (!lParam || !wParam) return 0;
|
---|
1452 | if (!windowNameA) ((LPSTR)lParam)[0] = 0;
|
---|
1453 | else lstrcpynA((LPSTR)lParam, windowNameA, wParam);
|
---|
1454 | return min(wndNameLength, wParam);
|
---|
1455 |
|
---|
1456 | case WM_SETTEXT:
|
---|
1457 | {
|
---|
1458 | LPCSTR lpsz = (LPCSTR)lParam;
|
---|
1459 |
|
---|
1460 | if(windowNameA) free(windowNameA);
|
---|
1461 | if(windowNameW) free(windowNameW);
|
---|
1462 |
|
---|
1463 | if (lParam)
|
---|
1464 | {
|
---|
1465 | wndNameLength = strlen(lpsz);
|
---|
1466 | windowNameA = (LPSTR)_smalloc(wndNameLength+1);
|
---|
1467 | strcpy(windowNameA, lpsz);
|
---|
1468 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
|
---|
1469 | lstrcpyAtoW(windowNameW, windowNameA);
|
---|
1470 | }
|
---|
1471 | else
|
---|
1472 | {
|
---|
1473 | windowNameA = NULL;
|
---|
1474 | windowNameW = NULL;
|
---|
1475 | wndNameLength = 0;
|
---|
1476 | }
|
---|
1477 | dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
|
---|
1478 |
|
---|
1479 | if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
1480 | return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
|
---|
1481 |
|
---|
1482 | return TRUE;
|
---|
1483 | }
|
---|
1484 |
|
---|
1485 | case WM_SETREDRAW:
|
---|
1486 | {
|
---|
1487 | if (wParam)
|
---|
1488 | {
|
---|
1489 | setStyle(getStyle() | WS_VISIBLE);
|
---|
1490 | OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
|
---|
1491 | }
|
---|
1492 | else
|
---|
1493 | {
|
---|
1494 | if (getStyle() & WS_VISIBLE)
|
---|
1495 | {
|
---|
1496 | setStyle(getStyle() & ~WS_VISIBLE);
|
---|
1497 | OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
|
---|
1498 | }
|
---|
1499 | }
|
---|
1500 | return 0;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | case WM_CTLCOLORMSGBOX:
|
---|
1504 | case WM_CTLCOLOREDIT:
|
---|
1505 | case WM_CTLCOLORLISTBOX:
|
---|
1506 | case WM_CTLCOLORBTN:
|
---|
1507 | case WM_CTLCOLORDLG:
|
---|
1508 | case WM_CTLCOLORSTATIC:
|
---|
1509 | case WM_CTLCOLORSCROLLBAR:
|
---|
1510 | return DefWndControlColor(Msg - WM_CTLCOLORMSGBOX, (HDC)wParam);
|
---|
1511 |
|
---|
1512 | case WM_CTLCOLOR:
|
---|
1513 | return DefWndControlColor(HIWORD(lParam), (HDC)wParam);
|
---|
1514 |
|
---|
1515 | case WM_VKEYTOITEM:
|
---|
1516 | case WM_CHARTOITEM:
|
---|
1517 | return -1;
|
---|
1518 |
|
---|
1519 | case WM_PARENTNOTIFY:
|
---|
1520 | return 0;
|
---|
1521 |
|
---|
1522 | case WM_MOUSEACTIVATE:
|
---|
1523 | {
|
---|
1524 | dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
---|
1525 | if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
1526 | {
|
---|
1527 | if(getParent()) {
|
---|
1528 | LRESULT rc = getParent()->SendInternalMessageA(WM_MOUSEACTIVATE, wParam, lParam );
|
---|
1529 | if(rc) return rc;
|
---|
1530 | }
|
---|
1531 | }
|
---|
1532 | return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
|
---|
1533 | }
|
---|
1534 |
|
---|
1535 | case WM_ACTIVATE:
|
---|
1536 | //CB: todo
|
---|
1537 | return 0;
|
---|
1538 |
|
---|
1539 | case WM_SETCURSOR:
|
---|
1540 | {
|
---|
1541 | dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
|
---|
1542 | if(getStyle() & WS_CHILD && !(getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
1543 | {
|
---|
1544 | if(getParent()) {
|
---|
1545 | LRESULT rc = getParent()->SendInternalMessageA(WM_SETCURSOR, wParam, lParam);
|
---|
1546 | if(rc) return rc;
|
---|
1547 | }
|
---|
1548 | }
|
---|
1549 | if (wParam == Win32Hwnd)
|
---|
1550 | {
|
---|
1551 | HCURSOR hCursor;
|
---|
1552 |
|
---|
1553 | switch(lastHitTestVal)
|
---|
1554 | {
|
---|
1555 | case HTLEFT:
|
---|
1556 | case HTRIGHT:
|
---|
1557 | hCursor = LoadCursorA(0,IDC_SIZEWEA);
|
---|
1558 | break;
|
---|
1559 |
|
---|
1560 | case HTTOP:
|
---|
1561 | case HTBOTTOM:
|
---|
1562 | hCursor = LoadCursorA(0,IDC_SIZENSA);
|
---|
1563 | break;
|
---|
1564 |
|
---|
1565 | case HTTOPLEFT:
|
---|
1566 | case HTBOTTOMRIGHT:
|
---|
1567 | hCursor = LoadCursorA(0,IDC_SIZENWSEA);
|
---|
1568 | break;
|
---|
1569 |
|
---|
1570 | case HTTOPRIGHT:
|
---|
1571 | case HTBOTTOMLEFT:
|
---|
1572 | hCursor = LoadCursorA(0,IDC_SIZENESWA);
|
---|
1573 | break;
|
---|
1574 |
|
---|
1575 | default:
|
---|
1576 | hCursor = windowClass ? windowClass->getCursor():LoadCursorA(0,IDC_ARROWA);
|
---|
1577 | break;
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | if (hCursor)
|
---|
1581 | {
|
---|
1582 | SetCursor(hCursor);
|
---|
1583 | return 1;
|
---|
1584 | } else return 0;
|
---|
1585 | } else return 0;
|
---|
1586 | }
|
---|
1587 |
|
---|
1588 | case WM_MOUSEMOVE:
|
---|
1589 | return 0;
|
---|
1590 |
|
---|
1591 | case WM_WINDOWPOSCHANGED:
|
---|
1592 | {
|
---|
1593 |
|
---|
1594 | /* undocumented SWP flags - from SDK 3.1 */
|
---|
1595 | #define SWP_NOCLIENTSIZE 0x0800
|
---|
1596 | #define SWP_NOCLIENTMOVE 0x1000
|
---|
1597 |
|
---|
1598 | PWINDOWPOS wpos = (PWINDOWPOS)lParam;
|
---|
1599 | WPARAM wp = SIZE_RESTORED;
|
---|
1600 |
|
---|
1601 | if (!(wpos->flags & SWP_NOMOVE) && !(wpos->flags & SWP_NOCLIENTMOVE))
|
---|
1602 | SendInternalMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
|
---|
1603 |
|
---|
1604 | if (!(wpos->flags & SWP_NOSIZE) && !(wpos->flags & SWP_NOCLIENTSIZE))
|
---|
1605 | {
|
---|
1606 | if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
|
---|
1607 | else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
|
---|
1608 |
|
---|
1609 | SendInternalMessageA(WM_SIZE, wp, MAKELONG(rectClient.right - rectClient.left,
|
---|
1610 | rectClient.bottom - rectClient.top));
|
---|
1611 | }
|
---|
1612 | return 0;
|
---|
1613 | }
|
---|
1614 | case WM_WINDOWPOSCHANGING:
|
---|
1615 | return HandleWindowPosChanging((WINDOWPOS *)lParam);
|
---|
1616 |
|
---|
1617 | case WM_ERASEBKGND:
|
---|
1618 | case WM_ICONERASEBKGND:
|
---|
1619 | {
|
---|
1620 | RECT rect;
|
---|
1621 | int rc;
|
---|
1622 |
|
---|
1623 | if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
|
---|
1624 |
|
---|
1625 | rc = GetClipBox( (HDC)wParam, &rect );
|
---|
1626 | if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
|
---|
1627 | {
|
---|
1628 | HBRUSH hBrush = windowClass->getBackgroundBrush();
|
---|
1629 |
|
---|
1630 | if (hBrush <= (HBRUSH)(SYSCOLOR_GetLastColor()+1)) hBrush = GetSysColorBrush(hBrush-1);
|
---|
1631 |
|
---|
1632 | FillRect( (HDC)wParam, &rect, hBrush);
|
---|
1633 | }
|
---|
1634 |
|
---|
1635 | return 1;
|
---|
1636 | }
|
---|
1637 |
|
---|
1638 | case WM_PRINT:
|
---|
1639 | return DefWndPrint(wParam,lParam);
|
---|
1640 |
|
---|
1641 | case WM_PAINTICON:
|
---|
1642 | case WM_PAINT:
|
---|
1643 | {
|
---|
1644 | PAINTSTRUCT ps;
|
---|
1645 | HDC hdc = BeginPaint(getWindowHandle(), &ps );
|
---|
1646 | if( hdc )
|
---|
1647 | {
|
---|
1648 | if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
|
---|
1649 | {
|
---|
1650 | int x = (getWindowRect()->right - getWindowRect()->left - GetSystemMetrics(SM_CXICON))/2;
|
---|
1651 | int y = (getWindowRect()->bottom - getWindowRect()->top - GetSystemMetrics(SM_CYICON))/2;
|
---|
1652 | dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
|
---|
1653 | DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
|
---|
1654 | }
|
---|
1655 | EndPaint(getWindowHandle(), &ps );
|
---|
1656 | }
|
---|
1657 | return 0;
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 | case WM_GETDLGCODE:
|
---|
1661 | return 0;
|
---|
1662 |
|
---|
1663 | case WM_NCPAINT:
|
---|
1664 | if(!fOS2Look) {
|
---|
1665 | HandleNCPaint(wParam, FALSE);
|
---|
1666 | }
|
---|
1667 | return 0;
|
---|
1668 |
|
---|
1669 | case WM_NCACTIVATE:
|
---|
1670 | if(!fOS2Look) {
|
---|
1671 | return HandleNCActivate(wParam);
|
---|
1672 | }
|
---|
1673 | return TRUE;
|
---|
1674 |
|
---|
1675 | case WM_NCCREATE:
|
---|
1676 | return(TRUE);
|
---|
1677 |
|
---|
1678 | case WM_NCDESTROY:
|
---|
1679 | return 0;
|
---|
1680 |
|
---|
1681 | case WM_NCCALCSIZE:
|
---|
1682 | return NCHandleCalcSize(wParam, (NCCALCSIZE_PARAMS *)lParam);
|
---|
1683 |
|
---|
1684 | case WM_NCLBUTTONDOWN:
|
---|
1685 | if(!fOS2Look) {
|
---|
1686 | return HandleNCLButtonDown(wParam,lParam);
|
---|
1687 | }
|
---|
1688 | return 0;
|
---|
1689 |
|
---|
1690 | case WM_NCLBUTTONUP:
|
---|
1691 | if(!fOS2Look) {
|
---|
1692 | return HandleNCLButtonUp(wParam,lParam);
|
---|
1693 | }
|
---|
1694 | return 0;
|
---|
1695 |
|
---|
1696 | case WM_NCLBUTTONDBLCLK:
|
---|
1697 | if(!fOS2Look) {
|
---|
1698 | return HandleNCLButtonDblClk(wParam,lParam);
|
---|
1699 | }
|
---|
1700 | return 0;
|
---|
1701 |
|
---|
1702 | case WM_NCRBUTTONDOWN:
|
---|
1703 | case WM_NCRBUTTONDBLCLK:
|
---|
1704 | case WM_NCMBUTTONDOWN:
|
---|
1705 | case WM_NCMBUTTONDBLCLK:
|
---|
1706 | if (lastHitTestVal == HTERROR) MessageBeep(MB_ICONEXCLAMATION);
|
---|
1707 | return 0;
|
---|
1708 |
|
---|
1709 | case WM_NCRBUTTONUP:
|
---|
1710 | case WM_NCMBUTTONUP:
|
---|
1711 | return 0;
|
---|
1712 |
|
---|
1713 | case WM_NCHITTEST:
|
---|
1714 | {
|
---|
1715 | POINT point;
|
---|
1716 |
|
---|
1717 | point.x = (SHORT)LOWORD(lParam);
|
---|
1718 | point.y = (SHORT)HIWORD(lParam);
|
---|
1719 |
|
---|
1720 | if(fOS2Look) {
|
---|
1721 | return FrameHitTest(this, point.x, point.y);
|
---|
1722 | }
|
---|
1723 | else return HandleNCHitTest(point);
|
---|
1724 | }
|
---|
1725 |
|
---|
1726 | case WM_SYSCOMMAND:
|
---|
1727 | {
|
---|
1728 | POINT point;
|
---|
1729 |
|
---|
1730 | point.x = LOWORD(lParam);
|
---|
1731 | point.y = HIWORD(lParam);
|
---|
1732 | return HandleSysCommand(wParam, &point);
|
---|
1733 | }
|
---|
1734 |
|
---|
1735 | case WM_SYSKEYDOWN:
|
---|
1736 | if(wParam == VK_F4) /* try to close the window */
|
---|
1737 | {
|
---|
1738 | Win32BaseWindow *window = GetTopParent();
|
---|
1739 | if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
|
---|
1740 | PostMessageA(getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
|
---|
1741 | }
|
---|
1742 |
|
---|
1743 | Win32BaseWindow *siblingWindow;
|
---|
1744 | HWND sibling;
|
---|
1745 | char nameBuffer [40], mnemonic;
|
---|
1746 | int nameLength;
|
---|
1747 |
|
---|
1748 | GetWindowTextA (nameBuffer, 40);
|
---|
1749 |
|
---|
1750 | // search all sibling to see it this key is their mnemonic
|
---|
1751 | sibling = GetWindow (GW_HWNDFIRST);
|
---|
1752 | while (sibling != 0) {
|
---|
1753 | siblingWindow = GetWindowFromHandle (sibling);
|
---|
1754 | nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40);
|
---|
1755 |
|
---|
1756 | // find the siblings mnemonic
|
---|
1757 | mnemonic = '\0';
|
---|
1758 | for (int i=0 ; i<nameLength ; i++) {
|
---|
1759 | if (nameBuffer [i] == '&') {
|
---|
1760 | mnemonic = nameBuffer [i+1];
|
---|
1761 | if ((mnemonic >= 'a') && (mnemonic <= 'z'))
|
---|
1762 | mnemonic -= 32; // make it uppercase
|
---|
1763 | break; // stop searching
|
---|
1764 | }
|
---|
1765 | }
|
---|
1766 |
|
---|
1767 | // key matches siblings mnemonic, send mouseclick
|
---|
1768 | if (mnemonic == (char) wParam) {
|
---|
1769 | siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0);
|
---|
1770 | }
|
---|
1771 |
|
---|
1772 | sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT);
|
---|
1773 | }
|
---|
1774 |
|
---|
1775 | return 0;
|
---|
1776 |
|
---|
1777 | case WM_SHOWWINDOW:
|
---|
1778 | if (!lParam) return 0; /* sent from ShowWindow */
|
---|
1779 | if (!(dwStyle & WS_POPUP) || !owner) return 0;
|
---|
1780 | if ((dwStyle & WS_VISIBLE) && wParam) return 0;
|
---|
1781 | else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
|
---|
1782 | ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
|
---|
1783 | return 0;
|
---|
1784 |
|
---|
1785 | case WM_CANCELMODE:
|
---|
1786 | //if (getParent() == windowDesktop) EndMenu();
|
---|
1787 | if (GetCapture() == Win32Hwnd) ReleaseCapture();
|
---|
1788 | return 0;
|
---|
1789 |
|
---|
1790 | case WM_DROPOBJECT:
|
---|
1791 | return DRAG_FILE;
|
---|
1792 |
|
---|
1793 | case WM_QUERYDROPOBJECT:
|
---|
1794 | if (dwExStyle & WS_EX_ACCEPTFILES) return 1;
|
---|
1795 | return 0;
|
---|
1796 |
|
---|
1797 | case WM_QUERYDRAGICON:
|
---|
1798 | {
|
---|
1799 | HICON hIcon = windowClass->getCursor();
|
---|
1800 | UINT len;
|
---|
1801 |
|
---|
1802 | if(hIcon) return (LRESULT)hIcon;
|
---|
1803 | for(len = 1; len < 64; len++)
|
---|
1804 | {
|
---|
1805 | hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
|
---|
1806 | if(hIcon)
|
---|
1807 | return (LRESULT)hIcon;
|
---|
1808 | }
|
---|
1809 | return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
|
---|
1810 | }
|
---|
1811 |
|
---|
1812 | case WM_QUERYOPEN:
|
---|
1813 | case WM_QUERYENDSESSION:
|
---|
1814 | return 1;
|
---|
1815 |
|
---|
1816 | case WM_NOTIFYFORMAT:
|
---|
1817 | if (IsWindowUnicode()) return NFR_UNICODE;
|
---|
1818 | else return NFR_ANSI;
|
---|
1819 |
|
---|
1820 | case WM_SETICON:
|
---|
1821 | case WM_GETICON:
|
---|
1822 | {
|
---|
1823 | LRESULT result = 0;
|
---|
1824 | if (!windowClass) return result;
|
---|
1825 | int index = GCL_HICON;
|
---|
1826 |
|
---|
1827 | if (wParam == ICON_SMALL)
|
---|
1828 | index = GCL_HICONSM;
|
---|
1829 |
|
---|
1830 | result = windowClass->getClassLongA(index);
|
---|
1831 |
|
---|
1832 | if (Msg == WM_SETICON)
|
---|
1833 | windowClass->setClassLongA(index, lParam);
|
---|
1834 |
|
---|
1835 | return result;
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 | case WM_NOTIFY:
|
---|
1839 | return 0; //comctl32 controls expect this
|
---|
1840 |
|
---|
1841 | default:
|
---|
1842 | if(Msg > WM_USER) {
|
---|
1843 | return 0;
|
---|
1844 | }
|
---|
1845 | return 1; //CB: shouldn't this be 0?
|
---|
1846 | }
|
---|
1847 | }
|
---|
1848 | //******************************************************************************
|
---|
1849 | //******************************************************************************
|
---|
1850 | LRESULT Win32BaseWindow::DefWindowProcW(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
1851 | {
|
---|
1852 | fDefWndProcCalled = TRUE;
|
---|
1853 |
|
---|
1854 | switch(Msg)
|
---|
1855 | {
|
---|
1856 | case WM_GETTEXTLENGTH:
|
---|
1857 | return wndNameLength;
|
---|
1858 |
|
---|
1859 | case WM_GETTEXT:
|
---|
1860 | if (!lParam || !wParam) return 0;
|
---|
1861 | if (!windowNameW) ((LPWSTR)lParam)[0] = 0;
|
---|
1862 | else lstrcpynW((LPWSTR)lParam,windowNameW,wParam);
|
---|
1863 | return min(wndNameLength,wParam);
|
---|
1864 |
|
---|
1865 | case WM_SETTEXT:
|
---|
1866 | {
|
---|
1867 | LPWSTR lpsz = (LPWSTR)lParam;
|
---|
1868 |
|
---|
1869 | if(windowNameA) free(windowNameA);
|
---|
1870 | if(windowNameW) free(windowNameW);
|
---|
1871 |
|
---|
1872 | if (lParam)
|
---|
1873 | {
|
---|
1874 | wndNameLength = lstrlenW(lpsz);
|
---|
1875 | windowNameA = (LPSTR)_smalloc(wndNameLength+1);
|
---|
1876 | lstrcpyWtoA(windowNameA,lpsz);
|
---|
1877 | windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR));
|
---|
1878 | lstrcpyW(windowNameW,lpsz);
|
---|
1879 | }
|
---|
1880 | else
|
---|
1881 | {
|
---|
1882 | windowNameA = NULL;
|
---|
1883 | windowNameW = NULL;
|
---|
1884 | wndNameLength = 0;
|
---|
1885 | }
|
---|
1886 |
|
---|
1887 | if(OS2HwndFrame && (dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
1888 | return OSLibWinSetWindowText(OS2HwndFrame,(LPSTR)windowNameA);
|
---|
1889 |
|
---|
1890 | return TRUE;
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 | default:
|
---|
1894 | return DefWindowProcA(Msg, wParam, lParam);
|
---|
1895 | }
|
---|
1896 | }
|
---|
1897 | //******************************************************************************
|
---|
1898 | //******************************************************************************
|
---|
1899 | LRESULT Win32BaseWindow::SendMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
---|
1900 | {
|
---|
1901 | //if the destination window is created by this process & thread, call window proc directly
|
---|
1902 | if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
|
---|
1903 | return SendInternalMessageA(Msg, wParam, lParam);
|
---|
1904 | }
|
---|
1905 | //otherwise use WinSendMsg to send it to the right process/thread
|
---|
1906 | return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, FALSE);
|
---|
1907 | }
|
---|
1908 | //******************************************************************************
|
---|
1909 | //******************************************************************************
|
---|
1910 | LRESULT Win32BaseWindow::SendMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
---|
1911 | {
|
---|
1912 | //if the destination window is created by this process & thread, call window proc directly
|
---|
1913 | if(dwProcessId == currentProcessId && dwThreadId == GetCurrentThreadId()) {
|
---|
1914 | return SendInternalMessageW(Msg, wParam, lParam);
|
---|
1915 | }
|
---|
1916 | //otherwise use WinSendMsg to send it to the right process/thread
|
---|
1917 | return OSLibSendMessage(getOS2WindowHandle(), Msg, wParam, lParam, TRUE);
|
---|
1918 | }
|
---|
1919 | //******************************************************************************
|
---|
1920 | //Called as a result of an OS/2 message or called from a class method
|
---|
1921 | //******************************************************************************
|
---|
1922 | LRESULT Win32BaseWindow::SendInternalMessageA(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
---|
1923 | {
|
---|
1924 | LRESULT rc;
|
---|
1925 | BOOL fInternalMsgBackup = fInternalMsg;
|
---|
1926 |
|
---|
1927 | DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, FALSE, TRUE);
|
---|
1928 |
|
---|
1929 | CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, FALSE);
|
---|
1930 |
|
---|
1931 | fInternalMsg = TRUE;
|
---|
1932 | switch(Msg)
|
---|
1933 | {
|
---|
1934 | case WM_CREATE:
|
---|
1935 | {
|
---|
1936 | if(CallWindowProcA(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
---|
1937 | dprintf(("WM_CREATE returned -1\n"));
|
---|
1938 | rc = -1; //don't create window
|
---|
1939 | break;
|
---|
1940 | }
|
---|
1941 | rc = 0;
|
---|
1942 | break;
|
---|
1943 | }
|
---|
1944 | case WM_LBUTTONDOWN:
|
---|
1945 | case WM_MBUTTONDOWN:
|
---|
1946 | case WM_RBUTTONDOWN:
|
---|
1947 | {
|
---|
1948 | if (getParent())
|
---|
1949 | {
|
---|
1950 | POINTS pt = MAKEPOINTS(lParam);
|
---|
1951 | POINT point;
|
---|
1952 |
|
---|
1953 | point.x = pt.x;
|
---|
1954 | point.y = pt.y;
|
---|
1955 | MapWindowPoints(Win32Hwnd,getParent()->getWindowHandle(),&point,1);
|
---|
1956 | NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
|
---|
1957 | }
|
---|
1958 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
---|
1959 | break;
|
---|
1960 | }
|
---|
1961 |
|
---|
1962 | case WM_DESTROY:
|
---|
1963 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
---|
1964 | break;
|
---|
1965 |
|
---|
1966 | default:
|
---|
1967 | rc = CallWindowProcA(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
|
---|
1968 | break;
|
---|
1969 | }
|
---|
1970 | fInternalMsg = fInternalMsgBackup;
|
---|
1971 | return rc;
|
---|
1972 | }
|
---|
1973 | //******************************************************************************
|
---|
1974 | //Called as a result of an OS/2 message or called from a class method
|
---|
1975 | //******************************************************************************
|
---|
1976 | LRESULT Win32BaseWindow::SendInternalMessageW(ULONG Msg, WPARAM wParam, LPARAM lParam)
|
---|
1977 | {
|
---|
1978 | LRESULT rc;
|
---|
1979 | BOOL fInternalMsgBackup = fInternalMsg;
|
---|
1980 |
|
---|
1981 | DebugPrintMessage(getWindowHandle(), Msg, wParam, lParam, TRUE, TRUE);
|
---|
1982 |
|
---|
1983 | CallWindowHookProc(WH_CALLWNDPROC, Msg, wParam, lParam, TRUE);
|
---|
1984 |
|
---|
1985 | fInternalMsg = TRUE;
|
---|
1986 | switch(Msg)
|
---|
1987 | {
|
---|
1988 | case WM_CREATE:
|
---|
1989 | {
|
---|
1990 | if(CallWindowProcW(win32wndproc, getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
|
---|
1991 | dprintf(("WM_CREATE returned -1\n"));
|
---|
1992 | rc = -1; //don't create window
|
---|
1993 | break;
|
---|
1994 | }
|
---|
1995 | rc = 0;
|
---|
1996 | break;
|
---|
1997 | }
|
---|
1998 | case WM_LBUTTONDOWN:
|
---|
1999 | case WM_MBUTTONDOWN:
|
---|
2000 | case WM_RBUTTONDOWN:
|
---|
2001 | NotifyParent(Msg, wParam, lParam);
|
---|
2002 | rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
|
---|
2003 | break;
|
---|
2004 |
|
---|
2005 | case WM_DESTROY:
|
---|
2006 | rc = win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
|
---|
2007 | break;
|
---|
2008 | default:
|
---|
2009 | rc = CallWindowProcW(win32wndproc, getWindowHandle(), Msg, wParam, lParam);
|
---|
2010 | break;
|
---|
2011 | }
|
---|
2012 | fInternalMsg = fInternalMsgBackup;
|
---|
2013 | return rc;
|
---|
2014 | }
|
---|
2015 | //******************************************************************************
|
---|
2016 | //******************************************************************************
|
---|
2017 | void Win32BaseWindow::CallWindowHookProc(ULONG hooktype, ULONG Msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
|
---|
2018 | {
|
---|
2019 | CWPSTRUCT cwp;
|
---|
2020 |
|
---|
2021 | cwp.lParam = lParam;
|
---|
2022 | cwp.wParam = wParam;
|
---|
2023 | cwp.message = Msg;
|
---|
2024 | cwp.hwnd = getWindowHandle();
|
---|
2025 |
|
---|
2026 | switch(hooktype) {
|
---|
2027 | case WH_CALLWNDPROC:
|
---|
2028 | if(fUnicode) {
|
---|
2029 | HOOK_CallHooksW(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
|
---|
2030 | }
|
---|
2031 | else HOOK_CallHooksA(WH_CALLWNDPROC, HC_ACTION, 1, (LPARAM)&cwp);
|
---|
2032 | break;
|
---|
2033 | }
|
---|
2034 | }
|
---|
2035 | //******************************************************************************
|
---|
2036 | //******************************************************************************
|
---|
2037 | //******************************************************************************
|
---|
2038 | //TODO: Do this more efficiently
|
---|
2039 | //******************************************************************************
|
---|
2040 | LRESULT Win32BaseWindow::BroadcastMessageA(int type, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
2041 | {
|
---|
2042 | Win32BaseWindow *window;
|
---|
2043 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
|
---|
2044 |
|
---|
2045 | dprintf(("BroadCastMessageA %x %x %x", msg, wParam, lParam, GetFS()));
|
---|
2046 |
|
---|
2047 | for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
|
---|
2048 | window = GetWindowFromHandle(hwnd++);
|
---|
2049 | if(window) {
|
---|
2050 | if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
|
---|
2051 | {
|
---|
2052 |
|
---|
2053 | if(type == BROADCAST_SEND) {
|
---|
2054 | window->SendInternalMessageA(msg, wParam, lParam);
|
---|
2055 | }
|
---|
2056 | else PostMessageA(window->getWindowHandle(), msg, wParam, lParam);
|
---|
2057 | }
|
---|
2058 | }
|
---|
2059 | }
|
---|
2060 | return 0;
|
---|
2061 | }
|
---|
2062 | //******************************************************************************
|
---|
2063 | //TODO: Do this more efficiently
|
---|
2064 | //******************************************************************************
|
---|
2065 | LRESULT Win32BaseWindow::BroadcastMessageW(int type, UINT msg, WPARAM wParam, LPARAM lParam)
|
---|
2066 | {
|
---|
2067 | Win32BaseWindow *window;
|
---|
2068 | HWND hwnd = WNDHANDLE_MAGIC_HIGHWORD;
|
---|
2069 |
|
---|
2070 | dprintf(("BroadCastMessageW %x %x %x", msg, wParam, lParam));
|
---|
2071 |
|
---|
2072 | for(int i=0;i<MAX_WINDOW_HANDLES;i++) {
|
---|
2073 | window = GetWindowFromHandle(hwnd++);
|
---|
2074 | if(window) {
|
---|
2075 | if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
|
---|
2076 | {
|
---|
2077 |
|
---|
2078 | if(type == BROADCAST_SEND) {
|
---|
2079 | window->SendInternalMessageW(msg, wParam, lParam);
|
---|
2080 | }
|
---|
2081 | else PostMessageW(window->getWindowHandle(), msg, wParam, lParam);
|
---|
2082 | }
|
---|
2083 | }
|
---|
2084 | }
|
---|
2085 | return 0;
|
---|
2086 | }
|
---|
2087 | //******************************************************************************
|
---|
2088 | //******************************************************************************
|
---|
2089 | void Win32BaseWindow::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam)
|
---|
2090 | {
|
---|
2091 | Win32BaseWindow *window = this;
|
---|
2092 | Win32BaseWindow *parentwindow;
|
---|
2093 |
|
---|
2094 | while(window)
|
---|
2095 | {
|
---|
2096 | if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
|
---|
2097 | {
|
---|
2098 | /* Notify the parent window only */
|
---|
2099 | parentwindow = window->getParent();
|
---|
2100 | if(parentwindow) {
|
---|
2101 | parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, getWindowId()), lParam );
|
---|
2102 | }
|
---|
2103 | }
|
---|
2104 | else break;
|
---|
2105 |
|
---|
2106 | window = parentwindow;
|
---|
2107 | }
|
---|
2108 | }
|
---|
2109 | //******************************************************************************
|
---|
2110 | //******************************************************************************
|
---|
2111 | BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
|
---|
2112 | {
|
---|
2113 |
|
---|
2114 | dprintf(("SetMenu %x", hMenu));
|
---|
2115 | OS2HwndMenu = OSLibWinSetMenu(OS2HwndFrame, hMenu);
|
---|
2116 | if(OS2HwndMenu == 0) {
|
---|
2117 | dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
|
---|
2118 | return FALSE;
|
---|
2119 | }
|
---|
2120 | return TRUE;
|
---|
2121 | }
|
---|
2122 | //******************************************************************************
|
---|
2123 | //******************************************************************************
|
---|
2124 | BOOL Win32BaseWindow::SetIcon(HICON hIcon)
|
---|
2125 | {
|
---|
2126 | dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
|
---|
2127 | if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
|
---|
2128 | //TODO: Wine does't send these. Correct?
|
---|
2129 | // SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
|
---|
2130 | return TRUE;
|
---|
2131 | }
|
---|
2132 | return FALSE;
|
---|
2133 | }
|
---|
2134 | //******************************************************************************
|
---|
2135 | //******************************************************************************
|
---|
2136 | BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
|
---|
2137 | {
|
---|
2138 | ULONG showstate = 0;
|
---|
2139 | HWND hWinAfter;
|
---|
2140 |
|
---|
2141 | dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
|
---|
2142 | #if 1
|
---|
2143 | if (flags & WIN_NEED_SIZE)
|
---|
2144 | {
|
---|
2145 | /* should happen only in CreateWindowEx() */
|
---|
2146 | int wParam = SIZE_RESTORED;
|
---|
2147 |
|
---|
2148 | flags &= ~WIN_NEED_SIZE;
|
---|
2149 | if (dwStyle & WS_MAXIMIZE)
|
---|
2150 | wParam = SIZE_MAXIMIZED;
|
---|
2151 | else
|
---|
2152 | if (dwStyle & WS_MINIMIZE)
|
---|
2153 | wParam = SIZE_MINIMIZED;
|
---|
2154 |
|
---|
2155 | SendInternalMessageA(WM_SIZE, wParam,
|
---|
2156 | MAKELONG(rectClient.right-rectClient.left,
|
---|
2157 | rectClient.bottom-rectClient.top));
|
---|
2158 | SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
|
---|
2159 | }
|
---|
2160 | #else
|
---|
2161 | if(fFirstShow) {
|
---|
2162 | if(isFrameWindow() && IS_OVERLAPPED(getStyle()) && !isChild()) {
|
---|
2163 | SendInternalMessageA(WM_SIZE, SIZE_RESTORED,
|
---|
2164 | MAKELONG(rectClient.right-rectClient.left,
|
---|
2165 | rectClient.bottom-rectClient.top));
|
---|
2166 | SendInternalMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
|
---|
2167 |
|
---|
2168 | }
|
---|
2169 | fFirstShow = FALSE;
|
---|
2170 | }
|
---|
2171 | #endif
|
---|
2172 | switch(nCmdShow)
|
---|
2173 | {
|
---|
2174 | case SW_SHOW:
|
---|
2175 | case SW_SHOWDEFAULT: //todo
|
---|
2176 | showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
|
---|
2177 | break;
|
---|
2178 | case SW_HIDE:
|
---|
2179 | showstate = SWPOS_HIDE;
|
---|
2180 | break;
|
---|
2181 | case SW_RESTORE:
|
---|
2182 | showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
---|
2183 | break;
|
---|
2184 | case SW_MINIMIZE:
|
---|
2185 | showstate = SWPOS_MINIMIZE;
|
---|
2186 | break;
|
---|
2187 | case SW_SHOWMAXIMIZED:
|
---|
2188 | showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
---|
2189 | break;
|
---|
2190 | case SW_SHOWMINIMIZED:
|
---|
2191 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
|
---|
2192 | break;
|
---|
2193 | case SW_SHOWMINNOACTIVE:
|
---|
2194 | showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
|
---|
2195 | break;
|
---|
2196 | case SW_SHOWNA:
|
---|
2197 | showstate = SWPOS_SHOW;
|
---|
2198 | break;
|
---|
2199 | case SW_SHOWNOACTIVATE:
|
---|
2200 | showstate = SWPOS_SHOW;
|
---|
2201 | break;
|
---|
2202 | case SW_SHOWNORMAL:
|
---|
2203 | showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
|
---|
2204 | break;
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | /* We can't activate a child window (WINE) */
|
---|
2208 | if(getStyle() & WS_CHILD)
|
---|
2209 | showstate &= ~SWPOS_ACTIVATE;
|
---|
2210 |
|
---|
2211 | if(showstate & SWPOS_SHOW) {
|
---|
2212 | setStyle(getStyle() | WS_VISIBLE);
|
---|
2213 | }
|
---|
2214 | else setStyle(getStyle() & ~WS_VISIBLE);
|
---|
2215 |
|
---|
2216 | BOOL rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
|
---|
2217 |
|
---|
2218 | return rc;
|
---|
2219 | }
|
---|
2220 | //******************************************************************************
|
---|
2221 | //When our parent window is moved, we aren't notified of the change (rectWindow is in
|
---|
2222 | //screen coordinates, so it needs to be updated)
|
---|
2223 | //Set the fWindowRectChanged flag and do the same for all the children
|
---|
2224 | //Whenever getWindowRect is called and this flag is set, it refreshes the rectWindow structure
|
---|
2225 | //******************************************************************************
|
---|
2226 | void Win32BaseWindow::setWindowRectChanged()
|
---|
2227 | {
|
---|
2228 | Win32BaseWindow *child;
|
---|
2229 |
|
---|
2230 | fWindowRectChanged = TRUE;
|
---|
2231 |
|
---|
2232 | child = (Win32BaseWindow *)getFirstChild();
|
---|
2233 | while(child)
|
---|
2234 | {
|
---|
2235 | child->setWindowRectChanged();
|
---|
2236 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
2237 | }
|
---|
2238 | }
|
---|
2239 | //******************************************************************************
|
---|
2240 | //******************************************************************************
|
---|
2241 | PRECT Win32BaseWindow::getWindowRect()
|
---|
2242 | {
|
---|
2243 | if(fWindowRectChanged) {
|
---|
2244 | OSLibWinQueryWindowRect(getOS2FrameWindowHandle(), &rectWindow, RELATIVE_TO_SCREEN);
|
---|
2245 | fWindowRectChanged = FALSE;
|
---|
2246 | }
|
---|
2247 | return &rectWindow;
|
---|
2248 | }
|
---|
2249 | //******************************************************************************
|
---|
2250 | //******************************************************************************
|
---|
2251 | void Win32BaseWindow::setWindowRect(LONG left, LONG top, LONG right, LONG bottom)
|
---|
2252 | {
|
---|
2253 | fWindowRectChanged = FALSE;
|
---|
2254 |
|
---|
2255 | rectWindow.left = left;
|
---|
2256 | rectWindow.top = top;
|
---|
2257 | rectWindow.right = right;
|
---|
2258 | rectWindow.bottom = bottom;
|
---|
2259 | }
|
---|
2260 | //******************************************************************************
|
---|
2261 | //******************************************************************************
|
---|
2262 | void Win32BaseWindow::setWindowRect(PRECT rect)
|
---|
2263 | {
|
---|
2264 | fWindowRectChanged = FALSE;
|
---|
2265 |
|
---|
2266 | rectWindow = *rect;
|
---|
2267 | }
|
---|
2268 | //******************************************************************************
|
---|
2269 | //******************************************************************************
|
---|
2270 | BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags)
|
---|
2271 | {
|
---|
2272 | BOOL rc = FALSE;
|
---|
2273 | Win32BaseWindow *window;
|
---|
2274 | HWND hParent = 0;
|
---|
2275 |
|
---|
2276 | dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
|
---|
2277 |
|
---|
2278 | if (fuFlags &
|
---|
2279 | ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
|
---|
2280 | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_FRAMECHANGED |
|
---|
2281 | SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS |
|
---|
2282 | SWP_NOOWNERZORDER))
|
---|
2283 | {
|
---|
2284 | return FALSE;
|
---|
2285 | }
|
---|
2286 |
|
---|
2287 | WINDOWPOS wpos;
|
---|
2288 | SWP swp, swpOld;
|
---|
2289 |
|
---|
2290 | wpos.flags = fuFlags;
|
---|
2291 | wpos.cy = cy;
|
---|
2292 | wpos.cx = cx;
|
---|
2293 | wpos.x = x;
|
---|
2294 | wpos.y = y;
|
---|
2295 | wpos.hwndInsertAfter = hwndInsertAfter;
|
---|
2296 | wpos.hwnd = getWindowHandle();
|
---|
2297 |
|
---|
2298 | if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
|
---|
2299 | {
|
---|
2300 | if (isChild())
|
---|
2301 | {
|
---|
2302 | Win32BaseWindow *windowParent = getParent();
|
---|
2303 | if(windowParent) {
|
---|
2304 | hParent = getParent()->getOS2WindowHandle();
|
---|
2305 | }
|
---|
2306 | else dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
|
---|
2307 | }
|
---|
2308 | OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
|
---|
2309 | }
|
---|
2310 |
|
---|
2311 | OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
|
---|
2312 | if (swp.fl == 0)
|
---|
2313 | return TRUE;
|
---|
2314 |
|
---|
2315 | // if ((swp.fl & SWPOS_ZORDER) && (swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
---|
2316 | if ((swp.hwndInsertBehind > HWNDOS_BOTTOM))
|
---|
2317 | {
|
---|
2318 | Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
|
---|
2319 | if(wndBehind) {
|
---|
2320 | swp.hwndInsertBehind = wndBehind->getOS2FrameWindowHandle();
|
---|
2321 | }
|
---|
2322 | else {
|
---|
2323 | dprintf(("ERROR: SetWindowPos: hwndInsertBehind %x invalid!",swp.hwndInsertBehind));
|
---|
2324 | swp.hwndInsertBehind = 0;
|
---|
2325 | }
|
---|
2326 | }
|
---|
2327 | #if 0
|
---|
2328 | if (isFrameWindow())
|
---|
2329 | {
|
---|
2330 | if (!isChild())
|
---|
2331 | {
|
---|
2332 | POINT maxSize, maxPos, minTrack, maxTrack;
|
---|
2333 |
|
---|
2334 | GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
|
---|
2335 |
|
---|
2336 | if (swp.cx > maxTrack.x) swp.cx = maxTrack.x;
|
---|
2337 | if (swp.cy > maxTrack.y) swp.cy = maxTrack.y;
|
---|
2338 | if (swp.cx < minTrack.x) swp.cx = minTrack.x;
|
---|
2339 | if (swp.cy < minTrack.y) swp.cy = minTrack.y;
|
---|
2340 | }
|
---|
2341 | swp.hwnd = OS2HwndFrame;
|
---|
2342 | }
|
---|
2343 | else
|
---|
2344 | #endif
|
---|
2345 | swp.hwnd = OS2HwndFrame;
|
---|
2346 |
|
---|
2347 | dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
|
---|
2348 |
|
---|
2349 | rc = OSLibWinSetMultWindowPos(&swp, 1);
|
---|
2350 |
|
---|
2351 | if (rc == FALSE)
|
---|
2352 | {
|
---|
2353 | dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
|
---|
2354 | }
|
---|
2355 |
|
---|
2356 | //SWP_FRAMECHANGED is ignored, not necessary for OS/2
|
---|
2357 |
|
---|
2358 | return (rc);
|
---|
2359 | }
|
---|
2360 | //******************************************************************************
|
---|
2361 | //TODO: WPF_RESTOREMAXIMIZED
|
---|
2362 | //******************************************************************************
|
---|
2363 | BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
|
---|
2364 | {
|
---|
2365 | if(isFrameWindow())
|
---|
2366 | {
|
---|
2367 | // Set the minimized position
|
---|
2368 | if (winpos->flags & WPF_SETMINPOSITION)
|
---|
2369 | {
|
---|
2370 | OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
|
---|
2371 | }
|
---|
2372 |
|
---|
2373 | //TODO: Max position
|
---|
2374 |
|
---|
2375 | // Set the new restore position.
|
---|
2376 | OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
|
---|
2377 | }
|
---|
2378 |
|
---|
2379 | return ShowWindow(winpos->showCmd);
|
---|
2380 | }
|
---|
2381 | //******************************************************************************
|
---|
2382 | //Also destroys all the child windows (destroy children first, parent last)
|
---|
2383 | //******************************************************************************
|
---|
2384 | BOOL Win32BaseWindow::DestroyWindow()
|
---|
2385 | {
|
---|
2386 | /* Call hooks */
|
---|
2387 | if(HOOK_CallHooksA( WH_CBT, HCBT_DESTROYWND, getWindowHandle(), 0L))
|
---|
2388 | {
|
---|
2389 | return FALSE;
|
---|
2390 | }
|
---|
2391 |
|
---|
2392 | if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
|
---|
2393 | {
|
---|
2394 | HOOK_CallHooksA(WH_SHELL, HSHELL_WINDOWDESTROYED, getWindowHandle(), 0L);
|
---|
2395 | /* FIXME: clean up palette - see "Internals" p.352 */
|
---|
2396 | }
|
---|
2397 |
|
---|
2398 | if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_NOPARENTNOTIFY))
|
---|
2399 | {
|
---|
2400 | if(getParent())
|
---|
2401 | {
|
---|
2402 | /* Notify the parent window only */
|
---|
2403 | getParent()->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_DESTROY, getWindowId()), (LPARAM)getWindowHandle());
|
---|
2404 | if( !::IsWindow(getWindowHandle()) )
|
---|
2405 | {
|
---|
2406 | return TRUE;
|
---|
2407 | }
|
---|
2408 | }
|
---|
2409 | else DebugInt3();
|
---|
2410 | }
|
---|
2411 | fDestroyWindowCalled = TRUE;
|
---|
2412 | return OSLibWinDestroyWindow(OS2HwndFrame);
|
---|
2413 | }
|
---|
2414 | //******************************************************************************
|
---|
2415 | //******************************************************************************
|
---|
2416 | Win32BaseWindow *Win32BaseWindow::getParent()
|
---|
2417 | {
|
---|
2418 | Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::GetParent();
|
---|
2419 | return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
|
---|
2420 | }
|
---|
2421 | //******************************************************************************
|
---|
2422 | //******************************************************************************
|
---|
2423 | HWND Win32BaseWindow::GetParent()
|
---|
2424 | {
|
---|
2425 | Win32BaseWindow *wndparent;
|
---|
2426 |
|
---|
2427 | if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
|
---|
2428 | {
|
---|
2429 | return 0;
|
---|
2430 | }
|
---|
2431 | wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
|
---|
2432 |
|
---|
2433 | return (wndparent) ? wndparent->getWindowHandle() : 0;
|
---|
2434 | }
|
---|
2435 | //******************************************************************************
|
---|
2436 | //******************************************************************************
|
---|
2437 | HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
|
---|
2438 | {
|
---|
2439 | HWND oldhwnd;
|
---|
2440 | Win32BaseWindow *newparent;
|
---|
2441 |
|
---|
2442 | if(getParent()) {
|
---|
2443 | oldhwnd = getParent()->getWindowHandle();
|
---|
2444 | getParent()->RemoveChild(this);
|
---|
2445 | }
|
---|
2446 | else oldhwnd = 0;
|
---|
2447 |
|
---|
2448 | newparent = GetWindowFromHandle(hwndNewParent);
|
---|
2449 | if(newparent)
|
---|
2450 | {
|
---|
2451 | setParent(newparent);
|
---|
2452 | getParent()->AddChild(this);
|
---|
2453 | OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
|
---|
2454 | return oldhwnd;
|
---|
2455 | }
|
---|
2456 | else {
|
---|
2457 | setParent(windowDesktop);
|
---|
2458 | windowDesktop->AddChild(this);
|
---|
2459 | OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
|
---|
2460 | return oldhwnd;
|
---|
2461 | }
|
---|
2462 | }
|
---|
2463 | //******************************************************************************
|
---|
2464 | //******************************************************************************
|
---|
2465 | BOOL Win32BaseWindow::IsChild(HWND hwndParent)
|
---|
2466 | {
|
---|
2467 | if(getParent()) {
|
---|
2468 | return getParent()->getWindowHandle() == hwndParent;
|
---|
2469 | }
|
---|
2470 | else return 0;
|
---|
2471 | }
|
---|
2472 | //******************************************************************************
|
---|
2473 | //******************************************************************************
|
---|
2474 | HWND Win32BaseWindow::GetTopWindow()
|
---|
2475 | {
|
---|
2476 | return GetWindow(GW_CHILD);
|
---|
2477 | }
|
---|
2478 | //******************************************************************************
|
---|
2479 | // Get the top-level parent for a child window.
|
---|
2480 | //******************************************************************************
|
---|
2481 | Win32BaseWindow *Win32BaseWindow::GetTopParent()
|
---|
2482 | {
|
---|
2483 | Win32BaseWindow *window = this;
|
---|
2484 |
|
---|
2485 | while(window && (window->getStyle() & WS_CHILD))
|
---|
2486 | {
|
---|
2487 | window = window->getParent();
|
---|
2488 | }
|
---|
2489 | return window;
|
---|
2490 | }
|
---|
2491 | //******************************************************************************
|
---|
2492 | //Don't call WinUpdateWindow as that one also updates the child windows
|
---|
2493 | //Also need to send WM_PAINT directly to the window procedure, which doesn't
|
---|
2494 | //always happen with WinUpdateWindow (could be posted if thread doesn't own window)
|
---|
2495 | //******************************************************************************
|
---|
2496 | BOOL Win32BaseWindow::UpdateWindow()
|
---|
2497 | {
|
---|
2498 | RECT rect;
|
---|
2499 |
|
---|
2500 | if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
|
---|
2501 | {//update region not empty
|
---|
2502 | HDC hdc;
|
---|
2503 |
|
---|
2504 | hdc = O32_GetDC(OS2Hwnd);
|
---|
2505 | if (isIcon)
|
---|
2506 | {
|
---|
2507 | SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
|
---|
2508 | SendInternalMessageA(WM_PAINTICON, 0, 0);
|
---|
2509 | }
|
---|
2510 | else
|
---|
2511 | {
|
---|
2512 | SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
|
---|
2513 | SendInternalMessageA(WM_PAINT, 0, 0);
|
---|
2514 | }
|
---|
2515 | O32_ReleaseDC(OS2Hwnd, hdc);
|
---|
2516 | }
|
---|
2517 | return TRUE;
|
---|
2518 | }
|
---|
2519 | //******************************************************************************
|
---|
2520 | //******************************************************************************
|
---|
2521 | BOOL Win32BaseWindow::IsIconic()
|
---|
2522 | {
|
---|
2523 | return OSLibWinIsIconic(OS2Hwnd);
|
---|
2524 | }
|
---|
2525 | //******************************************************************************
|
---|
2526 | //TODO: Should not enumerate children that are created during the enumeration!
|
---|
2527 | //******************************************************************************
|
---|
2528 | BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
2529 | {
|
---|
2530 | BOOL rc = TRUE;
|
---|
2531 | HWND hwnd;
|
---|
2532 | Win32BaseWindow *prevchild = 0, *child = 0;
|
---|
2533 |
|
---|
2534 | dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
|
---|
2535 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
---|
2536 | {
|
---|
2537 | dprintf(("EnumChildWindows: enumerating child %x", child->getWindowHandle()));
|
---|
2538 | hwnd = child->getWindowHandle();
|
---|
2539 | if(child->getOwner()) {
|
---|
2540 | continue; //shouldn't have an owner (Wine)
|
---|
2541 | }
|
---|
2542 | if(lpfn(hwnd, lParam) == FALSE)
|
---|
2543 | {
|
---|
2544 | rc = FALSE;
|
---|
2545 | break;
|
---|
2546 | }
|
---|
2547 | //check if the window still exists
|
---|
2548 | if(!::IsWindow(hwnd))
|
---|
2549 | {
|
---|
2550 | child = prevchild;
|
---|
2551 | continue;
|
---|
2552 | }
|
---|
2553 | if(child->getFirstChild() != NULL)
|
---|
2554 | {
|
---|
2555 | dprintf(("EnumChildWindows: Enumerate children of %x", child->getWindowHandle()));
|
---|
2556 | if(child->EnumChildWindows(lpfn, lParam) == FALSE)
|
---|
2557 | {
|
---|
2558 | rc = FALSE;
|
---|
2559 | break;
|
---|
2560 | }
|
---|
2561 | }
|
---|
2562 | prevchild = child;
|
---|
2563 | }
|
---|
2564 | return rc;
|
---|
2565 | }
|
---|
2566 | //******************************************************************************
|
---|
2567 | //Enumerate first-level children only and check thread id
|
---|
2568 | //******************************************************************************
|
---|
2569 | BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
|
---|
2570 | {
|
---|
2571 | Win32BaseWindow *child = 0;
|
---|
2572 | ULONG tid, pid;
|
---|
2573 | BOOL rc;
|
---|
2574 | HWND hwnd;
|
---|
2575 |
|
---|
2576 | dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
|
---|
2577 |
|
---|
2578 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
---|
2579 | {
|
---|
2580 | OSLibWinQueryWindowProcess(child->getOS2WindowHandle(), &pid, &tid);
|
---|
2581 |
|
---|
2582 | if(dwThreadId == tid) {
|
---|
2583 | dprintf2(("EnumThreadWindows: Found Window %x", child->getWindowHandle()));
|
---|
2584 | if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
|
---|
2585 | break;
|
---|
2586 | }
|
---|
2587 | }
|
---|
2588 | }
|
---|
2589 | return TRUE;
|
---|
2590 | }
|
---|
2591 | //******************************************************************************
|
---|
2592 | //Enumerate first-level children only
|
---|
2593 | //******************************************************************************
|
---|
2594 | BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
|
---|
2595 | {
|
---|
2596 | Win32BaseWindow *child = 0;
|
---|
2597 | BOOL rc;
|
---|
2598 | HWND hwnd;
|
---|
2599 |
|
---|
2600 | dprintf(("EnumWindows %x %x", lpfn, lParam));
|
---|
2601 |
|
---|
2602 | for (child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
---|
2603 | {
|
---|
2604 | hwnd = child->getWindowHandle();
|
---|
2605 |
|
---|
2606 | dprintf2(("EnumWindows: Found Window %x", child->getWindowHandle()));
|
---|
2607 | if((rc = lpfn(child->getWindowHandle(), lParam)) == FALSE) {
|
---|
2608 | break;
|
---|
2609 | }
|
---|
2610 | }
|
---|
2611 | return TRUE;
|
---|
2612 | }
|
---|
2613 | //******************************************************************************
|
---|
2614 | //******************************************************************************
|
---|
2615 | Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
|
---|
2616 | {
|
---|
2617 | for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
|
---|
2618 | {
|
---|
2619 | if (child->getWindowId() == id)
|
---|
2620 | {
|
---|
2621 | return child;
|
---|
2622 | }
|
---|
2623 | }
|
---|
2624 | return 0;
|
---|
2625 | }
|
---|
2626 | //******************************************************************************
|
---|
2627 | //TODO:
|
---|
2628 | //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that
|
---|
2629 | //the current process owns them.
|
---|
2630 | //******************************************************************************
|
---|
2631 | HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
|
---|
2632 | BOOL fUnicode)
|
---|
2633 | {
|
---|
2634 | Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
|
---|
2635 | Win32BaseWindow *child = GetWindowFromHandle(hwndChildAfter);
|
---|
2636 |
|
---|
2637 | if((hwndParent != OSLIB_HWND_DESKTOP && !parent) ||
|
---|
2638 | (hwndChildAfter != 0 && !child) ||
|
---|
2639 | (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
|
---|
2640 | {
|
---|
2641 | dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
|
---|
2642 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
---|
2643 | return 0;
|
---|
2644 | }
|
---|
2645 | if(hwndParent != OSLIB_HWND_DESKTOP)
|
---|
2646 | {//if the current process owns the window, just do a quick search
|
---|
2647 | child = (Win32BaseWindow *)parent->getFirstChild();
|
---|
2648 | if(hwndChildAfter != 0)
|
---|
2649 | {
|
---|
2650 | while(child)
|
---|
2651 | {
|
---|
2652 | if(child->getWindowHandle() == hwndChildAfter)
|
---|
2653 | {
|
---|
2654 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
2655 | break;
|
---|
2656 | }
|
---|
2657 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
2658 | }
|
---|
2659 | }
|
---|
2660 | while(child)
|
---|
2661 | {
|
---|
2662 | if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
|
---|
2663 | (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
|
---|
2664 | {
|
---|
2665 | dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
|
---|
2666 | return child->getWindowHandle();
|
---|
2667 | }
|
---|
2668 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
2669 | }
|
---|
2670 | }
|
---|
2671 | else {
|
---|
2672 | Win32BaseWindow *wnd;
|
---|
2673 | HWND henum, hwnd;
|
---|
2674 |
|
---|
2675 | henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
|
---|
2676 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
2677 |
|
---|
2678 | while(hwnd)
|
---|
2679 | {
|
---|
2680 | wnd = GetWindowFromOS2Handle(hwnd);
|
---|
2681 | if(wnd == NULL) {
|
---|
2682 | hwnd = OSLibWinQueryClientWindow(hwnd);
|
---|
2683 | if(hwnd) wnd = GetWindowFromOS2Handle(hwnd);
|
---|
2684 | if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
|
---|
2685 | }
|
---|
2686 |
|
---|
2687 | if(wnd) {
|
---|
2688 | if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
|
---|
2689 | (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
|
---|
2690 | {
|
---|
2691 | OSLibWinEndEnumWindows(henum);
|
---|
2692 | dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
|
---|
2693 | return wnd->getWindowHandle();
|
---|
2694 | }
|
---|
2695 | }
|
---|
2696 | hwnd = OSLibWinGetNextWindow(henum);
|
---|
2697 | }
|
---|
2698 | OSLibWinEndEnumWindows(henum);
|
---|
2699 | }
|
---|
2700 | SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
|
---|
2701 | return 0;
|
---|
2702 | }
|
---|
2703 | //******************************************************************************
|
---|
2704 | //******************************************************************************
|
---|
2705 | HWND Win32BaseWindow::GetWindow(UINT uCmd)
|
---|
2706 | {
|
---|
2707 | HWND hwndRelated = 0;
|
---|
2708 | Win32BaseWindow *window;
|
---|
2709 |
|
---|
2710 | switch(uCmd)
|
---|
2711 | {
|
---|
2712 | case GW_HWNDFIRST:
|
---|
2713 | if(getParent()) {
|
---|
2714 | window = (Win32BaseWindow *)getParent()->getFirstChild();
|
---|
2715 | hwndRelated = window->getWindowHandle();
|
---|
2716 | }
|
---|
2717 | break;
|
---|
2718 |
|
---|
2719 | case GW_HWNDLAST:
|
---|
2720 | if(!getParent())
|
---|
2721 | {
|
---|
2722 | goto end;
|
---|
2723 | }
|
---|
2724 |
|
---|
2725 | window = this;
|
---|
2726 | while(window->getNextChild())
|
---|
2727 | {
|
---|
2728 | window = (Win32BaseWindow *)window->getNextChild();
|
---|
2729 | }
|
---|
2730 | hwndRelated = window->getWindowHandle();
|
---|
2731 | break;
|
---|
2732 |
|
---|
2733 | case GW_HWNDNEXT:
|
---|
2734 | window = (Win32BaseWindow *)getNextChild();
|
---|
2735 | if(window) {
|
---|
2736 | hwndRelated = window->getWindowHandle();
|
---|
2737 | }
|
---|
2738 | break;
|
---|
2739 |
|
---|
2740 | case GW_HWNDPREV:
|
---|
2741 | if(!getParent())
|
---|
2742 | {
|
---|
2743 | goto end;
|
---|
2744 | }
|
---|
2745 | window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
|
---|
2746 | if(window == this)
|
---|
2747 | {
|
---|
2748 | hwndRelated = 0; /* First in list */
|
---|
2749 | goto end;
|
---|
2750 | }
|
---|
2751 | while(window->getNextChild())
|
---|
2752 | {
|
---|
2753 | if (window->getNextChild() == this)
|
---|
2754 | {
|
---|
2755 | hwndRelated = window->getWindowHandle();
|
---|
2756 | goto end;
|
---|
2757 | }
|
---|
2758 | window = (Win32BaseWindow *)window->getNextChild();
|
---|
2759 | }
|
---|
2760 | break;
|
---|
2761 |
|
---|
2762 | case GW_OWNER:
|
---|
2763 | if(getOwner()) {
|
---|
2764 | hwndRelated = getOwner()->getWindowHandle();
|
---|
2765 | }
|
---|
2766 | break;
|
---|
2767 |
|
---|
2768 | case GW_CHILD:
|
---|
2769 | if(getFirstChild()) {
|
---|
2770 | hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
|
---|
2771 | }
|
---|
2772 | break;
|
---|
2773 | }
|
---|
2774 | end:
|
---|
2775 | dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
|
---|
2776 | return hwndRelated;
|
---|
2777 | }
|
---|
2778 | //******************************************************************************
|
---|
2779 | //******************************************************************************
|
---|
2780 | HWND Win32BaseWindow::SetActiveWindow()
|
---|
2781 | {
|
---|
2782 | HWND hwndActive;
|
---|
2783 | Win32BaseWindow *win32wnd;
|
---|
2784 | ULONG magic;
|
---|
2785 |
|
---|
2786 | hwndActive = OSLibWinSetActiveWindow(OS2HwndFrame);
|
---|
2787 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32WNDPTR);
|
---|
2788 | magic = OSLibWinGetWindowULong(hwndActive, OFFSET_WIN32PM_MAGIC);
|
---|
2789 | if(CheckMagicDword(magic) && win32wnd)
|
---|
2790 | {
|
---|
2791 | return win32wnd->getWindowHandle();
|
---|
2792 | }
|
---|
2793 | return 0;
|
---|
2794 | }
|
---|
2795 | //******************************************************************************
|
---|
2796 | //WM_ENABLE is sent to hwnd, but not to it's children (as it should be)
|
---|
2797 | //******************************************************************************
|
---|
2798 | BOOL Win32BaseWindow::EnableWindow(BOOL fEnable)
|
---|
2799 | {
|
---|
2800 | return OSLibWinEnableWindow(OS2HwndFrame, fEnable);
|
---|
2801 | }
|
---|
2802 | //******************************************************************************
|
---|
2803 | //******************************************************************************
|
---|
2804 | BOOL Win32BaseWindow::CloseWindow()
|
---|
2805 | {
|
---|
2806 | return OSLibWinMinimizeWindow(OS2HwndFrame);
|
---|
2807 | }
|
---|
2808 | //******************************************************************************
|
---|
2809 | //******************************************************************************
|
---|
2810 | HWND Win32BaseWindow::GetActiveWindow()
|
---|
2811 | {
|
---|
2812 | HWND hwndActive;
|
---|
2813 | Win32BaseWindow *win32wnd;
|
---|
2814 | ULONG magic;
|
---|
2815 |
|
---|
2816 | hwndActive = OSLibWinQueryActiveWindow();
|
---|
2817 |
|
---|
2818 | return OS2ToWin32Handle(hwndActive);
|
---|
2819 | }
|
---|
2820 | //******************************************************************************
|
---|
2821 | //******************************************************************************
|
---|
2822 | BOOL Win32BaseWindow::IsWindowEnabled()
|
---|
2823 | {
|
---|
2824 | return OSLibWinIsWindowEnabled(OS2HwndFrame);
|
---|
2825 | }
|
---|
2826 | //******************************************************************************
|
---|
2827 | //******************************************************************************
|
---|
2828 | BOOL Win32BaseWindow::IsWindowVisible()
|
---|
2829 | {
|
---|
2830 | #if 1
|
---|
2831 | return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
|
---|
2832 | #else
|
---|
2833 | return OSLibWinIsWindowVisible(OS2HwndFrame);
|
---|
2834 | #endif
|
---|
2835 | }
|
---|
2836 | //******************************************************************************
|
---|
2837 | //******************************************************************************
|
---|
2838 | BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode)
|
---|
2839 | {
|
---|
2840 | INT len = GetWindowTextLength();
|
---|
2841 | BOOL res;
|
---|
2842 |
|
---|
2843 | if (wndname == NULL)
|
---|
2844 | return (len == 0);
|
---|
2845 |
|
---|
2846 | len++;
|
---|
2847 | if (fUnicode)
|
---|
2848 | {
|
---|
2849 | WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
---|
2850 |
|
---|
2851 | GetWindowTextW(text,len);
|
---|
2852 | res = (lstrcmpW(text,(LPWSTR)wndname) == 0);
|
---|
2853 | free(text);
|
---|
2854 | } else
|
---|
2855 | {
|
---|
2856 | CHAR *text = (CHAR*)malloc(len*sizeof(CHAR));
|
---|
2857 |
|
---|
2858 | GetWindowTextA(text,len);
|
---|
2859 | res = (strcmp(text,wndname) == 0);
|
---|
2860 | free(text);
|
---|
2861 | }
|
---|
2862 |
|
---|
2863 | return res;
|
---|
2864 | }
|
---|
2865 | //******************************************************************************
|
---|
2866 | //******************************************************************************
|
---|
2867 | CHAR *Win32BaseWindow::getWindowNamePtrA()
|
---|
2868 | {
|
---|
2869 | INT len = GetWindowTextLength();
|
---|
2870 | CHAR *text;
|
---|
2871 |
|
---|
2872 | if (len == 0) return NULL;
|
---|
2873 | len++;
|
---|
2874 | text = (CHAR*)malloc(len*sizeof(CHAR));
|
---|
2875 | GetWindowTextA(text,len);
|
---|
2876 |
|
---|
2877 | return text;
|
---|
2878 | }
|
---|
2879 | //******************************************************************************
|
---|
2880 | //******************************************************************************
|
---|
2881 | WCHAR *Win32BaseWindow::getWindowNamePtrW()
|
---|
2882 | {
|
---|
2883 | INT len = GetWindowTextLength();
|
---|
2884 | WCHAR *text;
|
---|
2885 |
|
---|
2886 | if (len == 0) return NULL;
|
---|
2887 | len++;
|
---|
2888 | text = (WCHAR*)malloc(len*sizeof(WCHAR));
|
---|
2889 | GetWindowTextW(text,len);
|
---|
2890 |
|
---|
2891 | return text;
|
---|
2892 | }
|
---|
2893 | //******************************************************************************
|
---|
2894 | //******************************************************************************
|
---|
2895 | VOID Win32BaseWindow::freeWindowNamePtr(PVOID namePtr)
|
---|
2896 | {
|
---|
2897 | if (namePtr) free(namePtr);
|
---|
2898 | }
|
---|
2899 | //******************************************************************************
|
---|
2900 | //******************************************************************************
|
---|
2901 | int Win32BaseWindow::GetWindowTextLength()
|
---|
2902 | {
|
---|
2903 | return SendInternalMessageA(WM_GETTEXTLENGTH,0,0);
|
---|
2904 | }
|
---|
2905 | //******************************************************************************
|
---|
2906 | //******************************************************************************
|
---|
2907 | int Win32BaseWindow::GetWindowTextA(LPSTR lpsz, int cch)
|
---|
2908 | {
|
---|
2909 | return SendInternalMessageA(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
---|
2910 | }
|
---|
2911 | //******************************************************************************
|
---|
2912 | //******************************************************************************
|
---|
2913 | int Win32BaseWindow::GetWindowTextW(LPWSTR lpsz, int cch)
|
---|
2914 | {
|
---|
2915 | return SendInternalMessageW(WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
|
---|
2916 | }
|
---|
2917 | //******************************************************************************
|
---|
2918 | //******************************************************************************
|
---|
2919 | BOOL Win32BaseWindow::SetWindowTextA(LPSTR lpsz)
|
---|
2920 | {
|
---|
2921 | return SendInternalMessageA(WM_SETTEXT,0,(LPARAM)lpsz);
|
---|
2922 | }
|
---|
2923 | //******************************************************************************
|
---|
2924 | //******************************************************************************
|
---|
2925 | BOOL Win32BaseWindow::SetWindowTextW(LPWSTR lpsz)
|
---|
2926 | {
|
---|
2927 | return SendInternalMessageW(WM_SETTEXT,0,(LPARAM)lpsz);
|
---|
2928 | }
|
---|
2929 | //******************************************************************************
|
---|
2930 | //******************************************************************************
|
---|
2931 | VOID Win32BaseWindow::updateWindowStyle(DWORD oldExStyle,DWORD oldStyle)
|
---|
2932 | {
|
---|
2933 | if(IsWindowDestroyed()) return;
|
---|
2934 |
|
---|
2935 | //CB: todo: dwExStyle, creating new frame controls, destroy not used controls, WS_VISIBLE, WS_CHILD, ...
|
---|
2936 | // write test cases
|
---|
2937 | if ((dwStyle & 0xFFFF0000) != (oldStyle & 0xFFFF0000))
|
---|
2938 | {
|
---|
2939 | //dprintf(("updateWindowStyle: %x %x",oldStyle,dwStyle));
|
---|
2940 | OSLibSetWindowStyle(OS2HwndFrame, dwStyle, fTaskList);
|
---|
2941 | }
|
---|
2942 | }
|
---|
2943 | //******************************************************************************
|
---|
2944 | //******************************************************************************
|
---|
2945 | LONG Win32BaseWindow::SetWindowLongA(int index, ULONG value, BOOL fUnicode)
|
---|
2946 | {
|
---|
2947 | LONG oldval;
|
---|
2948 |
|
---|
2949 | dprintf2(("SetWindowLong%c %x %d %x", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
|
---|
2950 | switch(index) {
|
---|
2951 | case GWL_EXSTYLE:
|
---|
2952 | {
|
---|
2953 | STYLESTRUCT ss;
|
---|
2954 |
|
---|
2955 | if(dwExStyle == value)
|
---|
2956 | return value;
|
---|
2957 |
|
---|
2958 | ss.styleOld = dwExStyle;
|
---|
2959 | ss.styleNew = value;
|
---|
2960 | dprintf(("SetWindowLong GWL_EXSTYLE %x old %x new style %x", getWindowHandle(), dwExStyle, value));
|
---|
2961 | SendInternalMessageA(WM_STYLECHANGING,GWL_EXSTYLE,(LPARAM)&ss);
|
---|
2962 | setExStyle(ss.styleNew);
|
---|
2963 | updateWindowStyle(ss.styleOld,getStyle());
|
---|
2964 | SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
|
---|
2965 | return ss.styleOld;
|
---|
2966 | }
|
---|
2967 | case GWL_STYLE:
|
---|
2968 | {
|
---|
2969 | STYLESTRUCT ss;
|
---|
2970 |
|
---|
2971 | if(dwStyle == value)
|
---|
2972 | return value;
|
---|
2973 |
|
---|
2974 | value &= ~(WS_VISIBLE | WS_CHILD); /* Some bits can't be changed this way (WINE) */
|
---|
2975 | ss.styleOld = getStyle();
|
---|
2976 | ss.styleNew = value | (ss.styleOld & (WS_VISIBLE | WS_CHILD));
|
---|
2977 | dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x", getWindowHandle(), ss.styleOld, ss.styleNew));
|
---|
2978 | SendInternalMessageA(WM_STYLECHANGING,GWL_STYLE,(LPARAM)&ss);
|
---|
2979 | setStyle(ss.styleNew);
|
---|
2980 | updateWindowStyle(dwExStyle,ss.styleOld);
|
---|
2981 | SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
|
---|
2982 | #ifdef DEBUG
|
---|
2983 | PrintWindowStyle(ss.styleNew, 0);
|
---|
2984 | #endif
|
---|
2985 | return ss.styleOld;
|
---|
2986 | }
|
---|
2987 | case GWL_WNDPROC:
|
---|
2988 | oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
---|
2989 | //WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_WINDOW);
|
---|
2990 | WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, WINPROC_GetProcType(win32wndproc), WIN_PROC_WINDOW);
|
---|
2991 | return oldval;
|
---|
2992 | case GWL_HINSTANCE:
|
---|
2993 | oldval = hInstance;
|
---|
2994 | hInstance = value;
|
---|
2995 | return oldval;
|
---|
2996 | case GWL_HWNDPARENT:
|
---|
2997 | return SetParent((HWND)value);
|
---|
2998 | case GWL_ID:
|
---|
2999 | oldval = getWindowId();
|
---|
3000 | setWindowId(value);
|
---|
3001 | return oldval;
|
---|
3002 | case GWL_USERDATA:
|
---|
3003 | oldval = userData;
|
---|
3004 | userData = value;
|
---|
3005 | return oldval;
|
---|
3006 | default:
|
---|
3007 | if(index >= 0 && index/4 < nrUserWindowLong)
|
---|
3008 | {
|
---|
3009 | oldval = userWindowLong[index/4];
|
---|
3010 | userWindowLong[index/4] = value;
|
---|
3011 | return oldval;
|
---|
3012 | }
|
---|
3013 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
3014 | return 0;
|
---|
3015 | }
|
---|
3016 | }
|
---|
3017 | //******************************************************************************
|
---|
3018 | //******************************************************************************
|
---|
3019 | ULONG Win32BaseWindow::GetWindowLongA(int index, BOOL fUnicode)
|
---|
3020 | {
|
---|
3021 | ULONG value;
|
---|
3022 |
|
---|
3023 | switch(index) {
|
---|
3024 | case GWL_EXSTYLE:
|
---|
3025 | value = dwExStyle;
|
---|
3026 | break;
|
---|
3027 | case GWL_STYLE:
|
---|
3028 | value = dwStyle;
|
---|
3029 | break;
|
---|
3030 | case GWL_WNDPROC:
|
---|
3031 | value = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
|
---|
3032 | break;
|
---|
3033 | case GWL_HINSTANCE:
|
---|
3034 | value = hInstance;
|
---|
3035 | break;
|
---|
3036 | case GWL_HWNDPARENT:
|
---|
3037 | if(getParent()) {
|
---|
3038 | value = getParent()->getWindowHandle();
|
---|
3039 | }
|
---|
3040 | else value = 0;
|
---|
3041 | break;
|
---|
3042 | case GWL_ID:
|
---|
3043 | value = getWindowId();
|
---|
3044 | break;
|
---|
3045 | case GWL_USERDATA:
|
---|
3046 | value = userData;
|
---|
3047 | break;
|
---|
3048 | default:
|
---|
3049 | if(index >= 0 && index/4 < nrUserWindowLong)
|
---|
3050 | {
|
---|
3051 | value = userWindowLong[index/4];
|
---|
3052 | break;
|
---|
3053 | }
|
---|
3054 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
3055 | return 0;
|
---|
3056 | }
|
---|
3057 | dprintf2(("GetWindowLongA %x %d %x", getWindowHandle(), index, value));
|
---|
3058 | return value;
|
---|
3059 | }
|
---|
3060 | //******************************************************************************
|
---|
3061 | //******************************************************************************
|
---|
3062 | WORD Win32BaseWindow::SetWindowWord(int index, WORD value)
|
---|
3063 | {
|
---|
3064 | WORD oldval;
|
---|
3065 |
|
---|
3066 | if(index >= 0 && index/4 < nrUserWindowLong)
|
---|
3067 | {
|
---|
3068 | oldval = ((WORD *)userWindowLong)[index/2];
|
---|
3069 | ((WORD *)userWindowLong)[index/2] = value;
|
---|
3070 | return oldval;
|
---|
3071 | }
|
---|
3072 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
3073 | return 0;
|
---|
3074 | }
|
---|
3075 | //******************************************************************************
|
---|
3076 | //******************************************************************************
|
---|
3077 | WORD Win32BaseWindow::GetWindowWord(int index)
|
---|
3078 | {
|
---|
3079 | if(index >= 0 && index/4 < nrUserWindowLong)
|
---|
3080 | {
|
---|
3081 | return ((WORD *)userWindowLong)[index/2];
|
---|
3082 | }
|
---|
3083 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
3084 | return 0;
|
---|
3085 | }
|
---|
3086 | //******************************************************************************
|
---|
3087 | //******************************************************************************
|
---|
3088 | void Win32BaseWindow::setWindowId(DWORD id)
|
---|
3089 | {
|
---|
3090 | windowId = id;
|
---|
3091 | dprintf(("Set window ID to %x", id));
|
---|
3092 | OSLibSetWindowID(OS2HwndFrame, id);
|
---|
3093 | }
|
---|
3094 | //******************************************************************************
|
---|
3095 | //******************************************************************************
|
---|
3096 | Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
|
---|
3097 | {
|
---|
3098 | Win32BaseWindow *window;
|
---|
3099 |
|
---|
3100 | if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
|
---|
3101 | return window;
|
---|
3102 | }
|
---|
3103 | // dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
|
---|
3104 | return NULL;
|
---|
3105 | }
|
---|
3106 | //******************************************************************************
|
---|
3107 | //******************************************************************************
|
---|
3108 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
|
---|
3109 | {
|
---|
3110 | Win32BaseWindow *win32wnd;
|
---|
3111 | DWORD magic;
|
---|
3112 |
|
---|
3113 | if(hwnd == OSLIB_HWND_DESKTOP)
|
---|
3114 | {
|
---|
3115 | return windowDesktop;
|
---|
3116 | }
|
---|
3117 |
|
---|
3118 | win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
|
---|
3119 | magic = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
|
---|
3120 |
|
---|
3121 | if(win32wnd && CheckMagicDword(magic)) {
|
---|
3122 | return win32wnd;
|
---|
3123 | }
|
---|
3124 | // dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
|
---|
3125 | return 0;
|
---|
3126 | }
|
---|
3127 | //******************************************************************************
|
---|
3128 | //******************************************************************************
|
---|
3129 | Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
|
---|
3130 | {
|
---|
3131 | return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
|
---|
3132 | }
|
---|
3133 | //******************************************************************************
|
---|
3134 | //******************************************************************************
|
---|
3135 | HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
|
---|
3136 | {
|
---|
3137 | Win32BaseWindow *window = GetWindowFromHandle(hwnd);
|
---|
3138 |
|
---|
3139 | if(window) {
|
---|
3140 | return window->getOS2WindowHandle();
|
---|
3141 | }
|
---|
3142 | // dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
|
---|
3143 | return hwnd;
|
---|
3144 | }
|
---|
3145 | //******************************************************************************
|
---|
3146 | //******************************************************************************
|
---|
3147 | HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
|
---|
3148 | {
|
---|
3149 | Win32BaseWindow *window = GetWindowFromHandle(hwnd);
|
---|
3150 |
|
---|
3151 | if(window) {
|
---|
3152 | return window->getOS2FrameWindowHandle();
|
---|
3153 | }
|
---|
3154 | // dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
|
---|
3155 | return hwnd;
|
---|
3156 | }
|
---|
3157 | //******************************************************************************
|
---|
3158 | //******************************************************************************
|
---|
3159 | HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
|
---|
3160 | {
|
---|
3161 | Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
|
---|
3162 |
|
---|
3163 | if(window) {
|
---|
3164 | return window->getWindowHandle();
|
---|
3165 | }
|
---|
3166 | window = GetWindowFromOS2FrameHandle(hwnd);
|
---|
3167 | if(window) {
|
---|
3168 | return window->getWindowHandle();
|
---|
3169 | }
|
---|
3170 | // dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
|
---|
3171 | return 0;
|
---|
3172 | // else return hwnd; //OS/2 window handle
|
---|
3173 | }
|
---|
3174 | //******************************************************************************
|
---|
3175 | // GetNextDlgTabItem32 (USER32.276)
|
---|
3176 | //******************************************************************************
|
---|
3177 | HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
|
---|
3178 | {
|
---|
3179 | Win32BaseWindow *child, *nextchild, *lastchild;
|
---|
3180 | HWND retvalue;
|
---|
3181 |
|
---|
3182 | if (hwndCtrl)
|
---|
3183 | {
|
---|
3184 | child = GetWindowFromHandle(hwndCtrl);
|
---|
3185 | if (!child)
|
---|
3186 | {
|
---|
3187 | retvalue = 0;
|
---|
3188 | goto END;
|
---|
3189 | }
|
---|
3190 | /* Make sure hwndCtrl is a top-level child */
|
---|
3191 | while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
|
---|
3192 | {
|
---|
3193 | child = child->getParent();
|
---|
3194 | if(child == NULL) break;
|
---|
3195 | }
|
---|
3196 |
|
---|
3197 | if (!child || (child->getParent() != this))
|
---|
3198 | {
|
---|
3199 | retvalue = 0;
|
---|
3200 | goto END;
|
---|
3201 | }
|
---|
3202 | }
|
---|
3203 | else
|
---|
3204 | {
|
---|
3205 | /* No ctrl specified -> start from the beginning */
|
---|
3206 | child = (Win32BaseWindow *)getFirstChild();
|
---|
3207 | if (!child)
|
---|
3208 | {
|
---|
3209 | retvalue = 0;
|
---|
3210 | goto END;
|
---|
3211 | }
|
---|
3212 |
|
---|
3213 | if (!fPrevious)
|
---|
3214 | {
|
---|
3215 | while (child->getNextChild())
|
---|
3216 | {
|
---|
3217 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
3218 | }
|
---|
3219 | }
|
---|
3220 | }
|
---|
3221 |
|
---|
3222 | lastchild = child;
|
---|
3223 | nextchild = (Win32BaseWindow *)child->getNextChild();
|
---|
3224 | while (TRUE)
|
---|
3225 | {
|
---|
3226 | if (!nextchild) nextchild = (Win32BaseWindow *)getFirstChild();
|
---|
3227 |
|
---|
3228 | if (child == nextchild) break;
|
---|
3229 |
|
---|
3230 | if ((nextchild->getStyle() & WS_TABSTOP) && (nextchild->getStyle() & WS_VISIBLE) &&
|
---|
3231 | !(nextchild->getStyle() & WS_DISABLED))
|
---|
3232 | {
|
---|
3233 | lastchild = nextchild;
|
---|
3234 | if (!fPrevious) break;
|
---|
3235 | }
|
---|
3236 | nextchild = (Win32BaseWindow *)nextchild->getNextChild();
|
---|
3237 | }
|
---|
3238 | retvalue = lastchild->getWindowHandle();
|
---|
3239 |
|
---|
3240 | END:
|
---|
3241 | return retvalue;
|
---|
3242 | }
|
---|
3243 | //******************************************************************************
|
---|
3244 | //******************************************************************************
|
---|
3245 | HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
|
---|
3246 | {
|
---|
3247 | Win32BaseWindow *child, *nextchild, *lastchild;
|
---|
3248 | HWND retvalue;
|
---|
3249 |
|
---|
3250 | if (hwndCtrl)
|
---|
3251 | {
|
---|
3252 | child = GetWindowFromHandle(hwndCtrl);
|
---|
3253 | if (!child)
|
---|
3254 | {
|
---|
3255 | retvalue = 0;
|
---|
3256 | goto END;
|
---|
3257 | }
|
---|
3258 | /* Make sure hwndCtrl is a top-level child */
|
---|
3259 | while ((child->getStyle() & WS_CHILD) && (child->getParent() != this))
|
---|
3260 | {
|
---|
3261 | child = child->getParent();
|
---|
3262 | if(child == NULL) break;
|
---|
3263 | }
|
---|
3264 |
|
---|
3265 | if (!child || (child->getParent() != this))
|
---|
3266 | {
|
---|
3267 | retvalue = 0;
|
---|
3268 | goto END;
|
---|
3269 | }
|
---|
3270 | }
|
---|
3271 | else
|
---|
3272 | {
|
---|
3273 | /* No ctrl specified -> start from the beginning */
|
---|
3274 | child = (Win32BaseWindow *)getFirstChild();
|
---|
3275 | if (!child)
|
---|
3276 | {
|
---|
3277 | retvalue = 0;
|
---|
3278 | goto END;
|
---|
3279 | }
|
---|
3280 |
|
---|
3281 | if (fPrevious)
|
---|
3282 | {
|
---|
3283 | while (child->getNextChild())
|
---|
3284 | {
|
---|
3285 | child = (Win32BaseWindow *)child->getNextChild();
|
---|
3286 | }
|
---|
3287 | }
|
---|
3288 | }
|
---|
3289 |
|
---|
3290 | lastchild = child;
|
---|
3291 | nextchild = (Win32BaseWindow *)child->getNextChild();
|
---|
3292 | while (TRUE)
|
---|
3293 | {
|
---|
3294 | if (!nextchild || (nextchild->getStyle() & WS_GROUP))
|
---|
3295 | {
|
---|
3296 | /* Wrap-around to the beginning of the group */
|
---|
3297 | Win32BaseWindow *pWndTemp;
|
---|
3298 |
|
---|
3299 | nextchild = (Win32BaseWindow *)getFirstChild();
|
---|
3300 |
|
---|
3301 | for(pWndTemp = nextchild;pWndTemp;pWndTemp = (Win32BaseWindow *)pWndTemp->getNextChild())
|
---|
3302 | {
|
---|
3303 | if (pWndTemp->getStyle() & WS_GROUP)
|
---|
3304 | nextchild = pWndTemp;
|
---|
3305 |
|
---|
3306 | if (pWndTemp == child)
|
---|
3307 | break;
|
---|
3308 | }
|
---|
3309 |
|
---|
3310 | }
|
---|
3311 | if (nextchild == child)
|
---|
3312 | break;
|
---|
3313 |
|
---|
3314 | if ((nextchild->getStyle() & WS_VISIBLE) && !(nextchild->getStyle() & WS_DISABLED))
|
---|
3315 | {
|
---|
3316 | lastchild = nextchild;
|
---|
3317 |
|
---|
3318 | if (!fPrevious)
|
---|
3319 | break;
|
---|
3320 | }
|
---|
3321 |
|
---|
3322 | nextchild = (Win32BaseWindow *)nextchild->getNextChild();
|
---|
3323 | }
|
---|
3324 | retvalue = lastchild->getWindowHandle();
|
---|
3325 | END:
|
---|
3326 | return retvalue;
|
---|
3327 | }
|
---|
3328 | //******************************************************************************
|
---|
3329 | //******************************************************************************
|
---|
3330 | #ifdef DEBUG
|
---|
3331 | void PrintWindowStyle(DWORD dwStyle, DWORD dwExStyle)
|
---|
3332 | {
|
---|
3333 | char style[256] = "";
|
---|
3334 | char exstyle[256] = "";
|
---|
3335 |
|
---|
3336 | /* Window styles */
|
---|
3337 | if(dwStyle & WS_CHILD)
|
---|
3338 | strcat(style, "WS_CHILD ");
|
---|
3339 | if(dwStyle & WS_POPUP)
|
---|
3340 | strcat(style, "WS_POPUP ");
|
---|
3341 | if(dwStyle & WS_VISIBLE)
|
---|
3342 | strcat(style, "WS_VISIBLE ");
|
---|
3343 | if(dwStyle & WS_DISABLED)
|
---|
3344 | strcat(style, "WS_DISABLED ");
|
---|
3345 | if(dwStyle & WS_CLIPSIBLINGS)
|
---|
3346 | strcat(style, "WS_CLIPSIBLINGS ");
|
---|
3347 | if(dwStyle & WS_CLIPCHILDREN)
|
---|
3348 | strcat(style, "WS_CLIPCHILDREN ");
|
---|
3349 | if(dwStyle & WS_MAXIMIZE)
|
---|
3350 | strcat(style, "WS_MAXIMIZE ");
|
---|
3351 | if(dwStyle & WS_MINIMIZE)
|
---|
3352 | strcat(style, "WS_MINIMIZE ");
|
---|
3353 | if(dwStyle & WS_GROUP)
|
---|
3354 | strcat(style, "WS_GROUP ");
|
---|
3355 | if(dwStyle & WS_TABSTOP)
|
---|
3356 | strcat(style, "WS_TABSTOP ");
|
---|
3357 |
|
---|
3358 | if((dwStyle & WS_CAPTION) == WS_CAPTION)
|
---|
3359 | strcat(style, "WS_CAPTION ");
|
---|
3360 | if(dwStyle & WS_DLGFRAME)
|
---|
3361 | strcat(style, "WS_DLGFRAME ");
|
---|
3362 | if(dwStyle & WS_BORDER)
|
---|
3363 | strcat(style, "WS_BORDER ");
|
---|
3364 |
|
---|
3365 | if(dwStyle & WS_VSCROLL)
|
---|
3366 | strcat(style, "WS_VSCROLL ");
|
---|
3367 | if(dwStyle & WS_HSCROLL)
|
---|
3368 | strcat(style, "WS_HSCROLL ");
|
---|
3369 | if(dwStyle & WS_SYSMENU)
|
---|
3370 | strcat(style, "WS_SYSMENU ");
|
---|
3371 | if(dwStyle & WS_THICKFRAME)
|
---|
3372 | strcat(style, "WS_THICKFRAME ");
|
---|
3373 | if(dwStyle & WS_MINIMIZEBOX)
|
---|
3374 | strcat(style, "WS_MINIMIZEBOX ");
|
---|
3375 | if(dwStyle & WS_MAXIMIZEBOX)
|
---|
3376 | strcat(style, "WS_MAXIMIZEBOX ");
|
---|
3377 |
|
---|
3378 | if(dwExStyle & WS_EX_DLGMODALFRAME)
|
---|
3379 | strcat(exstyle, "WS_EX_DLGMODALFRAME ");
|
---|
3380 | if(dwExStyle & WS_EX_ACCEPTFILES)
|
---|
3381 | strcat(exstyle, "WS_EX_ACCEPTFILES ");
|
---|
3382 | if(dwExStyle & WS_EX_NOPARENTNOTIFY)
|
---|
3383 | strcat(exstyle, "WS_EX_NOPARENTNOTIFY ");
|
---|
3384 | if(dwExStyle & WS_EX_TOPMOST)
|
---|
3385 | strcat(exstyle, "WS_EX_TOPMOST ");
|
---|
3386 | if(dwExStyle & WS_EX_TRANSPARENT)
|
---|
3387 | strcat(exstyle, "WS_EX_TRANSPARENT ");
|
---|
3388 |
|
---|
3389 | if(dwExStyle & WS_EX_MDICHILD)
|
---|
3390 | strcat(exstyle, "WS_EX_MDICHILD ");
|
---|
3391 | if(dwExStyle & WS_EX_TOOLWINDOW)
|
---|
3392 | strcat(exstyle, "WS_EX_TOOLWINDOW ");
|
---|
3393 | if(dwExStyle & WS_EX_WINDOWEDGE)
|
---|
3394 | strcat(exstyle, "WS_EX_WINDOWEDGE ");
|
---|
3395 | if(dwExStyle & WS_EX_CLIENTEDGE)
|
---|
3396 | strcat(exstyle, "WS_EX_CLIENTEDGE ");
|
---|
3397 | if(dwExStyle & WS_EX_CONTEXTHELP)
|
---|
3398 | strcat(exstyle, "WS_EX_CONTEXTHELP ");
|
---|
3399 | if(dwExStyle & WS_EX_RIGHT)
|
---|
3400 | strcat(exstyle, "WS_EX_RIGHT ");
|
---|
3401 | if(dwExStyle & WS_EX_LEFT)
|
---|
3402 | strcat(exstyle, "WS_EX_LEFT ");
|
---|
3403 | if(dwExStyle & WS_EX_RTLREADING)
|
---|
3404 | strcat(exstyle, "WS_EX_RTLREADING ");
|
---|
3405 | if(dwExStyle & WS_EX_LTRREADING)
|
---|
3406 | strcat(exstyle, "WS_EX_LTRREADING ");
|
---|
3407 | if(dwExStyle & WS_EX_LEFTSCROLLBAR)
|
---|
3408 | strcat(exstyle, "WS_EX_LEFTSCROLLBAR ");
|
---|
3409 | if(dwExStyle & WS_EX_RIGHTSCROLLBAR)
|
---|
3410 | strcat(exstyle, "WS_EX_RIGHTSCROLLBAR ");
|
---|
3411 | if(dwExStyle & WS_EX_CONTROLPARENT)
|
---|
3412 | strcat(exstyle, "WS_EX_CONTROLPARENT ");
|
---|
3413 | if(dwExStyle & WS_EX_STATICEDGE)
|
---|
3414 | strcat(exstyle, "WS_EX_STATICEDGE ");
|
---|
3415 | if(dwExStyle & WS_EX_APPWINDOW)
|
---|
3416 | strcat(exstyle, "WS_EX_APPWINDOW ");
|
---|
3417 |
|
---|
3418 | dprintf(("Window style: %x %s", dwStyle, style));
|
---|
3419 | dprintf(("Window exStyle: %x %s (FS = %x)", dwExStyle, exstyle, GetFS()));
|
---|
3420 | }
|
---|
3421 | #endif
|
---|
3422 | //******************************************************************************
|
---|
3423 | //******************************************************************************
|
---|
3424 |
|
---|
3425 | GenericObject *Win32BaseWindow::windows = NULL;
|
---|