-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmdichld.cpp
77 lines (66 loc) · 2.31 KB
/
tmdichld.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
TMDICHLD.CPP
Copyright (c) 1994 Shawn Halpenny
All rights reserved.
Source code module for TMDIChild class.
*/
#ifndef __WOLF_H
#include <wolf.h>
#endif
//done
TMDIChild::TMDIChild(PTMDIFrame pParent, LPCSTR lpszTitle) : TWindow(pParent, lpszTitle, 0)
{
ChildData.hOwner = pApplication->hInstance;
ChildData.lParam = NULL;
//default child style (is copied to ChildData.style when Create is called)
dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
bCreated = FALSE;
} //TMDIChild::TMDIChild
//done
LONG TMDIChild::DefMsgHandler(RTMessage Msg)
{
return DefMDIChildProc(Msg.hWindow, Msg.wMsg, Msg.wParam, Msg.lParam);
} //TMDIChild::DefMsgHandler
//done
BOOL TMDIChild::Create()
{
Register(); //okay to register all the time
if (!bCreated)
{
SetGlobalWindowObject(this);
ChildData.szClass = WndClass.lpszClassName;
ChildData.szTitle = lpszWindowText;
ChildData.x = x;
ChildData.y = y;
ChildData.cx = cx;
ChildData.cy = cy;
ChildData.style = dwStyle;
hWindow = (HWND) LOWORD(SendMessage(((PTMDIFrame) pParent)->pClient->hWindow, WM_MDICREATE, 0, (LONG) &ChildData));
nID = GetWindowWord(hWindow, GWW_ID); //it is set internally to ID_FIRSTMDICHILD+n
bCreated = TRUE;
return (BOOL) hWindow;
}
return FALSE;
} //TMDIChild::Create
//done
void TMDIChild::WMMDIActivate(RTMessage Msg)
{
if (Msg.wParam && WndClass.lpszMenuName)
{
HMENU hMenu = LoadMenu(pApplication->hInstance, WndClass.lpszMenuName);
SendMessage(((PTMDIFrame) pParent)->pClient->hWindow, WM_MDISETMENU, 0, MAKELONG(hMenu, GetSubMenu(hMenu, nChildMenuPos)));
DrawMenuBar(pParent->hWindow);
}
} //TMDIChild::WMMDIActivate
void TMDIChild::WMNCDestroy(RTMessage Msg)
{
//switch frame window menu back to initial menu if it exists and this is last child wnd
if (pParent->WndClass.lpszMenuName && !LOWORD(SendMessage(((PTMDIFrame) pParent)->pClient->hWindow, WM_MDIGETACTIVE, 0, 0)))
{
HMENU hMenu = LoadMenu(pApplication->hInstance, pParent->WndClass.lpszMenuName);
SendMessage(((PTMDIFrame) pParent)->pClient->hWindow, WM_MDISETMENU, 0, MAKELONG(hMenu, GetSubMenu(hMenu, nChildMenuPos)));
DrawMenuBar(pParent->hWindow);
}
TWindowObject::WMNCDestroy(Msg);
delete this;
} //TMDIChild::WMNCDestroy