Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Message box display twice

Message box display twice

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jadhavjitendrar
    wrote on last edited by
    #1

    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.

    T 1 Reply Last reply
    0
    • J jadhavjitendrar

      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.

      T Offline
      T Offline
      theCPkid
      wrote on last edited by
      #2

      yes, one suggestion. what's this ResourceString function. Check if there's some event happening that is sending ON_NOTIFY twice. THere can be more than one reason why OnNotify is called..

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups