Solved

What's the function call that closes a dialog window?

Posted on 2003-12-01
3
209 Views
Last Modified: 2013-11-20
void MyProgramDlg::OnBnClickedButtonClose()
{
}

Is there a function call like kill() or terminate() which will close the dialog window?
This question may sound stupid but the problem is that I could not find such function on MSDN....
Thanks!
0
Comment
Question by:UltimateApocalypse
3 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 20 total points
ID: 9850027
void MyProgramDlg::OnBnClickedButtonClose()
{
       CDialog::OnOK(); // or use  CDialog::OnCancel();
}

Rosh :)
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 9850219
I don't think you can call the message handlers directly.  Some message handlers handle the original message, not the one for the handler you call, so Microsoft discourages it.

A better choice may be to call CDialog::EndDialog(nResult) which also allows you to specify any return value you want (nResult is the resturn value of DoModal().

Hope this helps.
0
 

Author Comment

by:UltimateApocalypse
ID: 9851840
Thanks, both answers work!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
has77  challenge 9 97
Unix Command -- Challenging  question 7 101
How to convert MFC::CString to UTF8 wchar_t* 10 372
mapAB Challlenge 35 173
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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