• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • 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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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