Message box display twice
-
this drives me nuts... I have the following function that checks against an IP address control for displaying an error message box if users specify an invalid IP value that greater than 255 ON_NOTIFY(IPN_FIELDCHANGED, IDC_EDIT_LISTEN_ADDRESS, &CNetworkBindingDlg:SurprisenEditListenAddressChanged) void CNetworkBindingDlg:SurprisenEditListenAddressChanged(NMHDR* pNMHDR,LRESULT* pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); if(pIPAddr->iValue > 255) { CStringW ErrMsg; ErrMsg.Format(ResourceString(IDS_INVALID_IP_ADDRESS),pIPAddr->iValue); MessageBox(ErrMsg,ResourceString(AFX_IDS_APP_TITLE), MB_ICONERROR); } } Somehow the MessageBox() function execute twice. I chased the code and noticed that the MessageBox() is executed the first time, but the message does not show up, but the execution control comes back to the CStringW ErrMsg line, the MessageBox() will be executed the second time. And then the message box dialog shows up twice. Any suggestion? thanks.
-
this drives me nuts... I have the following function that checks against an IP address control for displaying an error message box if users specify an invalid IP value that greater than 255 ON_NOTIFY(IPN_FIELDCHANGED, IDC_EDIT_LISTEN_ADDRESS, &CNetworkBindingDlg:SurprisenEditListenAddressChanged) void CNetworkBindingDlg:SurprisenEditListenAddressChanged(NMHDR* pNMHDR,LRESULT* pResult) { LPNMIPADDRESS pIPAddr = reinterpret_cast<LPNMIPADDRESS>(pNMHDR); if(pIPAddr->iValue > 255) { CStringW ErrMsg; ErrMsg.Format(ResourceString(IDS_INVALID_IP_ADDRESS),pIPAddr->iValue); MessageBox(ErrMsg,ResourceString(AFX_IDS_APP_TITLE), MB_ICONERROR); } } Somehow the MessageBox() function execute twice. I chased the code and noticed that the MessageBox() is executed the first time, but the message does not show up, but the execution control comes back to the CStringW ErrMsg line, the MessageBox() will be executed the second time. And then the message box dialog shows up twice. Any suggestion? thanks.