ReactOS 0.4.15-dev-7906-g1b85a5f
mdi.c File Reference
#include <windows.h>
#include <commctrl.h>
#include <string.h>
#include "resource.h"
Include dependency graph for mdi.c:

Go to the source code of this file.

Macros

#define IDC_MAIN_MDI   101
 
#define IDC_MAIN_TOOL   102
 
#define IDC_MAIN_STATUS   103
 
#define IDC_CHILD_EDIT   101
 
#define ID_MDI_FIRSTCHILD   50000
 

Functions

BOOL LoadTextFileToEdit (HWND hEdit, LPCTSTR pszFileName)
 
BOOL SaveTextFileFromEdit (HWND hEdit, LPCTSTR pszFileName)
 
void DoFileOpen (HWND hwnd)
 
void DoFileSave (HWND hwnd)
 
HWND CreateNewMDIChild (HWND hMDIClient)
 
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK MDIChildWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
BOOL SetUpMDIChildWindowClass (HINSTANCE hInstance)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 

Variables

const char g_szClassName [] = "myWindowClass"
 
const char g_szChildClassName [] = "myMDIChildWindowClass"
 
HWND g_hMDIClient = NULL
 
HWND g_hMainWindow = NULL
 

Macro Definition Documentation

◆ ID_MDI_FIRSTCHILD

#define ID_MDI_FIRSTCHILD   50000

Definition at line 19 of file mdi.c.

◆ IDC_CHILD_EDIT

#define IDC_CHILD_EDIT   101

Definition at line 17 of file mdi.c.

◆ IDC_MAIN_MDI

#define IDC_MAIN_MDI   101

Definition at line 13 of file mdi.c.

◆ IDC_MAIN_STATUS

#define IDC_MAIN_STATUS   103

Definition at line 15 of file mdi.c.

◆ IDC_MAIN_TOOL

#define IDC_MAIN_TOOL   102

Definition at line 14 of file mdi.c.

Function Documentation

◆ CreateNewMDIChild()

HWND CreateNewMDIChild ( HWND  hMDIClient)

Definition at line 151 of file mdi.c.

152{
154 HWND hChild;
155
156 mcs.szTitle = "[Untitled]";
157 mcs.szClass = g_szChildClassName;
158 mcs.hOwner = GetModuleHandle(NULL);
159 mcs.x = mcs.cx = CW_USEDEFAULT;
160 mcs.y = mcs.cy = CW_USEDEFAULT;
161 mcs.style = MDIS_ALLCHILDSTYLES;
162
164 if(!hChild)
165 {
166 MessageBox(hMDIClient, "MDI Child creation failed.", "Oh Oh...",
168 }
169 return hChild;
170}
static struct myctx * mcs
Definition: adnstest.c:53
#define NULL
Definition: types.h:112
HANDLE HWND
Definition: compat.h:19
HWND hMDIClient
Definition: main.c:49
const char g_szChildClassName[]
Definition: mdi.c:11
static HTREEITEM hChild
Definition: treeview.c:381
#define GetModuleHandle
Definition: winbase.h:3827
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_MDICREATE
Definition: winuser.h:1812
#define MDIS_ALLCHILDSTYLES
Definition: winuser.h:253
#define SendMessage
Definition: winuser.h:5843
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790
#define CW_USEDEFAULT
Definition: winuser.h:225
#define MessageBox
Definition: winuser.h:5822

Referenced by WndProc().

◆ DoFileOpen()

void DoFileOpen ( HWND  hwnd)

Definition at line 95 of file mdi.c.

96{
98 char szFileName[MAX_PATH] = "";
99
100 ZeroMemory(&ofn, sizeof(ofn));
101
102 ofn.lStructSize = sizeof(ofn);
104 ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
105 ofn.lpstrFile = szFileName;
108 ofn.lpstrDefExt = "txt";
109
110 if(GetOpenFileName(&ofn))
111 {
113 if(LoadTextFileToEdit(hEdit, szFileName))
114 {
117
118 SetWindowText(hwnd, szFileName);
119 }
120 }
121}
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define GetOpenFileName
Definition: commdlg.h:665
#define MAX_PATH
Definition: compat.h:34
#define IDC_CHILD_EDIT
Definition: mdi.c:17
HWND g_hMainWindow
Definition: mdi.c:22
#define IDC_MAIN_STATUS
Definition: mdi.c:15
BOOL LoadTextFileToEdit(HWND hEdit, LPCTSTR pszFileName)
Definition: mdi.c:24
#define SB_SETTEXT
Definition: commctrl.h:1949
static HWND hEdit
Definition: autocomplete.c:34
OPENFILENAME ofn
Definition: sndrec32.cpp:56
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SetWindowText
Definition: winuser.h:5857
#define SendDlgItemMessage
Definition: winuser.h:5842

Referenced by MDIChildWndProc(), and WndProc().

◆ DoFileSave()

void DoFileSave ( HWND  hwnd)

Definition at line 123 of file mdi.c.

124{
126 char szFileName[MAX_PATH] = "";
127
128 ZeroMemory(&ofn, sizeof(ofn));
129
130 ofn.lStructSize = sizeof(ofn);
132 ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
133 ofn.lpstrFile = szFileName;
135 ofn.lpstrDefExt = "txt";
137
138 if(GetSaveFileName(&ofn))
139 {
141 if(SaveTextFileFromEdit(hEdit, szFileName))
142 {
145
146 SetWindowText(hwnd, szFileName);
147 }
148 }
149}
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL SaveTextFileFromEdit(HWND hEdit, LPCTSTR pszFileName)
Definition: mdi.c:59

Referenced by MDIChildWndProc().

◆ LoadTextFileToEdit()

BOOL LoadTextFileToEdit ( HWND  hEdit,
LPCTSTR  pszFileName 
)

Definition at line 24 of file mdi.c.

25{
28
32 {
34
36 if(dwFileSize != 0xFFFFFFFF)
37 {
38 LPSTR pszFileText;
39
40 pszFileText = GlobalAlloc(GPTR, dwFileSize + 1);
41 if(pszFileText != NULL)
42 {
43 DWORD dwRead;
44
45 if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL))
46 {
47 pszFileText[dwFileSize] = 0; // Add null terminator
48 if(SetWindowText(hEdit, pszFileText))
49 bSuccess = TRUE; // It worked!
50 }
51 GlobalFree(pszFileText);
52 }
53 }
55 }
56 return bSuccess;
57}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
DWORD dwFileSize
Definition: more.c:40
_In_ HANDLE hFile
Definition: mswsock.h:90
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define GPTR
Definition: winbase.h:296
#define CreateFile
Definition: winbase.h:3749
char * LPSTR
Definition: xmlstorage.h:182

Referenced by DoFileOpen().

◆ MDIChildWndProc()

LRESULT CALLBACK MDIChildWndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 346 of file mdi.c.

347{
348 switch(msg)
349 {
350 case WM_CREATE:
351 {
352 HFONT hfDefault;
353 HWND hEdit;
354
355 // Create Edit Control
356
359 0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
360 if(hEdit == NULL)
361 MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
362
363 hfDefault = GetStockObject(DEFAULT_GUI_FONT);
365 }
366 break;
367 case WM_MDIACTIVATE:
368 {
369 HMENU hMenu, hFileMenu;
370 UINT EnableFlag;
371
372 hMenu = GetMenu(g_hMainWindow);
373 if(hwnd == (HWND)lParam)
374 { //being activated, enable the menus
375 EnableFlag = MF_ENABLED;
376 }
377 else
378 { //being de-activated, gray the menus
379 EnableFlag = MF_GRAYED;
380 }
381
382 EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag);
383 EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag);
384
385 hFileMenu = GetSubMenu(hMenu, 0);
386 EnableMenuItem(hFileMenu, ID_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag);
387
388 EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag);
389 EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, MF_BYCOMMAND | EnableFlag);
390
392 }
393 break;
394 case WM_COMMAND:
395 switch(LOWORD(wParam))
396 {
397 case ID_FILE_OPEN:
399 break;
400 case ID_FILE_SAVEAS:
402 break;
403 case ID_EDIT_CUT:
405 break;
406 case ID_EDIT_COPY:
408 break;
409 case ID_EDIT_PASTE:
411 break;
412 }
413 break;
414 case WM_SIZE:
415 {
416 HWND hEdit;
417 RECT rcClient;
418
419 // Calculate remaining height and size edit
420
421 GetClientRect(hwnd, &rcClient);
422
424 SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
425 }
427 default:
429
430 }
431 return 0;
432}
#define msg(x)
Definition: auth_time.c:54
#define ID_EDIT_COPY
Definition: resource.h:48
#define ID_EDIT_PASTE
Definition: resource.h:49
#define ID_FILE_OPEN
Definition: resource.h:41
#define ID_FILE_SAVEAS
Definition: resource.h:43
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define ID_FILE_CLOSE
Definition: resource.h:39
void DoFileSave(HWND hwnd)
Definition: mdi.c:123
void DoFileOpen(HWND hwnd)
Definition: mdi.c:95
#define ID_FILE_CLOSEALL
Definition: resource.h:13
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define WS_VSCROLL
Definition: pedump.c:627
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_HSCROLL
Definition: pedump.c:628
#define ES_MULTILINE
Definition: pedump.c:667
#define DefMDIChildProc
Definition: ros2win.h:33
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
UINT_PTR WPARAM
Definition: windef.h:207
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
#define CreateWindowEx
Definition: winuser.h:5755
#define MF_BYCOMMAND
Definition: winuser.h:202
#define WM_PASTE
Definition: winuser.h:1863
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define WM_CREATE
Definition: winuser.h:1608
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define WM_SIZE
Definition: winuser.h:1611
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_CUT
Definition: winuser.h:1861
#define WM_MDIACTIVATE
Definition: winuser.h:1814
#define MB_ICONERROR
Definition: winuser.h:787
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MF_ENABLED
Definition: winuser.h:128
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define WM_SETFONT
Definition: winuser.h:1650
#define MF_BYPOSITION
Definition: winuser.h:203
#define WM_COPY
Definition: winuser.h:1862
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SWP_NOZORDER
Definition: winuser.h:1247
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetMenu(_In_ HWND)
#define MF_GRAYED
Definition: winuser.h:129
#define ID_EDIT_CUT
Definition: wordpad.h:72

Referenced by SetUpMDIChildWindowClass().

◆ SaveTextFileFromEdit()

BOOL SaveTextFileFromEdit ( HWND  hEdit,
LPCTSTR  pszFileName 
)

Definition at line 59 of file mdi.c.

60{
63
67 {
68 DWORD dwTextLength;
69
70 dwTextLength = GetWindowTextLength(hEdit);
71 // No need to bother if there's no text.
72 if(dwTextLength > 0)
73 {
74 LPSTR pszText;
75 DWORD dwBufferSize = dwTextLength + 1;
76
77 pszText = GlobalAlloc(GPTR, dwBufferSize);
78 if(pszText != NULL)
79 {
80 if(GetWindowText(hEdit, pszText, dwBufferSize))
81 {
82 DWORD dwWritten;
83
84 if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL))
85 bSuccess = TRUE;
86 }
87 GlobalFree(pszText);
88 }
89 }
91 }
92 return bSuccess;
93}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
#define GetWindowTextLength
Definition: winuser.h:5799
#define GetWindowText
Definition: winuser.h:5798

Referenced by DoFileSave().

◆ SetUpMDIChildWindowClass()

BOOL SetUpMDIChildWindowClass ( HINSTANCE  hInstance)

Definition at line 434 of file mdi.c.

435{
436 WNDCLASSEX wc;
437
438 wc.cbSize = sizeof(WNDCLASSEX);
441 wc.cbClsExtra = 0;
442 wc.cbWndExtra = 0;
443 wc.hInstance = hInstance;
446 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE+1);
447 wc.lpszMenuName = NULL;
450
451 if(!RegisterClassEx(&wc))
452 {
453 MessageBox(0, "Could Not Register Child Window", "Oh Oh...",
455 return FALSE;
456 }
457 else
458 return TRUE;
459}
HINSTANCE hInstance
Definition: charmap.c:19
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: mdi.c:346
int cbClsExtra
Definition: winuser.h:3204
HINSTANCE hInstance
Definition: winuser.h:3206
HCURSOR hCursor
Definition: winuser.h:3208
LPCSTR lpszMenuName
Definition: winuser.h:3210
HICON hIconSm
Definition: winuser.h:3212
UINT style
Definition: winuser.h:3202
int cbWndExtra
Definition: winuser.h:3205
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3207
HBRUSH hbrBackground
Definition: winuser.h:3209
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define RegisterClassEx
Definition: winuser.h:5837
#define LoadIcon
Definition: winuser.h:5813
#define LoadCursor
Definition: winuser.h:5812
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5719
#define COLOR_3DFACE
Definition: winuser.h:929
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 462 of file mdi.c.

464{
465 WNDCLASSEX wc;
466 HWND hwnd;
467 MSG Msg;
468
470
471 wc.cbSize = sizeof(WNDCLASSEX);
472 wc.style = 0;
473 wc.lpfnWndProc = WndProc;
474 wc.cbClsExtra = 0;
475 wc.cbWndExtra = 0;
476 wc.hInstance = hInstance;
479 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
483
484 if(!RegisterClassEx(&wc))
485 {
486 MessageBox(NULL, "Window Registration Failed!", "Error!",
488 return 0;
489 }
490
492 return 0;
493
495 0,
497 "MDI Test Application",
499 CW_USEDEFAULT, CW_USEDEFAULT, 480, 320,
501
502 if(hwnd == NULL)
503 {
504 MessageBox(NULL, "Window Creation Failed!", "Error!",
506 return 0;
507 }
508
510
511 ShowWindow(hwnd, nCmdShow);
513
514 while(GetMessage(&Msg, NULL, 0, 0) > 0)
515 {
517 {
520 }
521 }
522 return Msg.wParam;
523}
#define IDR_MAINMENU
Definition: resource.h:40
struct @1632 Msg[]
VOID WINAPI InitCommonControls(void)
Definition: commctrl.c:863
const char g_szClassName[]
Definition: mdi.c:10
HWND g_hMDIClient
Definition: mdi.c:21
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
Definition: mdi.c:434
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: mdi.c:172
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_CLIPCHILDREN
Definition: pedump.c:619
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:918
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define GetMessage
Definition: winuser.h:5790
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
BOOL WINAPI UpdateWindow(_In_ HWND)
#define DispatchMessage
Definition: winuser.h:5765
#define MAKEINTRESOURCE
Definition: winuser.h:591

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 172 of file mdi.c.

173{
174 switch(msg)
175 {
176 case WM_CREATE:
177 {
178 HWND hTool;
179 TBBUTTON tbb[3];
180 TBADDBITMAP tbab;
181
183 int statwidths[] = {100, -1};
184
186
187 // Create MDI Client
188
189 // Find window menu where children will be listed
192
197
198 if(g_hMDIClient == NULL)
199 MessageBox(hwnd, "Could not create MDI client.", "Error", MB_OK | MB_ICONERROR);
200
201 // Create Toolbar
202
203 hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
205 if(hTool == NULL)
206 MessageBox(hwnd, "Could not create tool bar.", "Error", MB_OK | MB_ICONERROR);
207
208 // Send the TB_BUTTONSTRUCTSIZE message, which is required for
209 // backward compatibility.
210 SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
211
212 tbab.hInst = HINST_COMMCTRL;
214 SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);
215
216 ZeroMemory(tbb, sizeof(tbb));
217 tbb[0].iBitmap = STD_FILENEW;
218 tbb[0].fsState = TBSTATE_ENABLED;
219 tbb[0].fsStyle = TBSTYLE_BUTTON;
220 tbb[0].idCommand = ID_FILE_NEW;
221
222 tbb[1].iBitmap = STD_FILEOPEN;
223 tbb[1].fsState = TBSTATE_ENABLED;
224 tbb[1].fsStyle = TBSTYLE_BUTTON;
225 tbb[1].idCommand = ID_FILE_OPEN;
226
227 tbb[2].iBitmap = STD_FILESAVE;
228 tbb[2].fsState = TBSTATE_ENABLED;
229 tbb[2].fsStyle = TBSTYLE_BUTTON;
230 tbb[2].idCommand = ID_FILE_SAVEAS;
231
232 SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
233
234 // Create Status bar
235
237 WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0,
239
240 SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
241 SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Hi there :)");
242 }
243 break;
244 case WM_SIZE:
245 {
246 HWND hTool;
247 RECT rcTool;
248 int iToolHeight;
249
251 RECT rcStatus;
252 int iStatusHeight;
253
254 HWND hMDI;
255 int iMDIHeight;
256 RECT rcClient;
257
258 // Size toolbar and get height
259
260 hTool = GetDlgItem(hwnd, IDC_MAIN_TOOL);
261 SendMessage(hTool, TB_AUTOSIZE, 0, 0);
262
263 GetWindowRect(hTool, &rcTool);
264 iToolHeight = rcTool.bottom - rcTool.top;
265
266 // Size status bar and get height
267
270
271 GetWindowRect(hStatus, &rcStatus);
272 iStatusHeight = rcStatus.bottom - rcStatus.top;
273
274 // Calculate remaining height and size edit
275
276 GetClientRect(hwnd, &rcClient);
277
278 iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
279
281 SetWindowPos(hMDI, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
282 }
283 break;
284 case WM_CLOSE:
286 break;
287 case WM_DESTROY:
289 break;
290 case WM_COMMAND:
291 switch(LOWORD(wParam))
292 {
293 case ID_FILE_EXIT:
294 PostMessage(hwnd, WM_CLOSE, 0, 0);
295 break;
296 case ID_FILE_NEW:
298 break;
299 case ID_FILE_OPEN:
300 {
302 if(hChild)
303 {
305 }
306 }
307 break;
308 case ID_FILE_CLOSE:
309 {
311 if(hChild)
312 {
314 }
315 }
316 break;
317 case ID_WINDOW_TILE:
319 break;
322 break;
323 default:
324 {
326 {
328 }
329 else
330 {
332 if(hChild)
333 {
335 }
336 }
337 }
338 }
339 break;
340 default:
342 }
343 return 0;
344}
#define ID_WINDOW_TILE
Definition: resource.h:77
#define ID_WINDOW_CASCADE
Definition: resource.h:76
#define ID_FILE_EXIT
Definition: resource.h:46
#define ID_FILE_NEW
Definition: resource.h:40
#define IDC_MAIN_MDI
Definition: mdi.c:13
#define ID_MDI_FIRSTCHILD
Definition: mdi.c:19
#define IDC_MAIN_TOOL
Definition: mdi.c:14
HWND CreateNewMDIChild(HWND hMDIClient)
Definition: mdi.c:151
#define TB_ADDBUTTONS
Definition: commctrl.h:1271
#define TB_AUTOSIZE
Definition: commctrl.h:1137
#define STD_FILENEW
Definition: commctrl.h:1077
#define HINST_COMMCTRL
Definition: commctrl.h:1063
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TBSTYLE_BUTTON
Definition: commctrl.h:981
#define STD_FILEOPEN
Definition: commctrl.h:1078
#define STD_FILESAVE
Definition: commctrl.h:1079
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TOOLBARCLASSNAME
Definition: commctrl.h:946
#define SB_SETPARTS
Definition: commctrl.h:1954
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define STATUSCLASSNAME
Definition: commctrl.h:1939
#define TB_ADDBITMAP
Definition: commctrl.h:1056
#define IDB_STD_SMALL_COLOR
Definition: commctrl.h:1064
#define DefFrameProc
Definition: ros2win.h:32
BYTE fsState
Definition: commctrl.h:951
int idCommand
Definition: commctrl.h:950
int iBitmap
Definition: commctrl.h:949
BYTE fsStyle
Definition: commctrl.h:952
LONG top
Definition: windef.h:307
UINT_PTR nID
Definition: commctrl.h:1060
HINSTANCE hInst
Definition: commctrl.h:1059
SERVICE_STATUS_HANDLE hStatus
Definition: w32time.c:14
#define WM_MDITILE
Definition: winuser.h:1818
#define WM_CLOSE
Definition: winuser.h:1621
#define WM_MDICASCADE
Definition: winuser.h:1819
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define PostMessage
Definition: winuser.h:5832
#define WM_DESTROY
Definition: winuser.h:1609
#define WM_MDIGETACTIVE
Definition: winuser.h:1821
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by WinMain().

Variable Documentation

◆ g_hMainWindow

HWND g_hMainWindow = NULL

Definition at line 22 of file mdi.c.

Referenced by DoFileOpen(), DoFileSave(), MDIChildWndProc(), and WinMain().

◆ g_hMDIClient

HWND g_hMDIClient = NULL

Definition at line 21 of file mdi.c.

Referenced by WinMain(), and WndProc().

◆ g_szChildClassName

const char g_szChildClassName[] = "myMDIChildWindowClass"

Definition at line 11 of file mdi.c.

Referenced by CreateNewMDIChild(), and SetUpMDIChildWindowClass().

◆ g_szClassName

const char g_szClassName[] = "myWindowClass"

Definition at line 10 of file mdi.c.

Referenced by WinMain().