1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: Mozilla-sample-code 1.0
5
* Copyright (c) 2002 Netscape Communications Corporation and
8
* Permission is hereby granted, free of charge, to any person obtaining a
9
* copy of this Mozilla sample software and associated documentation files
10
* (the "Software"), to deal in the Software without restriction, including
11
* without limitation the rights to use, copy, modify, merge, publish,
12
* distribute, sublicense, and/or sell copies of the Software, and to permit
13
* persons to whom the Software is furnished to do so, subject to the
14
* following conditions:
16
* The above copyright notice and this permission notice shall be included
17
* in all copies or substantial portions of the Software.
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25
* DEALINGS IN THE SOFTWARE.
28
* Chak Nanga <chak@netscape.com>
30
* ***** END LICENSE BLOCK ***** */
37
// Contains dialog box code to support Alerts, Prompts such as
38
// password prompt and username/password prompts
41
//--------------------------------------------------------------------------//
42
// CPromptDialog Stuff
43
//--------------------------------------------------------------------------//
45
CPromptDialog::CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
46
const char* pInitPromptText,
47
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
48
: CDialog(CPromptDialog::IDD, pParent),
49
m_bHasCheckBox(bHasCheck)
52
m_csDialogTitle = pTitle;
54
m_csPromptText = pText;
56
m_csPromptAnswer = pInitPromptText;
58
m_csCheckBoxText = pCheckText;
61
void CPromptDialog::DoDataExchange(CDataExchange* pDX)
63
CDialog::DoDataExchange(pDX);
64
//{{AFX_DATA_MAP(CPromptDialog)
65
DDX_Text(pDX, IDC_PROMPT_ANSWER, m_csPromptAnswer);
66
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
70
BEGIN_MESSAGE_MAP(CPromptDialog, CDialog)
71
//{{AFX_MSG_MAP(CPromptDialog)
72
// NOTE: the ClassWizard will add message map macros here
76
int CPromptDialog::OnInitDialog()
78
SetWindowText(m_csDialogTitle);
80
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
82
pWnd->SetWindowText(m_csPromptText);
84
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
89
if(!m_csCheckBoxText.IsEmpty())
90
pChk->SetWindowText(m_csCheckBoxText);
91
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
95
// Hide the check box control if there's no label text
96
// This will be the case when we're not using single sign-on
97
pChk->ShowWindow(SW_HIDE);
101
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PROMPT_ANSWER);
104
pEdit->SetWindowText(m_csPromptAnswer);
106
pEdit->SetSel(0, -1);
108
return 0; // Returning "0" since we're explicitly setting focus
114
//--------------------------------------------------------------------------//
115
// CPromptPasswordDialog Stuff
116
//--------------------------------------------------------------------------//
118
CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
119
const char* pInitPasswordText,
120
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
121
: CDialog(CPromptPasswordDialog::IDD, pParent),
122
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
125
m_csDialogTitle = pTitle;
127
m_csPromptText = pText;
128
if(pInitPasswordText)
129
m_csPassword = pInitPasswordText;
131
m_csCheckBoxText = pCheckText;
134
void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX)
136
CDialog::DoDataExchange(pDX);
137
//{{AFX_DATA_MAP(CPromptPasswordDialog)
138
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
139
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
143
BEGIN_MESSAGE_MAP(CPromptPasswordDialog, CDialog)
144
//{{AFX_MSG_MAP(CPromptPasswordDialog)
145
// NOTE: the ClassWizard will add message map macros here
149
int CPromptPasswordDialog::OnInitDialog()
151
SetWindowText(m_csDialogTitle);
153
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
155
pWnd->SetWindowText(m_csPromptText);
157
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
162
if(!m_csCheckBoxText.IsEmpty())
163
pChk->SetWindowText(m_csCheckBoxText);
164
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
168
// Hide the check box control if there's no label text
169
// This will be the case when we're not using single sign-on
170
pChk->ShowWindow(SW_HIDE);
174
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
179
return 0; // Returning "0" since we're explicitly setting focus
185
//--------------------------------------------------------------------------//
186
// CPromptUsernamePasswordDialog Stuff
187
//--------------------------------------------------------------------------//
189
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
190
const char* pInitUsername, const char* pInitPassword,
191
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
192
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent),
193
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
196
m_csDialogTitle = pTitle;
198
m_csPromptText = pText;
200
m_csUserName = pInitUsername;
202
m_csPassword = pInitPassword;
204
m_csCheckBoxText = pCheckText;
207
void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
209
CDialog::DoDataExchange(pDX);
210
//{{AFX_DATA_MAP(CPromptUsernamePasswordDialog)
211
DDX_Text(pDX, IDC_USERNAME, m_csUserName);
212
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
213
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
217
BEGIN_MESSAGE_MAP(CPromptUsernamePasswordDialog, CDialog)
218
//{{AFX_MSG_MAP(CPromptUsernamePasswordDialog)
219
// NOTE: the ClassWizard will add message map macros here
223
int CPromptUsernamePasswordDialog::OnInitDialog()
225
SetWindowText(m_csDialogTitle);
227
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
229
pWnd->SetWindowText(m_csPromptText);
231
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
236
if (!m_csCheckBoxText.IsEmpty())
237
pChk->SetWindowText(m_csCheckBoxText);
238
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
242
pChk->ShowWindow(SW_HIDE);
246
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
249
pEdit->SetWindowText(m_csPassword);
252
pEdit = (CEdit *)GetDlgItem(IDC_USERNAME);
255
pEdit->SetWindowText(m_csUserName);
256
pEdit->SetSel(0, -1);
260
return 0; // Returning "0" since we're explicitly setting focus
266
//--------------------------------------------------------------------------//
267
// CAlertCheckDialog Stuff
268
//--------------------------------------------------------------------------//
270
CAlertCheckDialog::CAlertCheckDialog(CWnd* pParent, const char* pTitle, const char* pText,
271
const char* pCheckText, int initCheckVal)
272
: CDialog(CAlertCheckDialog::IDD, pParent)
275
m_csDialogTitle = pTitle;
279
m_csCheckBoxText = pCheckText;
281
m_bCheckBoxValue = initCheckVal;
284
void CAlertCheckDialog::DoDataExchange(CDataExchange* pDX)
286
CDialog::DoDataExchange(pDX);
287
//{{AFX_DATA_MAP(CAlertCheckDialog)
288
DDX_Check(pDX, IDC_CHECKBOX, m_bCheckBoxValue);
292
BEGIN_MESSAGE_MAP(CAlertCheckDialog, CDialog)
293
//{{AFX_MSG_MAP(CAlertCheckDialog)
294
// NOTE: the ClassWizard will add message map macros here
298
int CAlertCheckDialog::OnInitDialog()
300
SetWindowText(m_csDialogTitle);
302
CWnd *pWnd = GetDlgItem(IDC_MSG_TEXT);
304
pWnd->SetWindowText(m_csMsgText);
306
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECKBOX);
309
pChk->SetWindowText(m_csCheckBoxText);
310
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
316
//--------------------------------------------------------------------------//
317
// CConfirmCheckDialog Stuff
318
//--------------------------------------------------------------------------//
320
CConfirmCheckDialog::CConfirmCheckDialog(CWnd* pParent, const char* pTitle, const char* pText,
321
const char* pCheckText, int initCheckVal,
322
const char *pBtn1Text, const char *pBtn2Text,
323
const char *pBtn3Text)
324
: CDialog(CConfirmCheckDialog::IDD, pParent)
327
m_csDialogTitle = pTitle;
331
m_csCheckBoxText = pCheckText;
333
m_bCheckBoxValue = initCheckVal;
336
m_csBtn1Text = pBtn1Text;
338
m_csBtn2Text = pBtn2Text;
340
m_csBtn3Text = pBtn3Text;
343
void CConfirmCheckDialog::DoDataExchange(CDataExchange* pDX)
345
CDialog::DoDataExchange(pDX);
346
//{{AFX_DATA_MAP(CConfirmCheckDialog)
347
DDX_Check(pDX, IDC_CHECKBOX, m_bCheckBoxValue);
351
BEGIN_MESSAGE_MAP(CConfirmCheckDialog, CDialog)
352
//{{AFX_MSG_MAP(CConfirmCheckDialog)
353
ON_BN_CLICKED(IDC_BTN1, OnBtn1Clicked)
354
ON_BN_CLICKED(IDC_BTN2, OnBtn2Clicked)
355
ON_BN_CLICKED(IDC_BTN3, OnBtn3Clicked)
359
int CConfirmCheckDialog::OnInitDialog()
361
SetWindowText(m_csDialogTitle);
363
CWnd *pWnd = GetDlgItem(IDC_MSG_TEXT);
365
pWnd->SetWindowText(m_csMsgText);
367
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECKBOX);
370
if(m_csCheckBoxText.IsEmpty())
372
pChk->ShowWindow(SW_HIDE);
376
pChk->SetWindowText(m_csCheckBoxText);
377
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
381
CButton *pBtn1 = (CButton *)GetDlgItem(IDC_BTN1);
384
if(m_csBtn1Text.IsEmpty())
385
pBtn1->ShowWindow(SW_HIDE);
387
pBtn1->SetWindowText(m_csBtn1Text);
390
CButton *pBtn2 = (CButton *)GetDlgItem(IDC_BTN2);
393
if(m_csBtn2Text.IsEmpty())
394
pBtn2->ShowWindow(SW_HIDE);
396
pBtn2->SetWindowText(m_csBtn2Text);
399
CButton *pBtn3 = (CButton *)GetDlgItem(IDC_BTN3);
402
if(m_csBtn3Text.IsEmpty())
403
pBtn3->ShowWindow(SW_HIDE);
405
pBtn3->SetWindowText(m_csBtn3Text);
411
void CConfirmCheckDialog::OnBtn1Clicked()
415
EndDialog(0); // where 0 indicates that the btn pressed was at index 0
418
void CConfirmCheckDialog::OnBtn2Clicked()
422
EndDialog(1); // where 1 indicates that the btn pressed was at index 1
425
void CConfirmCheckDialog::OnBtn3Clicked()
429
EndDialog(2); // where 2 indicates that the btn pressed was at index 2