|
// MessageBox.cpp : implementation file
//
#include "stdafx.h"
#include "wbhelp.h"
#include "MessageBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMessageBox dialog
CMessageBox::CMessageBox(CWnd* pParent /*=NULL*/)
: CDialog(CMessageBox::IDD, pParent)
{
//{{AFX_DATA_INIT(CMessageBox)
//}}AFX_DATA_INIT
}
void CMessageBox::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMessageBox)
DDX_Control(pDX, IDC_DONTSHOWAGAIN2, m_CustomCheckboxCtrl);
DDX_Control(pDX, IDC_STATICLINE, m_StaticLine);
DDX_Control(pDX, IDC_MESSAGEBOXTITLE, m_TitleCtrl);
DDX_Control(pDX, IDC_MESSAGEBOXTEXT, m_TextCtrl);
DDX_Control(pDX, IDC_MESSAGEBOXICON, m_IconCtrl);
DDX_Control(pDX, IDC_DONTSHOWAGAIN, m_DontShowAgainCtrl);
DDX_Control(pDX, ID_MESSAGEBUT3, m_But3Ctrl);
DDX_Control(pDX, ID_MESSAGEBUT2, m_But2Ctrl);
DDX_Control(pDX, ID_MESSAGEBUT1, m_But1Ctrl);
DDX_Check(pDX, IDC_DONTSHOWAGAIN, m_DontShowAgain);
DDX_Text(pDX, IDC_MESSAGEBOXTITLE, m_Title);
DDX_Text(pDX, IDC_MESSAGEBOXTEXT, m_Text);
DDX_Text(pDX, IDC_MESSAGEBOXICON, m_Icon);
//}}AFX_DATA_MAP
// Set up dialog
if (m_nType & MB_ICONASTERISK || m_nType & MB_ICONINFORMATION)
m_IconCtrl.SetIcon(theApp.LoadStandardIcon(IDI_ASTERISK));
else if (m_nType & MB_ICONQUESTION)
m_IconCtrl.SetIcon(theApp.LoadStandardIcon(IDI_QUESTION));
else if (m_nType & MB_ICONHAND || m_nType & MB_ICONSTOP || m_nType & MB_ICONERROR)
m_IconCtrl.SetIcon(theApp.LoadStandardIcon(IDI_HAND));
else // MB_ICONWARNING & MB_ICONEXCLAMATION
m_IconCtrl.SetIcon(theApp.LoadStandardIcon(IDI_EXCLAMATION));
m_TitleCtrl.SetWindowText(m_Title);
m_TextCtrl.SetWindowText(m_Text);
if (m_But1Visible == 1)
{
m_But1Ctrl.ShowWindow(TRUE);
m_But1Ctrl.SetWindowText(m_But1Caption);
}
if (m_But2Visible == 1)
{
m_But2Ctrl.ShowWindow(TRUE);
m_But2Ctrl.SetWindowText(m_But2Caption);
}
if (m_But3Visible == 1)
{
m_But3Ctrl.ShowWindow(TRUE);
m_But3Ctrl.SetWindowText(m_But3Caption);
}
if (m_HideShowAgain)
{
m_StaticLine.ShowWindow(SW_HIDE);
m_DontShowAgainCtrl.ShowWindow(SW_HIDE);
}
}
BEGIN_MESSAGE_MAP(CMessageBox, CDialog)
//{{AFX_MSG_MAP(CMessageBox)
ON_BN_CLICKED(ID_MESSAGEBUT1, OnMessagebut1)
ON_BN_CLICKED(ID_MESSAGEBUT2, OnMessagebut2)
ON_BN_CLICKED(ID_MESSAGEBUT3, OnMessagebut3)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMessageBox message handlers
void CMessageBox::OnMessagebut1()
{
if (m_DontShowAgain)
theApp.WriteProfileInt("Settings\\Messages", m_Title + "#" + m_Text, m_DontShowAgainCtrl.GetCheck());
else
{
if (m_CustomCheckboxCtrl.GetCheck() != 0)
m_CustomCheckbox = 1;
else
m_CustomCheckbox = 0;
}
EndDialog(m_But1Value);
}
void CMessageBox::OnMessagebut2()
{
if (m_DontShowAgain)
theApp.WriteProfileInt("Settings\\Messages", m_Title + "#" + m_Text, m_DontShowAgainCtrl.GetCheck());
else
{
if (m_CustomCheckboxCtrl.GetCheck() != 0)
m_CustomCheckbox = 1;
else
m_CustomCheckbox = 0;
}
EndDialog(m_But2Value);
}
void CMessageBox::OnMessagebut3()
{
if (m_DontShowAgain)
theApp.WriteProfileInt("Settings\\Messages", m_Title + "#" + m_Text, m_DontShowAgainCtrl.GetCheck());
else
{
if (m_CustomCheckboxCtrl.GetCheck() != 0)
m_CustomCheckbox = 1;
else
m_CustomCheckbox = 0;
}
EndDialog(m_But3Value);
}
BOOL CMessageBox::OnInitDialog()
{
if (theApp.GetProfileInt("Settings\\Messages", m_Title + "#" + m_Text, 0) != 0)
EndDialog(-1);
CDialog::OnInitDialog();
// set some styles for the pretty caption bar
m_TitleCtrl.m_textClr = ::GetSysColor(COLOR_3DFACE);
m_TitleCtrl.m_fontWeight = FW_BOLD;
m_TitleCtrl.m_fontSize = 14;
m_TitleCtrl.m_csFontName = "Verdana";
m_TitleCtrl.SetWindowText(m_Title);
if (m_DontShowAgain) m_CustomCheckbox = FALSE;
if (m_CustomCheckbox) m_DontShowAgain = FALSE;
if (m_DontShowAgain)
m_DontShowAgainCtrl.ShowWindow(SW_SHOW);
if (m_CustomCheckbox)
{
m_CustomCheckboxCtrl.ShowWindow(SW_SHOW);
m_CustomCheckboxCtrl.SetWindowText(m_CustomCheckboxCaption);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMessageBox::OnClose()
{
EndDialog(-1);
//CDialog::OnClose();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.