// 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.c_str()); 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(string strMsg, string strDelimiter) { int iHalf; int iDelimiter; // \r\n ms win if (strMsg.length() == 0) { return; } if (strMsg.length() < 100) { GetDlgItem(IDC_MESSAGE1)->SetWindowText(strMsg.c_str()); GetDlgItem(IDC_MESSAGE2)->SetWindowText(""); } else { iHalf = (int)(strMsg.length() / 2); iDelimiter = (int)strMsg.find(strDelimiter,iHalf); if (iDelimiter >= iHalf) { // try to find next \r\n GetDlgItem(IDC_MESSAGE1)->SetWindowText(strMsg.substr(0,iDelimiter+1).c_str()); GetDlgItem(IDC_MESSAGE2)->SetWindowText(strMsg.substr(iDelimiter+2).c_str()); } } }