source: trunk/src/user32/new/window.cpp@ 304

Last change on this file since 304 was 304, checked in by cbratschi, 26 years ago

several bugs fixed, RegisterClass works, CreateWindow on the way

File size: 23.7 KB
Line 
1/* $Id: window.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
2/*
3 * Win32 window apis for OS/2
4 *
5 * Copyright 1999 Sander van Leeuwen
6 *
7 * Parts based on Wine Windows code (windows\win.c)
8 *
9 * Copyright 1993, 1994 Alexandre Julliard
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14
15#include <os2win.h>
16#include <misc.h>
17#include <win32wnd.h>
18
19//******************************************************************************
20//******************************************************************************
21HWND WIN32API CreateWindowExA(DWORD exStyle, LPCSTR className,
22 LPCSTR windowName, DWORD style, INT x,
23 INT y, INT width, INT height,
24 HWND parent, HMENU menu,
25 HINSTANCE instance, LPVOID data )
26{
27 Win32Window *window;
28 ATOM classAtom;
29 CREATESTRUCTA cs;
30
31 if(exStyle & WS_EX_MDICHILD)
32 return CreateMDIWindowA(className, windowName, style, x, y, width, height, parent, instance, (LPARAM)data);
33
34 /* Find the class atom */
35 if (!(classAtom = GlobalFindAtomA(className)))
36 {
37 dprintf(("CreateWindowEx32A: bad class name "));
38 if (!HIWORD(className)) {
39 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
40 }
41 else dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
42 SetLastError(ERROR_INVALID_PARAMETER);
43 return 0;
44 }
45
46 /* Create the window */
47 cs.lpCreateParams = data;
48 cs.hInstance = instance;
49 cs.hMenu = menu;
50 cs.hwndParent = parent;
51 cs.x = x;
52 cs.y = y;
53 cs.cx = width;
54 cs.cy = height;
55 cs.style = style;
56 cs.lpszName = windowName;
57 cs.lpszClass = className;
58 cs.dwExStyle = exStyle;
59 window = new Win32Window( &cs, classAtom, FALSE );
60 if(window == NULL)
61 {
62 dprintf(("Win32Window creation failed!!"));
63 return 0;
64 }
65 if(GetLastError() != 0)
66 {
67 dprintf(("Win32Window error found!!"));
68 delete window;
69 return 0;
70 }
71 return window->getWindowHandle();
72}
73//******************************************************************************
74//******************************************************************************
75HWND WIN32API CreateMDIWindowA(LPCSTR arg1, LPCSTR arg2, DWORD arg3,
76 int arg4, int arg5, int arg6, int arg7,
77 HWND arg8, HINSTANCE arg9, LPARAM arg10)
78{
79 HWND hwnd;
80
81 dprintf(("USER32: CreateMDIWindowA\n"));
82
83 hwnd = O32_CreateMDIWindow((LPSTR)arg1, (LPSTR)arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
84
85 dprintf(("USER32: CreateMDIWindowA returned %X\n", hwnd));
86 return hwnd;
87}
88//******************************************************************************
89//******************************************************************************
90HWND WIN32API CreateMDIWindowW(LPCWSTR arg1, LPCWSTR arg2, DWORD arg3, int arg4,
91 int arg5, int arg6, int arg7, HWND arg8, HINSTANCE arg9,
92 LPARAM arg10)
93{
94 HWND hwnd;
95 char *astring1 = NULL, *astring2 = NULL;
96
97 if((int)arg1 >> 16 != 0) {
98 astring1 = UnicodeToAsciiString((LPWSTR)arg1);
99 }
100 else astring1 = (char *)arg2;
101
102 astring2 = UnicodeToAsciiString((LPWSTR)arg2);
103
104 hwnd = O32_CreateMDIWindow(astring1, astring2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
105
106 if(astring1) FreeAsciiString(astring1);
107 FreeAsciiString(astring2);
108 dprintf(("USER32: CreateMDIWindowW hwnd = %X\n", hwnd));
109 return(hwnd);
110}
111//******************************************************************************
112//******************************************************************************
113HWND WIN32API CreateWindowExW(DWORD arg1,
114 LPCWSTR arg2,
115 LPCWSTR arg3,
116 DWORD dwStyle,
117 int arg5,
118 int arg6,
119 int arg7,
120 int arg8,
121 HWND arg9,
122 HMENU arg10,
123 HINSTANCE arg11,
124 PVOID arg12)
125{
126 HWND hwnd;
127 char *astring1 = NULL,
128 *astring2 = NULL;
129
130 /* @@@PH 98/06/21 changed to call OS2CreateWindowExA */
131 if(HIWORD(arg2) != 0)
132 astring1 = UnicodeToAsciiString((LPWSTR)arg2);
133 else
134 astring1 = (char *)arg2;
135
136 astring2 = UnicodeToAsciiString((LPWSTR)arg3);
137
138#ifdef DEBUG
139 WriteLog("USER32: CreateWindowExW: dwExStyle = %X\n", arg1);
140 if((int)arg2 >> 16 != 0)
141 WriteLog("USER32: CreateWindow: classname = %s\n", astring1);
142 else WriteLog("USER32: CreateWindow: classname = %X\n", arg2);
143 WriteLog("USER32: CreateWindow: windowname= %s\n", astring2);
144 WriteLog("USER32: CreateWindow: dwStyle = %X\n", dwStyle);
145 WriteLog("USER32: CreateWindow: x = %d\n", arg5);
146 WriteLog("USER32: CreateWindow: y = %d\n", arg6);
147 WriteLog("USER32: CreateWindow: nWidth = %d\n", arg7);
148 WriteLog("USER32: CreateWindow: nHeight = %d\n", arg8);
149 WriteLog("USER32: CreateWindow: parent = %X\n", arg9);
150 WriteLog("USER32: CreateWindow: hwmenu = %X\n", arg10);
151 WriteLog("USER32: CreateWindow: hinstance = %X\n", arg11);
152 WriteLog("USER32: CreateWindow: param = %X\n", arg12);
153 #endif
154
155 hwnd = CreateWindowExA(arg1,
156 astring1,
157 astring2,
158 dwStyle,
159 arg5,
160 arg6,
161 arg7,
162 arg8,
163 arg9,
164 arg10,
165 arg11,
166 arg12);
167
168 if(HIWORD(arg1) != 0)
169 FreeAsciiString(astring1);
170
171 FreeAsciiString(astring2);
172
173#ifdef DEBUG
174 WriteLog("USER32: ************CreateWindowExW hwnd = %X (%X)\n", hwnd, GetLastError());
175#endif
176 return(hwnd);
177}
178//******************************************************************************
179//******************************************************************************
180BOOL WIN32API DestroyWindow(HWND arg1)
181{
182#ifdef DEBUG
183 WriteLog("USER32: DestroyWindow\n");
184#endif
185 return O32_DestroyWindow(arg1);
186}
187//******************************************************************************
188//******************************************************************************
189HWND WIN32API SetActiveWindow( HWND arg1)
190{
191#ifdef DEBUG
192 WriteLog("USER32: SetActiveWindow\n");
193#endif
194 return O32_SetActiveWindow(arg1);
195}
196//******************************************************************************
197//******************************************************************************
198HWND WIN32API GetParent( HWND arg1)
199{
200#ifdef DEBUG
201//// WriteLog("USER32: GetParent\n");
202#endif
203 return O32_GetParent(arg1);
204}
205//******************************************************************************
206//******************************************************************************
207HWND WIN32API SetParent( HWND arg1, HWND arg2)
208{
209#ifdef DEBUG
210 WriteLog("USER32: SetParent\n");
211#endif
212 return O32_SetParent(arg1, arg2);
213}
214//******************************************************************************
215//******************************************************************************
216BOOL WIN32API IsChild( HWND arg1, HWND arg2)
217{
218#ifdef DEBUG
219 WriteLog("USER32: IsChild\n");
220#endif
221 return O32_IsChild(arg1, arg2);
222}
223//******************************************************************************
224//******************************************************************************
225HWND WIN32API GetTopWindow( HWND arg1)
226{
227#ifdef DEBUG
228//// WriteLog("USER32: GetTopWindow\n");
229#endif
230 return O32_GetTopWindow(arg1);
231}
232//******************************************************************************
233//******************************************************************************
234BOOL WIN32API UpdateWindow(HWND hwnd)
235{
236 dprintf(("USER32: UpdateWindow\n"));
237
238 return O32_UpdateWindow(hwnd);
239}
240//******************************************************************************
241//******************************************************************************
242BOOL WIN32API IsIconic( HWND arg1)
243{
244#ifdef DEBUG
245 WriteLog("USER32: IsIconic\n");
246#endif
247 return O32_IsIconic(arg1);
248}
249//******************************************************************************
250//******************************************************************************
251HWND WIN32API GetWindow(HWND arg1, UINT arg2)
252{
253 HWND rc;
254
255 rc = O32_GetWindow(arg1, arg2);
256#ifdef DEBUG
257 WriteLog("USER32: GetWindow %X %d returned %d\n", arg1, arg2, rc);
258#endif
259 return(rc);
260}
261//******************************************************************************
262//******************************************************************************
263HDC WIN32API GetWindowDC(HWND arg1)
264{
265#ifdef DEBUG
266 WriteLog("USER32: GetWindowDC\n");
267#endif
268 return O32_GetWindowDC(arg1);
269}
270//******************************************************************************
271//******************************************************************************
272BOOL WIN32API EnableWindow( HWND arg1, BOOL arg2)
273{
274#ifdef DEBUG
275 WriteLog("USER32: EnableWindow\n");
276#endif
277 return O32_EnableWindow(arg1, arg2);
278}
279//******************************************************************************
280//******************************************************************************
281BOOL WIN32API BringWindowToTop( HWND arg1)
282{
283#ifdef DEBUG
284 WriteLog("USER32: BringWindowToTop\n");
285#endif
286 return O32_BringWindowToTop(arg1);
287}
288//******************************************************************************
289//******************************************************************************
290HWND WIN32API GetActiveWindow()
291{
292 return(O32_GetActiveWindow());
293}
294//******************************************************************************
295//******************************************************************************
296BOOL WIN32API ShowWindow(HWND arg1, int arg2)
297{
298#ifdef DEBUG
299 WriteLog("USER32: ShowWindow %X %d\n", arg1, arg2);
300#endif
301 return O32_ShowWindow(arg1, arg2);
302}
303//******************************************************************************
304//******************************************************************************
305BOOL WIN32API SetWindowPos( HWND arg1, HWND arg2, int arg3, int arg4, int arg5, int arg6, UINT arg7)
306{
307#ifdef DEBUG
308 WriteLog("USER32: SetWindowPos\n");
309#endif
310 return O32_SetWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
311}
312/***********************************************************************
313 * GetInternalWindowPos (USER32.245)
314 */
315UINT WIN32API GetInternalWindowPos(HWND hwnd,
316 LPRECT rectWnd,
317 LPPOINT ptIcon )
318{
319 WINDOWPLACEMENT wndpl;
320
321 dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
322 hwnd,
323 rectWnd,
324 ptIcon));
325
326 if (O32_GetWindowPlacement( hwnd, &wndpl ))
327 {
328 if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
329 if (ptIcon) *ptIcon = wndpl.ptMinPosition;
330 return wndpl.showCmd;
331 }
332 return 0;
333}
334//******************************************************************************
335//******************************************************************************
336BOOL WIN32API IsWindow( HWND arg1)
337{
338#ifdef DEBUG
339 WriteLog("USER32: IsWindow\n");
340#endif
341 return O32_IsWindow(arg1);
342}
343//******************************************************************************
344//******************************************************************************
345BOOL WIN32API IsWindowEnabled( HWND arg1)
346{
347#ifdef DEBUG
348 WriteLog("USER32: IsWindowEnabled\n");
349#endif
350 return O32_IsWindowEnabled(arg1);
351}
352//******************************************************************************
353//******************************************************************************
354BOOL WIN32API IsWindowVisible( HWND arg1)
355{
356#ifdef DEBUG
357 WriteLog("USER32: IsWindowVisible\n");
358#endif
359 return O32_IsWindowVisible(arg1);
360}
361//******************************************************************************
362//******************************************************************************
363BOOL WIN32API IsZoomed( HWND arg1)
364{
365#ifdef DEBUG
366 WriteLog("USER32: IsZoomed\n");
367#endif
368 return O32_IsZoomed(arg1);
369}
370//******************************************************************************
371//******************************************************************************
372BOOL WIN32API LockWindowUpdate( HWND arg1)
373{
374#ifdef DEBUG
375 WriteLog("USER32: LockWindowUpdate\n");
376#endif
377 return O32_LockWindowUpdate(arg1);
378}
379//******************************************************************************
380//******************************************************************************
381BOOL WIN32API RedrawWindow( HWND arg1, const RECT * arg2, HRGN arg3, UINT arg4)
382{
383 BOOL rc;
384
385 rc = O32_RedrawWindow(arg1, arg2, arg3, arg4);
386#ifdef DEBUG
387 WriteLog("USER32: RedrawWindow %X , %X, %X, %X returned %d\n", arg1, arg2, arg3, arg4, rc);
388#endif
389 InvalidateRect(arg1, arg2, TRUE);
390 UpdateWindow(arg1);
391 SendMessageA(arg1, WM_PAINT, 0, 0);
392 return(rc);
393}
394//******************************************************************************
395//******************************************************************************
396BOOL WIN32API GetWindowRect( HWND arg1, PRECT arg2)
397{
398 BOOL rc;
399
400 rc = O32_GetWindowRect(arg1, arg2);
401 dprintf(("USER32: GetWindowRect %X returned %d\n", arg1, rc));
402 return(rc);
403}
404//******************************************************************************
405//******************************************************************************
406BOOL WIN32API SetWindowTextA(HWND arg1, LPCSTR arg2)
407{
408#ifdef DEBUG
409 WriteLog("USER32: SetWindowText %s\n", arg2);
410#endif
411 return O32_SetWindowText(arg1, arg2);
412}
413//******************************************************************************
414//******************************************************************************
415BOOL WIN32API SetWindowTextW( HWND arg1, LPCWSTR arg2)
416{
417 char *astring = UnicodeToAsciiString((LPWSTR)arg2);
418 BOOL rc;
419
420 rc = SetWindowTextA(arg1, (LPCSTR)astring);
421 dprintf(("USER32: SetWindowTextW %X %s returned %d\n", arg1, astring, rc));
422 FreeAsciiString(astring);
423 return(rc);
424}
425//******************************************************************************
426//******************************************************************************
427BOOL WIN32API SetForegroundWindow(HWND arg1)
428{
429#ifdef DEBUG
430 WriteLog("USER32: SetForegroundWindow\n");
431#endif
432 return O32_SetForegroundWindow(arg1);
433}
434//******************************************************************************
435//******************************************************************************
436BOOL WIN32API GetClientRect( HWND arg1, PRECT arg2)
437{
438#ifdef DEBUG
439 WriteLog("USER32: GetClientRect of %X\n", arg1);
440#endif
441
442 return O32_GetClientRect(arg1, arg2);
443}
444//******************************************************************************
445//******************************************************************************
446HWND WIN32API FindWindowA(LPCSTR arg1, LPCSTR arg2)
447{
448#ifdef DEBUG
449 WriteLog("USER32: FindWindow\n");
450#endif
451 return O32_FindWindow(arg1, arg2);
452}
453//******************************************************************************
454//******************************************************************************
455HWND WIN32API FindWindowExA(HWND arg1, HWND arg2, LPCSTR arg3, LPCSTR arg4)
456{
457#ifdef DEBUG
458 WriteLog("USER32: FindWindowExA, not completely implemented\n");
459#endif
460 return O32_FindWindow(arg3, arg4);
461}
462//******************************************************************************
463//******************************************************************************
464BOOL WIN32API FlashWindow( HWND arg1, BOOL arg2)
465{
466#ifdef DEBUG
467 WriteLog("USER32: FlashWindow\n");
468#endif
469 return O32_FlashWindow(arg1, arg2);
470}
471//******************************************************************************
472//******************************************************************************
473BOOL WIN32API MoveWindow(HWND arg1, int arg2, int arg3, int arg4, int arg5, BOOL arg6)
474{
475 BOOL rc;
476
477 rc = O32_MoveWindow(arg1, arg2, arg3, arg4, arg5, arg6);
478 dprintf(("USER32: MoveWindow %X to (%d,%d) size (%d,%d), repaint = %d returned %d\n", arg1, arg2, arg3, arg4, arg5, arg6, rc));
479 return(rc);
480}
481//******************************************************************************
482//******************************************************************************
483BOOL WIN32API AdjustWindowRect( PRECT arg1, DWORD arg2, BOOL arg3)
484{
485#ifdef DEBUG
486 WriteLog("USER32: AdjustWindowRect\n");
487#endif
488 return O32_AdjustWindowRect(arg1, arg2, arg3);
489}
490//******************************************************************************
491//******************************************************************************
492BOOL WIN32API AdjustWindowRectEx( PRECT arg1, DWORD arg2, BOOL arg3, DWORD arg4)
493{
494#ifdef DEBUG
495 WriteLog("USER32: AdjustWindowRectEx\n");
496#endif
497 return O32_AdjustWindowRectEx(arg1, arg2, arg3, arg4);
498}
499//******************************************************************************
500//******************************************************************************
501BOOL WIN32API ClientToScreen( HWND arg1, PPOINT arg2)
502{
503#ifdef DEBUG
504//// WriteLog("USER32: ClientToScreen\n");
505#endif
506 return O32_ClientToScreen(arg1, arg2);
507}
508//******************************************************************************
509//******************************************************************************
510HDWP WIN32API BeginDeferWindowPos( int arg1)
511{
512#ifdef DEBUG
513 WriteLog("USER32: BeginDeferWindowPos\n");
514#endif
515 return O32_BeginDeferWindowPos(arg1);
516}
517//******************************************************************************
518//******************************************************************************
519HDWP WIN32API DeferWindowPos( HDWP arg1, HWND arg2, HWND arg3, int arg4, int arg5, int arg6, int arg7, UINT arg8)
520{
521#ifdef DEBUG
522 WriteLog("USER32: DeferWindowPos\n");
523#endif
524 return O32_DeferWindowPos(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
525}
526//******************************************************************************
527//******************************************************************************
528HWND WIN32API ChildWindowFromPoint( HWND arg1, POINT arg2)
529{
530#ifdef DEBUG
531 WriteLog("USER32: ChildWindowFromPoint\n");
532#endif
533 return O32_ChildWindowFromPoint(arg1, arg2);
534}
535//******************************************************************************
536//******************************************************************************
537HWND WIN32API ChildWindowFromPointEx(HWND arg1, POINT arg2, UINT uFlags)
538{
539#ifdef DEBUG
540 WriteLog("USER32: ChildWindowFromPointEx, not completely supported!\n");
541#endif
542 return O32_ChildWindowFromPoint(arg1, arg2);
543}
544//******************************************************************************
545//******************************************************************************
546BOOL WIN32API CloseWindow( HWND arg1)
547{
548#ifdef DEBUG
549 WriteLog("USER32: CloseWindow\n");
550#endif
551 return O32_CloseWindow(arg1);
552}
553//******************************************************************************
554//******************************************************************************
555HWND WIN32API WindowFromDC( HDC arg1)
556{
557#ifdef DEBUG
558 WriteLog("USER32: WindowFromDC\n");
559#endif
560 return O32_WindowFromDC(arg1);
561}
562//******************************************************************************
563//******************************************************************************
564HWND WIN32API WindowFromPoint( POINT arg1)
565{
566#ifdef DEBUG
567 WriteLog("USER32: WindowFromPoint\n");
568#endif
569 return O32_WindowFromPoint(arg1);
570}
571//******************************************************************************
572//******************************************************************************
573BOOL WIN32API IsWindowUnicode(HWND hwnd)
574{
575#ifdef DEBUG
576 WriteLog("USER32: IsWindowUnicode, not implemented\n");
577#endif
578 return(FALSE);
579}
580/*****************************************************************************
581 * Name : WORD WIN32API CascadeWindows
582 * Purpose : The CascadeWindows function cascades the specified windows or
583 * the child windows of the specified parent window.
584 * Parameters: HWND hwndParent handle of parent window
585 * UINT wHow types of windows not to arrange
586 * CONST RECT * lpRect rectangle to arrange windows in
587 * UINT cKids number of windows to arrange
588 * const HWND FAR * lpKids array of window handles
589 * Variables :
590 * Result : If the function succeeds, the return value is the number of windows arranged.
591 * If the function fails, the return value is zero.
592 * Remark :
593 * Status : UNTESTED STUB
594 *
595 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
596 *****************************************************************************/
597
598WORD WIN32API CascadeWindows(HWND hwndParent,
599 UINT wHow,
600 CONST LPRECT lpRect,
601 UINT cKids,
602 const HWND *lpKids)
603{
604 dprintf(("USER32:CascadeWindows(%08xh,%u,%08xh,%u,%08x) not implemented.\n",
605 hwndParent,
606 wHow,
607 lpRect,
608 cKids,
609 lpKids));
610
611 return (0);
612}
613/*****************************************************************************
614 * Name : HWND WIN32API FindWindowExW
615 * Purpose : The FindWindowEx function retrieves the handle of a window whose
616 * class name and window name match the specified strings. The
617 * function searches child windows, beginning with the one following
618 * the given child window.
619 * Parameters: HWND hwndParent handle of parent window
620 * HWND hwndChildAfter handle of a child window
621 * LPCTSTR lpszClass address of class name
622 * LPCTSTR lpszWindow address of window name
623 * Variables :
624 * Result : If the function succeeds, the return value is the handle of the
625 * window that has the specified class and window names.
626 * If the function fails, the return value is NULL. To get extended
627 * error information, call GetLastError.
628 * Remark :
629 * Status : UNTESTED STUB
630 *
631 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
632 *****************************************************************************/
633
634HWND WIN32API FindWindowExW(HWND hwndParent,
635 HWND hwndChildAfter,
636 LPCWSTR lpszClass,
637 LPCWSTR lpszWindow)
638{
639 dprintf(("USER32:FindWindowExW (%08xh,%08xh,%s,%s) not implemented.\n",
640 hwndParent,
641 hwndChildAfter,
642 lpszClass,
643 lpszWindow));
644
645 return (NULL);
646}
647/*****************************************************************************
648 * Name : BOOL WIN32API SwitchToThisWindow
649 * Purpose : Unknown
650 * Parameters: Unknown
651 * Variables :
652 * Result :
653 * Remark :
654 * Status : UNTESTED UNKNOWN STUB
655 *
656 * Author : Patrick Haller [Wed, 1998/06/16 11:55]
657 *****************************************************************************/
658
659BOOL WIN32API SwitchToThisWindow(HWND hwnd,
660 BOOL x2)
661{
662 dprintf(("USER32: SwitchToThisWindow(%08xh,%08xh) not implemented.\n",
663 hwnd,
664 x2));
665
666 return (FALSE); /* default */
667}
668//******************************************************************************
669//******************************************************************************
Note: See TracBrowser for help on using the repository browser.