Solved

Detect Exit in Dialog

Posted on 2006-06-09
4
573 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 93
Autosar OS Multicore Share Resources confusion ? 2 189
print bytes of an integer 6 47
C++ statement T∗ begin(Vector<T>& x) 5 41
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

738 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