Sign in to follow this  
fathom88

Question On Creating PopUp Dialog Window

Recommended Posts

I have a silly question on creating a pop up dialog window. I'm trying to have a new dialog window pop up a window on a button press. Inside my OnButtonPress function, I wrote CMyDialogWin *NewWindow = new CMyDialogWin; NewWindow->Create(ID_POP_WIN); NewWindow->ShowWindow(SW_SHOW); This seems to work fine. However, I think the memory allocated by new is still present. The pop up window exits on its own via the OnOK/OnClose button press. I changed the code to CMyDialogWin NewWindow; NewWindow.Create(ID_POP_WIN); NewWindow.ShowWindow(SW_SHOW); This would remove the memory problem, but the window does not pop up correctly. It appears for a quick moment and goes away. What is the correct way to create a pop up window? Thanks.

Share this post


Link to post
Share on other sites
Assuming you're using MFC and this is a CWnd derivative, you can simply do delete this; in an override of CWnd::PostNcDestroy (). The other way to do this would be to call CWnd::DestroyWindow () when you need the window and class object destroyed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this