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
|
#include "./pageInfo.h"
#include "./common.h"
#include "./loginGui.h"
#include "../resource.h"
static HRESULT CALLBACK LoginPageInfo_CreateInstance(HWND hwnd, HWND hLoginbox, LoginPage **instance)
{
if (NULL == instance) return E_POINTER;
if (NULL == hwnd || NULL == hLoginbox) return E_INVALIDARG;
*instance = new LoginPageInfo(hwnd, hLoginbox);
if (NULL == instance) return E_OUTOFMEMORY;
return S_OK;
}
LoginPageInfo::LoginPageInfo(HWND hwnd, HWND hLoginbox)
: LoginPage(hwnd, hLoginbox)
{
}
LoginPageInfo::~LoginPageInfo()
{
}
HWND LoginPageInfo::CreatePage(HWND hLoginbox, HWND hParent)
{
return LoginPage::CreatePage(hLoginbox, MAKEINTRESOURCE(IDD_PAGE_INFO),
hParent, NULL, LoginPageInfo_CreateInstance);
}
void LoginPageInfo::UpdateLayout(BOOL fRedraw)
{
LoginPage::UpdateLayout(fRedraw);
RECT pageRect;
if (FALSE == GetPageRect(&pageRect))
return;
HWND hMessage = GetDlgItem(hwnd, IDC_MESSAGE);
if (NULL == hMessage) return;
INT cx, cy;
cx = pageRect.right - pageRect.left;
HDC hdc = GetDCEx(hMessage, NULL, DCX_CACHE | DCX_NORESETATTRS);
if (NULL != hdc)
{
HFONT fontControl = (HFONT)SendMessage(hMessage, WM_GETFONT, 0, 0L);
HFONT fontOrig = (HFONT)SelectObject(hdc, fontControl);
INT maxWidth = LoginBox_GetAveStrWidth(hdc, 80);
if (cx > maxWidth) cx = maxWidth;
SelectObject(hdc, fontOrig);
ReleaseDC(hMessage, hdc);
}
LoginBox_GetWindowTextSize(hMessage, cx, &cx, &cy);
if(cy > (pageRect.bottom - pageRect.top))
cy = pageRect.bottom - pageRect.top;
RECT messageRect;
GetWindowRect(hMessage, &messageRect);
MapWindowPoints(HWND_DESKTOP, hwnd, (POINT*)&messageRect, 2);
if (messageRect.left != pageRect.left ||
messageRect.top != pageRect.top ||
(messageRect.right - messageRect.left) != cx ||
(messageRect.bottom - messageRect.top) != cy)
{
SetWindowPos(hMessage, NULL, pageRect.left, pageRect.top, cx, cy,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW);
if (FALSE != fRedraw)
{
HRGN rgn1 = CreateRectRgnIndirect(&messageRect);
HRGN rgn2 = CreateRectRgn(pageRect.left, pageRect.top, pageRect.left + cx, pageRect.top + cy);
CombineRgn(rgn1, rgn1, rgn2, RGN_OR);
RedrawWindow(hwnd, NULL, rgn1, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ERASENOW | RDW_VALIDATE | RDW_ALLCHILDREN);
DeleteObject(rgn1);
DeleteObject(rgn2);
}
}
}
BOOL LoginPageInfo::OnInitDialog(HWND hFocus, LPARAM param)
{
HFONT fontText = NULL;
LoginGuiObject *loginGui;
if (SUCCEEDED(LoginGuiObject::QueryInstance(&loginGui)))
{
fontText = loginGui->GetTextFont();
loginGui->Release();
}
if (NULL != fontText)
{
HWND hMessage = GetDlgItem(hwnd, IDC_MESSAGE);
if (NULL != hMessage)
SendMessage(hMessage, WM_SETFONT, (WPARAM)fontText, 0L);
}
LoginPage::OnInitDialog(hFocus, param);
return FALSE;
}
void LoginPageInfo::OnSetMessage(LPCWSTR pszMessage)
{
HWND hMessage = GetDlgItem(hwnd, IDC_MESSAGE);
if (NULL != hMessage)
{
SetWindowText(hMessage, pszMessage);
INT showWindow = (NULL != pszMessage && L'\0' != *pszMessage) ? SW_SHOWNA : SW_HIDE;
ShowWindow(hMessage, showWindow);
}
}
INT_PTR LoginPageInfo::DialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case NLPIM_SETMESSAGE: OnSetMessage((LPCWSTR)lParam); return TRUE;
}
return __super::DialogProc(uMsg, wParam, lParam);
}
|