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