[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

Closing a Dialog Window

I would like to close my dialog window from button code. I can see that EndDialog() is probaby the routine to call but it wants a "handle" to the dialog window.  How can I get this from my code.  It doesn't seem to be passed in.

Thanks for any help.
1 Solution
Jaime OlivaresSoftware ArchitectCommented:
If you are working with a MFC CDialog derived class, you don't need a handle. Just call EndDialog(IDOK).
It is the CDialog::EndDialog function member: http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_cdialog.3a3a.enddialog.asp
The unique argument is a result value, could be any integer value you want, but I recommend you to use IDOK constant to simulate an "OK" pressure.
stevaAuthor Commented:
Ok, that works fine.  I was looking at the EndDialog() for Windows Management, that returns a BOOL and takes a HWND parameter.  Apparently when you're in a Dialog button routine you default to the EndDialog() you pointed to rather than the one I was looking at.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now