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