ReactOS 0.4.16-dev-91-g764881a
framewnd.c
Go to the documentation of this file.
1/*
2 * ReactOS Application
3 *
4 * framewnd.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#ifdef _MSC_VER
24#include "stdafx.h"
25#else
26#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
27#include <windows.h>
28#include <commctrl.h>
29#include <stdlib.h>
30#include <malloc.h>
31#include <memory.h>
32#include <tchar.h>
33#include <process.h>
34#include <stdio.h>
35#endif
36
37#include "main.h"
38#include "about.h"
39#include "framewnd.h"
40
41
43// Global Variables:
44//
45
46BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop
47
49// Local module support methods
50//
51
52static void resize_frame_rect(HWND hWnd, PRECT prect)
53{
54 RECT rt;
55
59 prect->top = rt.bottom+3;
60 prect->bottom -= rt.bottom+3;
61 }
63 int parts[] = {300, 500};
64
68 prect->bottom -= rt.bottom;
69 }
70 MoveWindow(hMDIClient, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE);
71}
72
73/* static void resize_frame(HWND hWnd, int cx, int cy)
74{
75 RECT rect = {0, 0, cx, cy};
76
77 resize_frame_rect(hWnd, &rect);
78}*/
79
81{
82 RECT rect;
83
86}
87
89static HHOOK hcbthook;
91
93{
94 if (code == HCBT_CREATEWND && newchild) {
95 ChildWnd* pChildWnd = newchild;
96 newchild = NULL;
97 pChildWnd->hWnd = (HWND)wParam;
98 SetWindowLongPtr(pChildWnd->hWnd, GWLP_USERDATA, (LPARAM)pChildWnd);
99 }
101}
102
103#if 0
104HWND create_child_window(ChildWnd* pChildWnd)
105{
107 szChildClass, (LPTSTR)pChildWnd->path, hInst,
108 pChildWnd->pos.rcNormalPosition.left, pChildWnd->pos.rcNormalPosition.top,
109 pChildWnd->pos.rcNormalPosition.right-pChildWnd->pos.rcNormalPosition.left,
110 pChildWnd->pos.rcNormalPosition.bottom-pChildWnd->pos.rcNormalPosition.top,
111 0/*style*/, 0/*lParam*/
112 };
114 newchild = pChildWnd;
115 pChildWnd->hWnd = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs);
116 if (!pChildWnd->hWnd)
117 return 0;
119 return pChildWnd->hWnd;
120}
121
122#endif
123
124
126{
127 BOOL vis = IsWindowVisible(hchild);
128
131 ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
133}
134
135
137{
138 //TCHAR drv[_MAX_DRIVE];
140 ChildWnd* pChildWnd = NULL;
141/*
142 LPCTSTR root = Globals.drives;
143 int i;
144 for(i = cmd - ID_DRIVE_FIRST; i--; root++)
145 while(*root)
146 root++;
147 if (activate_drive_window(root))
148 return 0;
149 _tsplitpath(root, drv, 0, 0, 0);
150 if (!SetCurrentDirectory(drv)) {
151 display_error(hWnd, GetLastError());
152 return 0;
153 }
154 */
156// pChildWnd = alloc_child_window(path);
157// if (!create_child_window(pChildWnd))
158// free(pChildWnd);
159 pChildWnd = (ChildWnd*)malloc(sizeof(ChildWnd));
160 if (pChildWnd != NULL) {
165 0/*style*/, 0/*lParam*/
166 };
167 memset(pChildWnd, 0, sizeof(ChildWnd));
168 lstrcpy(pChildWnd->szPath, path);
169 pChildWnd->pos.length = sizeof(WINDOWPLACEMENT);
170 pChildWnd->pos.flags = 0;
171 pChildWnd->pos.showCmd = SW_SHOWNORMAL;
176 pChildWnd->nFocusPanel = 0;
177 pChildWnd->nSplitPos = 200;
179 newchild = pChildWnd;
180 pChildWnd->hWnd = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs);
182 if (pChildWnd->hWnd == NULL) {
183 free(pChildWnd);
184 newchild = pChildWnd = NULL;
185 }
186 return pChildWnd->hWnd;
187 }
188 return 0;
189}
190
192{
193 if (!GetWindow(hWnd, GW_OWNER)) {
195 if (SendMessage(hWnd, WM_QUERYENDSESSION, 0, 0)) {
197 }
198 }
199 return 1;
200}
201
203{
204 int nParts;
205
206 // Update the status bar pane sizes
207 nParts = -1;
211}
212
214{
215 RECT rc;
216 int nParts[3];
217
219 // Update the status bar pane sizes
220 GetClientRect(hWnd, &rc);
221 nParts[0] = 100;
222 nParts[1] = 210;
223 nParts[2] = rc.right;
227}
228
229void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
230{
231 TCHAR str[100];
232
233 strcpy(str, TEXT(""));
234 if (nFlags & MF_POPUP) {
235 if (hSysMenu != GetMenu(hWnd)) {
236 if (nItemID == 2) nItemID = 5;
237 }
238 }
239 if (LoadString(hInst, nItemID, str, 100)) {
240 // load appropriate string
241 LPTSTR lpsz = str;
242 // first newline terminates actual string
243 lpsz = _tcschr(lpsz, '\n');
244 if (lpsz != NULL)
245 *lpsz = '\0';
246 }
248}
249
251//
252// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
253//
254// PURPOSE: Processes WM_COMMAND messages for the main frame window.
255//
256//
257
259{
260 HWND hChildWnd;
261
262 if (1) {
263
264 switch (LOWORD(wParam)) {
267 break;
268 case ID_WINDOW_CLOSE:
269 hChildWnd = (HWND) SendMessage(hMDIClient, WM_MDIGETACTIVE, 0, 0);
270 if (!SendMessage(hChildWnd, WM_QUERYENDSESSION, 0, 0))
272 break;
273 case ID_FILE_EXIT:
274 SendMessage(hWnd, WM_CLOSE, 0, 0);
275 break;
278 break;
281 break;
282
283 case ID_FILE_OPEN:
285 InitChildWindow("Child Window");
286 return 0;
289 break;
292 break;
295 break;
298 break;
299 case ID_HELP_ABOUT:
301 break;
302 default:
303 hChildWnd = (HWND)SendMessage(hMDIClient, WM_MDIGETACTIVE, 0, 0);
304 if (IsWindow(hChildWnd))
305 SendMessage(hChildWnd, WM_COMMAND, wParam, lParam);
306 else
308 }
309 }
310 return 0;
311}
312
314//
315// FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
316//
317// PURPOSE: Processes messages for the main frame window.
318//
319// WM_COMMAND - process the application menu
320// WM_DESTROY - post a quit message and return
321//
322//
323
325{
326 switch (message) {
327 case WM_CREATE:
328 {
330 CLIENTCREATESTRUCT ccs = { hMenuWindow, IDW_FIRST_CHILD };
331#if 0
332 hMDIClient = CreateWindow(_T("MDICLIENT"), NULL,
334 0, 0, 0, 0,
335 hWnd, (HMENU)1, hInst, &ccs);
336#else
337 hMDIClient = CreateWindowEx(0, _T("MDICLIENT"), NULL,
338// hMDIClient = CreateWindowEx(0, (LPCTSTR)(int)hChildWndClass, NULL,
340 0, 0, 0, 0,
341 hWnd, (HMENU)0, hInst, &ccs);
342#endif
343 }
344 break;
345 case WM_COMMAND:
347 break;
348 case WM_SIZE:
350 break;
351 case WM_ENTERMENULOOP:
353 break;
354 case WM_EXITMENULOOP:
356 break;
357 case WM_MENUSELECT:
359 break;
360 case WM_DESTROY:
362 break;
364 case WM_CLOSE:
367 return 0;
368 // else fall thru...
369 default:
371 }
372 return 0;
373}
374
375
std::map< E_STRING, PART_TEST > parts
Definition: LocaleTests.cpp:67
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static struct myctx * mcs
Definition: adnstest.c:53
HWND hWnd
Definition: settings.c:17
void ShowAboutBox(HWND hWnd)
Definition: about.c:12
static void resize_frame_client(HWND hWnd)
Definition: framewnd.c:42
static void OnEnterMenuLoop(HWND hWnd)
Definition: framewnd.c:109
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
Definition: framewnd.c:129
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1127
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
Definition: framewnd.c:173
void UpdateStatusBar(void)
Definition: framewnd.c:165
static void OnExitMenuLoop(HWND hWnd)
Definition: framewnd.c:121
static BOOL bInMenuLoop
Definition: framewnd.c:16
static void resize_frame_rect(HWND hWnd, PRECT prect)
Definition: framewnd.c:29
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:1440
HMENU hMenuFrame
Definition: main.c:24
WCHAR szChildClass[MAX_LOADSTRING]
Definition: main.c:32
HWND hStatusBar
Definition: main.c:23
#define ID_HELP_ABOUT
Definition: resource.h:61
#define ID_FILE_EXIT
Definition: resource.h:46
#define ID_FILE_OPEN
Definition: resource.h:41
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HANDLE HWND
Definition: compat.h:19
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
HINSTANCE hInst
Definition: dxdiag.c:13
#define IDW_FIRST_CHILD
Definition: explorer.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
GLfloat param
Definition: glext.h:5796
#define _tcschr
Definition: tchar.h:1406
#define TEXT(s)
Definition: k32.h:26
#define ID_WINDOW_TILE_VERT
Definition: resource.h:49
#define ID_WINDOW_TILE_HORZ
Definition: resource.h:48
#define ID_WINDOW_CASCADE
Definition: resource.h:50
static HHOOK hcbthook
Definition: framewnd.c:89
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
Definition: framewnd.c:92
BOOL CALLBACK CloseEnumProc(HWND hWnd, LPARAM lParam)
Definition: framewnd.c:191
static HWND InitChildWindow(LPTSTR param)
Definition: framewnd.c:136
static ChildWnd * newchild
Definition: framewnd.c:90
HWND hMDIClient
Definition: main.c:49
#define ID_OPTIONS_TOOLBAR
Definition: resource.h:40
#define ID_WINDOW_ARRANGE_ICONS
Definition: resource.h:48
#define ID_OPTIONS_STATUSBAR
Definition: resource.h:41
#define ID_OPTIONS_MENU
Definition: resource.h:8
#define ID_WINDOW_CLOSE
Definition: resource.h:32
#define ID_WINDOW_CLOSEALL
Definition: resource.h:33
#define ID_WINDOW_NEW_WINDOW
Definition: resource.h:44
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
HWND hToolBar
Definition: mplay32.c:23
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_BORDER
Definition: pedump.c:625
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define SB_SETTEXT
Definition: commctrl.h:1954
#define SB_SETPARTS
Definition: commctrl.h:1959
#define DefFrameProc
Definition: ros2win.h:32
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
& rect
Definition: startmenu.cpp:1413
Definition: main.h:48
int nSplitPos
Definition: main.h:56
WCHAR szPath[MAX_PATH]
Definition: main.h:58
int nFocusPanel
Definition: main.h:55
WINDOWPLACEMENT pos
Definition: main.h:57
HWND hWnd
Definition: main.h:49
RECT rcNormalPosition
Definition: winuser.h:3298
Definition: ftp_var.h:139
Definition: inflate.c:139
Definition: tftpd.h:60
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_USERDATA
Definition: treelist.c:63
#define HIWORD(l)
Definition: typedefs.h:247
#define _T(x)
Definition: vfdio.h:22
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
#define lstrcpy
Definition: winbase.h:3874
#define GetCurrentDirectory
Definition: winbase.h:3805
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define SW_SHOWNORMAL
Definition: winuser.h:773
#define GW_OWNER
Definition: winuser.h:769
#define WM_MDITILE
Definition: winuser.h:1821
#define CreateWindowEx
Definition: winuser.h:5767
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SW_HIDE
Definition: winuser.h:771
#define WM_CLOSE
Definition: winuser.h:1624
#define MF_BYCOMMAND
Definition: winuser.h:202
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define WM_MDICREATE
Definition: winuser.h:1815
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define WM_MDICASCADE
Definition: winuser.h:1822
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_SIZE
Definition: winuser.h:1614
#define WM_COMMAND
Definition: winuser.h:1743
#define MF_CHECKED
Definition: winuser.h:132
#define WH_CBT
Definition: winuser.h:35
#define SetWindowsHookEx
Definition: winuser.h:5868
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
#define MF_POPUP
Definition: winuser.h:136
#define HCBT_CREATEWND
Definition: winuser.h:58
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define CreateWindow
Definition: winuser.h:5766
#define WM_MDIICONARRANGE
Definition: winuser.h:1823
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_ENTERMENULOOP
Definition: winuser.h:1807
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define WM_MDIDESTROY
Definition: winuser.h:1816
#define WM_QUERYENDSESSION
Definition: winuser.h:1625
#define SendMessage
Definition: winuser.h:5855
#define WM_EXITMENULOOP
Definition: winuser.h:1808
#define CW_USEDEFAULT
Definition: winuser.h:225
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define LoadString
Definition: winuser.h:5831
#define SW_SHOW
Definition: winuser.h:778
#define MDITILE_HORIZONTAL
Definition: winuser.h:2191
#define WM_DESTROY
Definition: winuser.h:1612
#define WM_MDIGETACTIVE
Definition: winuser.h:1824
#define GW_CHILD
Definition: winuser.h:766
#define MDITILE_VERTICAL
Definition: winuser.h:2192
struct _WINDOWPLACEMENT WINDOWPLACEMENT
#define WM_MENUSELECT
Definition: winuser.h:1750
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
HMENU WINAPI GetMenu(_In_ HWND)
#define WM_MDIRESTORE
Definition: winuser.h:1818
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192