Solved

Closing a Dialog Window

Posted on 2004-10-27
231 Views
Last Modified: 2013-11-20
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.
Steve
0
Question by:steva
    2 Comments
     
    LVL 55

    Accepted Solution

    by:
    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.
    0
     

    Author Comment

    by:steva
    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.

    Thanks,
    Steve
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
    Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    911 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now