#include <windows.h>
#include <commctrl.h>
#include <string.h>
#include "resource.h"
Go to the source code of this file.
|
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) |
|
◆ ID_MDI_FIRSTCHILD
#define ID_MDI_FIRSTCHILD 50000 |
Definition at line 19 of file mdi.c.
◆ IDC_CHILD_EDIT
Definition at line 17 of file mdi.c.
◆ IDC_MAIN_MDI
Definition at line 13 of file mdi.c.
◆ IDC_MAIN_STATUS
Definition at line 15 of file mdi.c.
◆ IDC_MAIN_TOOL
Definition at line 14 of file mdi.c.
◆ CreateNewMDIChild()
HWND CreateNewMDIChild |
( |
HWND |
hMDIClient | ) |
|
Definition at line 151 of file mdi.c.
152{
155
156 mcs.szTitle =
"[Untitled]";
162
165 {
168 }
170}
static struct myctx * mcs
const char g_szChildClassName[]
#define MDIS_ALLCHILDSTYLES
#define MB_ICONEXCLAMATION
Referenced by WndProc().
◆ DoFileOpen()
Definition at line 95 of file mdi.c.
96{
99
101
104 ofn.
lpstrFilter =
"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
109
111 {
114 {
117
119 }
120 }
121}
#define OFN_FILEMUSTEXIST
BOOL LoadTextFileToEdit(HWND hEdit, LPCTSTR pszFileName)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define SendDlgItemMessage
Referenced by MDIChildWndProc(), and WndProc().
◆ DoFileSave()
Definition at line 123 of file mdi.c.
124{
127
129
132 ofn.
lpstrFilter =
"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
137
139 {
142 {
145
147 }
148 }
149}
#define OFN_OVERWRITEPROMPT
#define OFN_PATHMUSTEXIST
BOOL SaveTextFileFromEdit(HWND hEdit, LPCTSTR pszFileName)
Referenced by MDIChildWndProc().
◆ LoadTextFileToEdit()
Definition at line 24 of file mdi.c.
25{
28
32 {
34
37 {
39
41 if(pszFileText !=
NULL)
42 {
44
46 {
50 }
52 }
53 }
55 }
57}
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
WORD WORD PSZ PSZ pszFileName
Referenced by DoFileOpen().
◆ MDIChildWndProc()
Definition at line 346 of file mdi.c.
347{
349 {
351 {
354
355
356
362
365 }
366 break;
368 {
369 HMENU hMenu, hFileMenu;
371
374 {
376 }
377 else
378 {
380 }
381
384
387
390
392 }
393 break;
396 {
399 break;
402 break;
405 break;
408 break;
411 break;
412 }
413 break;
415 {
418
419
420
422
425 }
427 default:
429
430 }
431 return 0;
432}
void DoFileSave(HWND hwnd)
void DoFileOpen(HWND hwnd)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
HGDIOBJ WINAPI GetStockObject(_In_ int)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI DrawMenuBar(_In_ HWND)
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetMenu(_In_ HWND)
Referenced by SetUpMDIChildWindowClass().
◆ SaveTextFileFromEdit()
Definition at line 59 of file mdi.c.
60{
63
67 {
69
71
72 if(dwTextLength > 0)
73 {
75 DWORD dwBufferSize = dwTextLength + 1;
76
79 {
81 {
83
86 }
88 }
89 }
91 }
93}
#define FILE_ATTRIBUTE_NORMAL
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
#define GetWindowTextLength
Referenced by DoFileSave().
◆ SetUpMDIChildWindowClass()
Definition at line 434 of file mdi.c.
435{
437
450
452 {
453 MessageBox(0,
"Could Not Register Child Window",
"Oh Oh...",
456 }
457 else
459}
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Referenced by WinMain().
◆ WinMain()
Definition at line 462 of file mdi.c.
464{
468
470
483
485 {
488 return 0;
489 }
490
492 return 0;
493
495 0,
497 "MDI Test Application",
501
503 {
506 return 0;
507 }
508
510
513
515 {
517 {
520 }
521 }
523}
VOID WINAPI InitCommonControls(void)
const char g_szClassName[]
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#define WS_OVERLAPPEDWINDOW
TW_UINT32 TW_UINT16 TW_UINT16 MSG
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI TranslateMDISysAccel(_In_ HWND, _In_ LPMSG)
BOOL WINAPI UpdateWindow(_In_ HWND)
◆ WndProc()
Definition at line 172 of file mdi.c.
173{
175 {
177 {
181
183 int statwidths[] = {100, -1};
184
186
187
188
189
192
197
200
201
202
207
208
209
211
215
221
226
231
233
234
235
239
242 }
243 break;
245 {
248 int iToolHeight;
249
252 int iStatusHeight;
253
255 int iMDIHeight;
257
258
259
262
264 iToolHeight = rcTool.
bottom - rcTool.
top;
265
266
267
270
272 iStatusHeight = rcStatus.
bottom - rcStatus.
top;
273
274
275
277
278 iMDIHeight = rcClient.
bottom - iToolHeight - iStatusHeight;
279
282 }
283 break;
286 break;
289 break;
292 {
295 break;
298 break;
300 {
303 {
305 }
306 }
307 break;
309 {
312 {
314 }
315 }
316 break;
319 break;
322 break;
323 default:
324 {
326 {
328 }
329 else
330 {
333 {
335 }
336 }
337 }
338 }
339 break;
340 default:
342 }
343 return 0;
344}
#define ID_WINDOW_CASCADE
#define ID_MDI_FIRSTCHILD
HWND CreateNewMDIChild(HWND hMDIClient)
#define TB_BUTTONSTRUCTSIZE
#define IDB_STD_SMALL_COLOR
SERVICE_STATUS_HANDLE hStatus
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)
Referenced by WinMain().
◆ g_hMainWindow
◆ g_hMDIClient
◆ g_szChildClassName
const char g_szChildClassName[] = "myMDIChildWindowClass" |
◆ g_szClassName