// MsgBox.cpp : implementation file // #include "stdafx.h" #include "resource.h" #include "MsgBox.h" #include ".\msgbox.h" // CMsgBox dialog IMPLEMENT_DYNAMIC(CMsgBox, CDialog) CMsgBox::CMsgBox(CWnd* pParent /*=NULL*/) : CDialog(CMsgBox::IDD, pParent) { } CMsgBox::~CMsgBox() { } void CMsgBox::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CMsgBox, CDialog) END_MESSAGE_MAP() // CMsgBox message handlers BOOL CMsgBox::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText(m_strTitle); SetMessage(m_strMessage, m_strDelimiter); // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CMsgBox::SetMessage(CString strMsg, CString strDelimiter) { int iHalf; int iDelimiter; // \r\n ms win if (strMsg.GetLength() == 0) { return; } if (strMsg.GetLength() < 100) { GetDlgItem(IDC_MESSAGE1)->SetWindowText(strMsg); GetDlgItem(IDC_MESSAGE2)->SetWindowText(""); } else { iHalf = (int)(strMsg.GetLength() / 2); iDelimiter = strMsg.Find(strDelimiter,iHalf); if (iDelimiter >= iHalf) { // try to find next \r\n GetDlgItem(IDC_MESSAGE1)->SetWindowText(strMsg.Left(iDelimiter+1)); GetDlgItem(IDC_MESSAGE2)->SetWindowText(strMsg.Mid(iDelimiter+2)); } } }