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

Last change on this file since 300 was 300, checked in by sandervl, 26 years ago

Very preliminary code for Open32 replacement

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