Solved

Detect Exit in Dialog

Posted on 2006-06-09
4
574 Views
Last Modified: 2012-06-21
Hi, i made a MFC Dialog.....how do i know if user exit with pressing F4 so that i can perform something before the dialog exit?
Thanks in advance
0
Comment
Question by:iphone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 16875786
Do you mean Alt+F4? Handle WM_CLOSE message:

void CtMyDlg::OnClose()
{
    // Put your code here.
    // Call CDialog::OnClose to close dialog.
    // return without calling CDialog::OnClose to prevent closing dialog.

    CDialog::OnClose();
}

OnClose function is called when user presses Alt+F4, clicks Close button in the title bar, or selects Close from system menu.
0
 

Author Comment

by:iphone
ID: 16875828
I have put in the code, i tried remove the line CDialog::OnClose(); yes it wont close when pressing alt+f4 meaning it really call the onclose function but then when i put in CDialog::OnClose() as my dialog is CMagazineCleanUpDlg so it looks like CMagazineCleanUpDlg::OnClose() ofcause, but it wont exit and the whole dialog hang, i will have to press ctrl+alt+del and terminate the process.why?
0
 
LVL 48

Expert Comment

by:AlexFM
ID: 16875847
>> so it looks like CMagazineCleanUpDlg::OnClose() ofcause.

This creates endless recursion. It should be CDialog::OnClose - call to base class function.
0
 

Author Comment

by:iphone
ID: 16875877

oh sorry my mistake...problem solve, thanks alot
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

726 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