00001
00002
00003
00004
00005 #include "MessageBoxDLG.h"
00006
00007
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #undef THIS_FILE
00011 static char THIS_FILE[] = __FILE__;
00012 #endif
00013
00014
00015 using namespace jbxwl;
00016
00017
00018
00020
00021
00022 CMessageBoxDLG::CMessageBoxDLG(LPCTSTR tn, CWnd* pParent)
00023 : CDialog(CMessageBoxDLG::IDD, pParent)
00024 {
00025
00026
00027
00028 dialogID = CMessageBoxDLG::IDD;
00029 pWnd = pParent;
00030 title = tn;
00031 message = NULL;
00032 cancel = false;
00033
00034 Create(dialogID, pWnd);
00035 }
00036
00037
00038
00039 CMessageBoxDLG::CMessageBoxDLG(UINT nIDTemplate, LPCTSTR tn, CWnd* pParent)
00040 : CDialog(nIDTemplate, pParent)
00041 {
00042 dialogID = nIDTemplate;
00043 pWnd = pParent;
00044 title = tn;
00045 message = NULL;
00046 cancel = false;
00047
00048 Create(dialogID, pWnd);
00049 }
00050
00051
00052
00053 CMessageBoxDLG::~CMessageBoxDLG()
00054 {
00055 Destory();
00056 }
00057
00058
00059
00060 void CMessageBoxDLG::DoDataExchange(CDataExchange* pDX)
00061 {
00062 CDialog::DoDataExchange(pDX);
00063
00064
00065 }
00066
00067
00068
00069 BEGIN_MESSAGE_MAP(CMessageBoxDLG, CDialog)
00070
00071
00072 ON_STN_CLICKED(IDC_MESG_BOX_TEXT, &CMessageBoxDLG::OnStnClickedMesgBoxText)
00073 END_MESSAGE_MAP()
00074
00075
00076
00078
00079
00080 BOOL CMessageBoxDLG::OnInitDialog()
00081 {
00082 message = (CStatic*)GetDlgItem(IDC_MESG_BOX_TEXT);
00083 return TRUE;
00084 }
00085
00086
00087
00088
00089
00090 void CMessageBoxDLG::Display(LPCTSTR mesg)
00091 {
00092 if (pWnd!=NULL) {
00093 RECT rect;
00094 pWnd->GetWindowRect(&rect);
00095 int sx = (rect.left+rect.right)/2;
00096 int sy = (rect.top+rect.bottom)/2;
00097 this->GetWindowRect(&rect);
00098 sx -= (rect.right-rect.left)/2;
00099 sy -= (rect.bottom-rect.top)/2;
00100 this->SetWindowPos(NULL, sx, sy, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
00101 }
00102 ShowWindow(SW_SHOW);
00103
00104 if (!title.IsEmpty()) SetWindowText(title);
00105 if (message!=NULL && mesg!=NULL) message->SetWindowText(mesg);
00106 }
00107
00108
00109
00110
00111
00112 void CMessageBoxDLG::Destory()
00113 {
00114 DestroyWindow();
00115 }
00116
00117
00118
00119 void jbxwl::CMessageBoxDLG::OnStnClickedMesgBoxText()
00120 {
00121
00122 }
00123
00124
00125
00126
00127
00128 BOOL jbxwl::CMessageBoxDLG::OnCommand(WPARAM wParam, LPARAM lParam)
00129 {
00130 if (wParam==IDCANCEL) cancel = true;
00131
00132 return CDialog::OnCommand(wParam, lParam);
00133 }
00134
00135
00136
00137
00139
00140
00141
00142 CMessageBoxDLG* jbxwl::MessageBoxDLG(int ttl, int msg, CWnd* wnd)
00143 {
00144 CString mesg, noti;
00145 noti.LoadString(ttl);
00146 mesg.LoadString(msg);
00147
00148 CMessageBoxDLG* mesgbox = new CMessageBoxDLG(noti, wnd);
00149 if (mesgbox!=NULL) mesgbox->Display(mesg);
00150 return mesgbox;
00151 }
00152
00153
00154
00155 CMessageBoxDLG* jbxwl::MessageBoxDLG(LPCTSTR ttl, int msg, CWnd* wnd)
00156 {
00157 CString mesg;
00158 mesg.LoadString(msg);
00159
00160 CMessageBoxDLG* mesgbox = new CMessageBoxDLG(ttl, wnd);
00161 if (mesgbox!=NULL) mesgbox->Display(mesg);
00162 return mesgbox;
00163 }
00164
00165
00166
00167 CMessageBoxDLG* jbxwl::MessageBoxDLG(int ttl, LPCTSTR msg, CWnd* wnd)
00168 {
00169 CString noti;
00170 noti.LoadString(ttl);
00171
00172 CMessageBoxDLG* mesgbox = new CMessageBoxDLG(noti, wnd);
00173 if (mesgbox!=NULL) mesgbox->Display(msg);
00174 return mesgbox;
00175 }
00176
00177
00178
00179 CMessageBoxDLG* jbxwl::MessageBoxDLG(LPCTSTR ttl, LPCTSTR msg, CWnd* wnd)
00180 {
00181 CMessageBoxDLG* mesgbox = new CMessageBoxDLG(ttl, wnd);
00182 if (mesgbox!=NULL) mesgbox->Display(msg);
00183 return mesgbox;
00184 }
00185
00186
00187
00188
00190
00191
00192
00193 int jbxwl::MessageBoxDLG(int ttl, int msg, UINT type, CWnd* wnd)
00194 {
00195 CString mesg, noti;
00196 noti.LoadString(ttl);
00197 mesg.LoadString(msg);
00198
00199 int ret;
00200 if (wnd!=NULL) ret = ::MessageDLG(noti, mesg, type, wnd->m_hWnd);
00201 else ret = ::MessageDLG(noti, mesg, type, (HWND)NULL);
00202 return ret;
00203 }
00204
00205
00206
00207 int jbxwl::MessageBoxDLG(LPCTSTR ttl, int msg, UINT type, CWnd* wnd)
00208 {
00209 CString mesg;
00210 mesg.LoadString(msg);
00211
00212 int ret;
00213 if (wnd!=NULL) ret = ::MessageDLG(ttl, mesg, type, wnd->m_hWnd);
00214 else ret = ::MessageDLG(ttl, mesg, type, (HWND)NULL);
00215 return ret;
00216 }
00217
00218
00219
00220 int jbxwl::MessageBoxDLG(int ttl, LPCTSTR msg, UINT type, CWnd* wnd)
00221 {
00222 CString noti;
00223 noti.LoadString(ttl);
00224
00225 int ret;
00226 if (wnd!=NULL) ret = ::MessageDLG(noti, msg, type, wnd->m_hWnd);
00227 else ret = ::MessageDLG(noti, msg, type, (HWND)NULL);
00228 return ret;
00229 }
00230
00231
00232
00233 int jbxwl::MessageBoxDLG(LPCTSTR ttl, LPCTSTR msg, UINT type, CWnd* wnd)
00234 {
00235 int ret;
00236 if (wnd!=NULL) ret = ::MessageDLG(ttl, msg, type, wnd->m_hWnd);
00237 else ret = ::MessageDLG(ttl, msg, type, (HWND)NULL);
00238 return ret;
00239 }
00240