1 | /* $Id: win32wmdiclient.cpp,v 1.1 1999-08-30 14:21:50 sandervl Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 Window 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\mdi.c) (990815)
|
---|
9 | *
|
---|
10 | * Copyright 1994, Bob Amstadt
|
---|
11 | * 1995,1996 Alex Korobka
|
---|
12 | *
|
---|
13 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
14 | *
|
---|
15 | */
|
---|
16 | #include <os2win.h>
|
---|
17 | #include <win.h>
|
---|
18 | #include <stdlib.h>
|
---|
19 | #include <string.h>
|
---|
20 | #include <stdarg.h>
|
---|
21 | #include <assert.h>
|
---|
22 | #include <misc.h>
|
---|
23 | #include <heapstring.h>
|
---|
24 | #include <win32wmdiclient.h>
|
---|
25 | #include <win32wnd.h>
|
---|
26 | #include <spy.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 "oslibdos.h"
|
---|
34 | #include <winres.h>
|
---|
35 | #include "syscolor.h"
|
---|
36 | #include "win32wndhandle.h"
|
---|
37 | #include "heapshared.h"
|
---|
38 |
|
---|
39 |
|
---|
40 | //******************************************************************************
|
---|
41 | //******************************************************************************
|
---|
42 | Win32MDIClientWindow::Win32MDIClientWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
|
---|
43 | : Win32BaseWindow(lpCreateStructA, classAtom, isUnicode)
|
---|
44 | {
|
---|
45 | memset(&ci, 0, sizeof(ci));
|
---|
46 | }
|
---|
47 | //******************************************************************************
|
---|
48 | //******************************************************************************
|
---|
49 | Win32MDIClientWindow::~Win32MDIClientWindow()
|
---|
50 | {
|
---|
51 | }
|
---|
52 | //******************************************************************************
|
---|
53 | //******************************************************************************
|
---|
54 | LRESULT Win32MDIClientWindow::MDIClientWndProc(UINT message, WPARAM wParam, LPARAM lParam)
|
---|
55 | {
|
---|
56 | LPCREATESTRUCTA cs;
|
---|
57 | RECT rect;
|
---|
58 | INT nItems;
|
---|
59 | LRESULT retvalue;
|
---|
60 | Win32Window *frameWnd;
|
---|
61 |
|
---|
62 | frameWnd = (Win32Window *)getParent();
|
---|
63 | if(frameWnd == NULL) {
|
---|
64 | return 0;
|
---|
65 | }
|
---|
66 |
|
---|
67 | #if 0
|
---|
68 | switch (message)
|
---|
69 | {
|
---|
70 | case WM_CREATE:
|
---|
71 | cs = (LPCREATESTRUCTA)lParam;
|
---|
72 |
|
---|
73 | ci->hWindowMenu = cs->lpCreateParams->hWindowMenu;
|
---|
74 | ci->idFirstChild = cs->lpCreateParams->idFirstChild;
|
---|
75 |
|
---|
76 | ci->hwndChildMaximized = 0;
|
---|
77 | ci->nActiveChildren = 0;
|
---|
78 | ci->nTotalCreated = 0;
|
---|
79 | ci->frameTitle = NULL;
|
---|
80 | ci->mdiFlags = 0;
|
---|
81 | ci->self = hwnd;
|
---|
82 | w->dwStyle |= WS_CLIPCHILDREN;
|
---|
83 |
|
---|
84 | MDI_UpdateFrameText(frameWnd, hwnd, MDI_NOFRAMEREPAINT,frameWnd->text);
|
---|
85 |
|
---|
86 | AppendMenuA( ci->hWindowMenu, MF_SEPARATOR, 0, NULL );
|
---|
87 |
|
---|
88 | GetClientRect(frameWnd->hwndSelf, &rect);
|
---|
89 | w->rectClient = rect;
|
---|
90 |
|
---|
91 | dprintf(("MDIClient created - hwnd = %04x, idFirst = %u\n",
|
---|
92 | hwnd, ci->idFirstChild ));
|
---|
93 |
|
---|
94 | retvalue = 0;
|
---|
95 | goto END;
|
---|
96 |
|
---|
97 | case WM_DESTROY:
|
---|
98 | if( ci->hwndChildMaximized ) MDI_RestoreFrameMenu(w, frameWnd->hwndSelf);
|
---|
99 | if((nItems = GetMenuItemCount(ci->hWindowMenu)) > 0)
|
---|
100 | {
|
---|
101 | ci->idFirstChild = nItems - 1;
|
---|
102 | ci->nActiveChildren++; /* to delete a separator */
|
---|
103 | while( ci->nActiveChildren-- )
|
---|
104 | DeleteMenu(ci->hWindowMenu,MF_BYPOSITION,ci->idFirstChild--);
|
---|
105 | }
|
---|
106 | retvalue = 0;
|
---|
107 | goto END;
|
---|
108 |
|
---|
109 | case WM_MDIACTIVATE:
|
---|
110 | if( ci->hwndActiveChild != (HWND)wParam )
|
---|
111 | SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
|
---|
112 | retvalue = 0;
|
---|
113 | goto END;
|
---|
114 |
|
---|
115 | case WM_MDICASCADE:
|
---|
116 | retvalue = MDICascade(w, ci);
|
---|
117 | goto END;
|
---|
118 |
|
---|
119 | case WM_MDICREATE:
|
---|
120 | if (lParam) retvalue = MDICreateChild( w, ci, hwnd,
|
---|
121 | (MDICREATESTRUCTA*)lParam );
|
---|
122 | else retvalue = 0;
|
---|
123 | goto END;
|
---|
124 |
|
---|
125 | case WM_MDIDESTROY:
|
---|
126 | retvalue = MDIDestroyChild( w, ci, hwnd, (HWND)wParam, TRUE );
|
---|
127 | goto END;
|
---|
128 |
|
---|
129 | case WM_MDIGETACTIVE:
|
---|
130 | if (lParam) *(BOOL *)lParam = (ci->hwndChildMaximized > 0);
|
---|
131 | retvalue = ci->hwndActiveChild;
|
---|
132 | goto END;
|
---|
133 |
|
---|
134 | case WM_MDIICONARRANGE:
|
---|
135 | ci->mdiFlags |= MDIF_NEEDUPDATE;
|
---|
136 | ArrangeIconicWindows(hwnd);
|
---|
137 | ci->sbRecalc = SB_BOTH+1;
|
---|
138 | SendMessageA(hwnd, WM_MDICALCCHILDSCROLL, 0, 0L);
|
---|
139 | retvalue = 0;
|
---|
140 | goto END;
|
---|
141 |
|
---|
142 | case WM_MDIMAXIMIZE:
|
---|
143 | ShowWindow( (HWND)wParam, SW_MAXIMIZE );
|
---|
144 | retvalue = 0;
|
---|
145 | goto END;
|
---|
146 |
|
---|
147 | case WM_MDINEXT: /* lParam != 0 means previous window */
|
---|
148 | MDI_SwitchActiveChild(hwnd, (HWND)wParam, (lParam)? FALSE : TRUE );
|
---|
149 | break;
|
---|
150 |
|
---|
151 | case WM_MDIRESTORE:
|
---|
152 | SendMessageA( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0);
|
---|
153 | retvalue = 0;
|
---|
154 | goto END;
|
---|
155 |
|
---|
156 | case WM_MDISETMENU:
|
---|
157 | retvalue = MDISetMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
|
---|
158 | goto END;
|
---|
159 | case WM_MDIREFRESHMENU:
|
---|
160 | retvalue = MDIRefreshMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
|
---|
161 | goto END;
|
---|
162 |
|
---|
163 | case WM_MDITILE:
|
---|
164 | ci->mdiFlags |= MDIF_NEEDUPDATE;
|
---|
165 | ShowScrollBar(hwnd,SB_BOTH,FALSE);
|
---|
166 | MDITile(w, ci, wParam);
|
---|
167 | ci->mdiFlags &= ~MDIF_NEEDUPDATE;
|
---|
168 | retvalue = 0;
|
---|
169 | goto END;
|
---|
170 |
|
---|
171 | case WM_VSCROLL:
|
---|
172 | case WM_HSCROLL:
|
---|
173 | ci->mdiFlags |= MDIF_NEEDUPDATE;
|
---|
174 | ScrollChildren(hwnd, message, wParam, lParam);
|
---|
175 | ci->mdiFlags &= ~MDIF_NEEDUPDATE;
|
---|
176 | retvalue = 0;
|
---|
177 | goto END;
|
---|
178 |
|
---|
179 | case WM_SETFOCUS:
|
---|
180 | if( ci->hwndActiveChild )
|
---|
181 | {
|
---|
182 | WND* pw = WIN_FindWndPtr( ci->hwndActiveChild );
|
---|
183 | if( !(pw->dwStyle & WS_MINIMIZE) )
|
---|
184 | SetFocus( ci->hwndActiveChild );
|
---|
185 | WIN_ReleaseWndPtr(pw);
|
---|
186 | }
|
---|
187 | retvalue = 0;
|
---|
188 | goto END;
|
---|
189 |
|
---|
190 | case WM_NCACTIVATE:
|
---|
191 | if( ci->hwndActiveChild )
|
---|
192 | SendMessageA(ci->hwndActiveChild, message, wParam, lParam);
|
---|
193 | break;
|
---|
194 |
|
---|
195 | case WM_PARENTNOTIFY:
|
---|
196 | if (LOWORD(wParam) == WM_LBUTTONDOWN)
|
---|
197 | {
|
---|
198 | POINT pt = MAKEPOINT(lParam);
|
---|
199 | HWND child = ChildWindowFromPoint(hwnd, pt);
|
---|
200 |
|
---|
201 | if( child && child != hwnd && child != ci->hwndActiveChild )
|
---|
202 | SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
|
---|
203 | }
|
---|
204 | retvalue = 0;
|
---|
205 | goto END;
|
---|
206 |
|
---|
207 | case WM_SIZE:
|
---|
208 | if( IsWindow(ci->hwndChildMaximized) )
|
---|
209 | {
|
---|
210 | WND* child = WIN_FindWndPtr(ci->hwndChildMaximized);
|
---|
211 | RECT rect;
|
---|
212 |
|
---|
213 | rect.left = 0;
|
---|
214 | rect.top = 0;
|
---|
215 | rect.right = LOWORD(lParam);
|
---|
216 | rect.bottom = HIWORD(lParam);
|
---|
217 |
|
---|
218 | AdjustWindowRectEx(&rect, child->dwStyle, 0, child->dwExStyle);
|
---|
219 | MoveWindow(ci->hwndChildMaximized, rect.left, rect.top,
|
---|
220 | rect.right - rect.left, rect.bottom - rect.top, 1);
|
---|
221 | WIN_ReleaseWndPtr(child);
|
---|
222 | }
|
---|
223 | else
|
---|
224 | MDI_PostUpdate(hwnd, ci, SB_BOTH+1);
|
---|
225 |
|
---|
226 | break;
|
---|
227 |
|
---|
228 | case WM_MDICALCCHILDSCROLL:
|
---|
229 | if( (ci->mdiFlags & MDIF_NEEDUPDATE) && ci->sbRecalc )
|
---|
230 | {
|
---|
231 | CalcChildScroll(hwnd, ci->sbRecalc-1);
|
---|
232 | ci->sbRecalc = 0;
|
---|
233 | ci->mdiFlags &= ~MDIF_NEEDUPDATE;
|
---|
234 | }
|
---|
235 | retvalue = 0;
|
---|
236 | goto END;
|
---|
237 | }
|
---|
238 | #endif
|
---|
239 | retvalue = DefWindowProcA(message, wParam, lParam );
|
---|
240 | END:
|
---|
241 | return retvalue;
|
---|
242 | }
|
---|
243 | /**********************************************************************
|
---|
244 | * MDIClientWndProc
|
---|
245 | *
|
---|
246 | * This function handles all MDI requests.
|
---|
247 | */
|
---|
248 | LRESULT WINAPI MDIClientWndProc( HWND hwnd, UINT message, WPARAM wParam,
|
---|
249 | LPARAM lParam )
|
---|
250 | {
|
---|
251 | Win32MDIClientWindow *window;
|
---|
252 |
|
---|
253 | window = (Win32MDIClientWindow *)Win32BaseWindow::GetWindowFromHandle(hwnd);
|
---|
254 | if(!window) {
|
---|
255 | dprintf(("MDIClientWndProc, window %x not found", hwnd));
|
---|
256 | return 0;
|
---|
257 | }
|
---|
258 | return window->MDIClientWndProc(message, wParam, lParam);
|
---|
259 | }
|
---|
260 | //******************************************************************************
|
---|
261 | //******************************************************************************
|
---|
262 | BOOL MDICLIENT_Register()
|
---|
263 | {
|
---|
264 | WNDCLASSA wndClass;
|
---|
265 |
|
---|
266 | if (GlobalFindAtomA(MDICLIENTCLASSNAME)) return FALSE;
|
---|
267 |
|
---|
268 | ZeroMemory(&wndClass,sizeof(WNDCLASSA));
|
---|
269 | wndClass.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW | CS_PARENTDC | CS_DBLCLKS;
|
---|
270 | wndClass.lpfnWndProc = (WNDPROC)MDIClientWndProc;
|
---|
271 | wndClass.cbClsExtra = 0;
|
---|
272 | wndClass.cbWndExtra = 0;
|
---|
273 | wndClass.hCursor = 0;
|
---|
274 | wndClass.hbrBackground = (HBRUSH)0;
|
---|
275 | wndClass.lpszClassName = MDICLIENTCLASSNAME;
|
---|
276 |
|
---|
277 | return RegisterClassA(&wndClass);
|
---|
278 | }
|
---|
279 | //******************************************************************************
|
---|
280 | //******************************************************************************
|
---|
281 | BOOL MDICLIENT_Unregister()
|
---|
282 | {
|
---|
283 | if (GlobalFindAtomA(MDICLIENTCLASSNAME))
|
---|
284 | return UnregisterClassA(MDICLIENTCLASSNAME,(HINSTANCE)NULL);
|
---|
285 | else return FALSE;
|
---|
286 | }
|
---|
287 | //******************************************************************************
|
---|
288 | //******************************************************************************
|
---|