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. remotely closing a modeless dialog

remotely closing a modeless dialog

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsperformancehelplounge
3 Posts 3 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.
  • K Offline
    K Offline
    kfaday
    wrote on last edited by
    #1

    Hello, i'm developing a chat program. There's a vector of pointers to Dialogs. When i open a chat window, a NEW is called to that dialog, then i call create and showwindow to show the dialog. The windows are deleted when i close the program. I'm not having trouble with that. When i close a window, i send a message to the remote client to close the window. The remote client receives this message in a function from the dialog, and there i want to close the dialog (not the remote one):

    		CVentanaPizarra::OnClose(); 
    		CDialog::EndDialog(0);
    

    In the OnClose I have the following:

    void CVentanaPizarra::OnClose()
    {
    //stuff i do
    CDialog::OnClose();
    }

    If i don't use EndDialog, the dialog doesn't close. If i use EndDialog, when i want to open the dialog again, the program crashes. i don't want to delete the memory, just hide the dialog, or close it in some kind of way. i know it works locally, as when i close with the X, then i can open it again, but not when i receive the message. I searched in msdn, and it says EndDialog is or modal dialogs. So i tried DestroyWindow. I also tried ShowWindow(SW_HIDE) but it doen't work as well. I'd really appreciate any kind of help you could give me. Thanks in advance!

    J L 2 Replies Last reply
    0
    • K kfaday

      Hello, i'm developing a chat program. There's a vector of pointers to Dialogs. When i open a chat window, a NEW is called to that dialog, then i call create and showwindow to show the dialog. The windows are deleted when i close the program. I'm not having trouble with that. When i close a window, i send a message to the remote client to close the window. The remote client receives this message in a function from the dialog, and there i want to close the dialog (not the remote one):

      		CVentanaPizarra::OnClose(); 
      		CDialog::EndDialog(0);
      

      In the OnClose I have the following:

      void CVentanaPizarra::OnClose()
      {
      //stuff i do
      CDialog::OnClose();
      }

      If i don't use EndDialog, the dialog doesn't close. If i use EndDialog, when i want to open the dialog again, the program crashes. i don't want to delete the memory, just hide the dialog, or close it in some kind of way. i know it works locally, as when i close with the X, then i can open it again, but not when i receive the message. I searched in msdn, and it says EndDialog is or modal dialogs. So i tried DestroyWindow. I also tried ShowWindow(SW_HIDE) but it doen't work as well. I'd really appreciate any kind of help you could give me. Thanks in advance!

      J Offline
      J Offline
      Johan Rosengren
      wrote on last edited by
      #2

      If it is a modeless window - as I understand - then I should go for ShowWindow( SW_HIDE ). The drawbacks are that you might need to reinitialize controls when showing it again. Note that first, you create the window with Create. Then you use ShowWindow( SW_SHOW / SW_HIDE ) for all showing and hiding - you don't call Create again.

      1 Reply Last reply
      0
      • K kfaday

        Hello, i'm developing a chat program. There's a vector of pointers to Dialogs. When i open a chat window, a NEW is called to that dialog, then i call create and showwindow to show the dialog. The windows are deleted when i close the program. I'm not having trouble with that. When i close a window, i send a message to the remote client to close the window. The remote client receives this message in a function from the dialog, and there i want to close the dialog (not the remote one):

        		CVentanaPizarra::OnClose(); 
        		CDialog::EndDialog(0);
        

        In the OnClose I have the following:

        void CVentanaPizarra::OnClose()
        {
        //stuff i do
        CDialog::OnClose();
        }

        If i don't use EndDialog, the dialog doesn't close. If i use EndDialog, when i want to open the dialog again, the program crashes. i don't want to delete the memory, just hide the dialog, or close it in some kind of way. i know it works locally, as when i close with the X, then i can open it again, but not when i receive the message. I searched in msdn, and it says EndDialog is or modal dialogs. So i tried DestroyWindow. I also tried ShowWindow(SW_HIDE) but it doen't work as well. I'd really appreciate any kind of help you could give me. Thanks in advance!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        ShowWindow will work fine, but keep in mind, the more windows you create (and eventually hide again), the more memory your app will comsume. A better way would be to destroy the windows if you don't need them again and call delete this; in the PostNcDestroy-function of your dialogs. regards

        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