remotely closing a modeless dialog
-
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!
-
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!
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 withCreate
. Then you useShowWindow( SW_SHOW / SW_HIDE )
for all showing and hiding - you don't callCreate
again. -
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!
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 calldelete this;
in thePostNcDestroy
-function of your dialogs. regards