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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
#include "StdAfx.h"
#include "T2DLL/T2DlgItemAnimation.h"
#include "T2DLL/T2ImageObj.h"
#include "T2MsgWindow.h"
#include "T2MWControl.h"
#include "T2TowerDoc.h"
#include "T2DLL/T2WorldDef.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#line 19
IMPLEMENT_DYNCREATE(T2MsgWindow, CFrameWnd)
T2MsgWindow::T2MsgWindow() {
#line 23
mClockControl = new T2MWControl;
mCalendarControl = new T2MWControl;
mFundsControl = new T2MWControl;
#line 30
mPopulationControl = new T2MWControl;
mMessageControl = new T2MWControl;
mDocument = NULL;
mWorldDef = NULL;
mIsSetUp = false;
}
/*virtual*/ T2MsgWindow::~T2MsgWindow() {
delete mClockControl;
delete mCalendarControl;
delete mFundsControl;
delete mPopulationControl;
delete mMessageControl;
}
BEGIN_MESSAGE_MAP(T2MsgWindow, CFrameWnd)
//{{AFX_MSG_MAP(T2MsgWindow)
ON_WM_QUERYNEWPALETTE()
ON_WM_ERASEBKGND()
ON_WM_CREATE()
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void T2MsgWindow::SetDocument(T2TowerDoc *inDoc) {
mDocument = inDoc;
mWorldDef = inDoc->mWorldDef;
mWndClass = AfxRegisterWndClass(CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH));
RECT rect;
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Clock", 0), rect);
mClockControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1000);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Calendar", 0), rect);
mCalendarControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1001);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Funds", 0), rect);
mFundsControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1002);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Population", 0), rect);
mPopulationControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1003);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Message", 0), rect);
mMessageControl->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect, this, 1004);
mWorldDef->mImageObj->GetObjectImage(mWorldDef->mImageObj->FindObject("Grade", 0), rect);
#line 80
mGradeControl = new T2DlgItemAnimation(mDocument, NULL, mWorldDef->GetPalette());
mGradeControl->Create("", WS_CLIPCHILDREN | WS_VISIBLE | WS_CHILD, rect, this, 1005);
mClockControl->Setup(inDoc);
mCalendarControl->Setup(inDoc);
mFundsControl->Setup(inDoc);
mPopulationControl->Setup(inDoc);
mMessageControl->Setup(inDoc);
mToolTip.Create(this, TTS_ALWAYSTIP | TTS_NOPREFIX);
mToolTip.AddTool(mClockControl);
mToolTip.AddTool(mCalendarControl);
mToolTip.AddTool(mFundsControl);
mToolTip.AddTool(mPopulationControl);
mToolTip.AddTool(mMessageControl);
mToolTip.Activate(true);
mIsSetUp = true;
InvalidateRect(NULL);
}
int T2MsgWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) {
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
RECT windowRect, clientRect;
GetWindowRect(&windowRect);
GetClientRect(&clientRect);
SetWindowPos(NULL,
0,
0,
(windowRect.right - windowRect.left) - clientRect.right + 512,
(windowRect.bottom - windowRect.top) - clientRect.bottom + 44,
SWP_NOMOVE | SWP_NOZORDER
);
return 0;
}
BOOL T2MsgWindow::OnQueryNewPalette() {
return CFrameWnd::OnQueryNewPalette();
}
BOOL T2MsgWindow::OnEraseBkgnd(CDC *pDC) {
if (!mDocument)
return CFrameWnd::OnEraseBkgnd(pDC);
pDC->SaveDC();
pDC->SelectPalette(mWorldDef->GetPalette(), false);
int objInd = mWorldDef->mImageObj->FindObject("MsgWnd");
RECT rect;
SetRect(&rect, 0, 0, 513, 45);
mWorldDef->mImageObj->DrawObject(pDC, objInd, rect);
pDC->RealizePalette();
pDC->RestoreDC(-1);
return true;
}
/*virtual*/ BOOL T2MsgWindow::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT *pResult) {
LPNMTTDISPINFO msg = (LPNMTTDISPINFO) lParam;
int id = ::GetDlgCtrlID((HWND) msg->hdr.idFrom);
if (msg->hdr.code == TTN_GETDISPINFO && (id >= 1000) && (id <= 1003)) {
mWorldDef->GetToolTipText(mDocument, (T2MWControl *) GetDlgItem(id), msg);
return true;
}
return CWnd::OnNotify(wParam, lParam, pResult);
}
void T2MsgWindow::OnClose() {
if (!mDocument)
return;
mDocument->towerDoc_vf198(kMessageWindow);
}
/*virtual*/ BOOL T2MsgWindow::PreTranslateMessage(MSG *pMsg) {
if (mIsSetUp)
mToolTip.RelayEvent(pMsg);
return CFrameWnd::PreTranslateMessage(pMsg);
}
|