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
|
// JS_ResponseDlg.cpp : implementation file
//
#include "stdafx.h"
#include "readervc.h"
#include "JS_ResponseDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJS_ResponseDlg dialog
CJS_ResponseDlg::CJS_ResponseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CJS_ResponseDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CJS_ResponseDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_swTitle =(FPDF_WIDESTRING) L"";
m_swQuestion =(FPDF_WIDESTRING) L"";
m_swLabel =(FPDF_WIDESTRING) L"";
m_swDefault =(FPDF_WIDESTRING) L"";
m_swResponse =L"";
m_bIsVisible = false;
m_pResponseEdit = NULL;
}
void CJS_ResponseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CJS_ResponseDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CJS_ResponseDlg, CDialog)
//{{AFX_MSG_MAP(CJS_ResponseDlg)
// NOTE: the ClassWizard will add message map macros here
ON_BN_CLICKED(ID_JS_OK, OnResOk)
ON_BN_CLICKED(ID_JS_CANCEL, OnResCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJS_ResponseDlg message handlers
BOOL CJS_ResponseDlg::OnInitDialog()
{
CDialog::OnInitDialog();
::SetWindowTextW(this->GetSafeHwnd(), (LPCWSTR)m_swTitle);
CStatic* pQuestion = (CStatic*)GetDlgItem(IDC_JS_QUESTION);
::SetWindowTextW(pQuestion->GetSafeHwnd(), (LPCWSTR)m_swQuestion);
CStatic* pLabel = (CStatic*)GetDlgItem(IDC_JS_ANSWER);
CRect DialogRect;
CRect LabelRect;
RECT rect;
GetWindowRect(&DialogRect);
pLabel->GetWindowRect(&LabelRect);
if(m_swLabel == (FPDF_WIDESTRING)L"")
{
rect.left = DialogRect.left + 20;
pLabel->ShowWindow(SW_HIDE);
}
else
{
rect.left = LabelRect.right + 1;
::SetWindowTextW(pLabel->GetSafeHwnd(), (LPCWSTR)m_swLabel);
}
rect.top = LabelRect.top - 3;
rect.right = DialogRect.right - 20;
rect.bottom = LabelRect.bottom + 2;
ScreenToClient(&rect);
m_pResponseEdit = new CEdit();
if(m_bIsVisible)
m_pResponseEdit->Create(ES_AUTOVSCROLL | ES_NOHIDESEL | ES_PASSWORD | WS_BORDER, rect, this, IDC_JS_EDIT);
else
m_pResponseEdit->Create(ES_AUTOVSCROLL | ES_NOHIDESEL | WS_BORDER, rect, this, IDC_JS_EDIT);
::SetWindowTextW(m_pResponseEdit->GetSafeHwnd(), (LPCWSTR)m_swDefault);
m_pResponseEdit->ShowWindow(SW_SHOW);
return TRUE;
}
void CJS_ResponseDlg::OnResOk()
{
m_swResponse = (wchar_t*)malloc(sizeof(wchar_t) * 250);
::GetWindowTextW(m_pResponseEdit->GetSafeHwnd(), m_swResponse, 250);
if(m_pResponseEdit)
{
m_pResponseEdit->DestroyWindow();
delete m_pResponseEdit;
m_pResponseEdit = NULL;
}
CDialog::OnOK();
}
void CJS_ResponseDlg::OnResCancel()
{
if(m_pResponseEdit)
{
m_pResponseEdit->DestroyWindow();
delete m_pResponseEdit;
m_pResponseEdit = NULL;
}
CDialog::OnCancel();
}
void CJS_ResponseDlg::SetTitle(FPDF_WIDESTRING swTitle)
{
m_swTitle = swTitle;
}
void CJS_ResponseDlg::SetQuestion(FPDF_WIDESTRING swQuestion)
{
m_swQuestion = swQuestion;
}
void CJS_ResponseDlg::SetLabel(FPDF_WIDESTRING swLabel)
{
m_swLabel = swLabel;
}
void CJS_ResponseDlg::SetDefault(FPDF_WIDESTRING swDefault)
{
m_swDefault = swDefault;
}
FPDF_WIDESTRING CJS_ResponseDlg::GetResponse()
{
return (FPDF_WIDESTRING)m_swResponse;
}
void CJS_ResponseDlg::SetIsVisible(FPDF_BOOL bPassword)
{
m_bIsVisible = bPassword;
}
|