Solved

Quiting an app from a CFormView button

Posted on 1998-06-15
8
266 Views
Last Modified: 2013-11-20
I have a SDI app consisting of a CFormView main window...I added a button to exit the program, how do I get
the app to quit when I click on the button (i.e., I know that I need to close the main frame window...but what is
the best way to do this)?
0
Comment
Question by:veltkamp
8 Comments
 
LVL 2

Accepted Solution

by:
rayb earned 50 total points
ID: 1317976
Simply call the Win32 function: PostQuitMessage()
0
 

Author Comment

by:veltkamp
ID: 1317977
While the above response will work...I get the following trace dump:

SENDING command id 0x03FE to CConvView target
PumpMessage - Received WM_QUIT
Warning: destroying CSingleDocTemplate with live document
Detected memory leaks!
Dumping objects ->
{19} strcore1.cpp(82) : non-object block at $3DB70BA8, 6 bytes long
{17} plex.cpp(29) : non-object block at $3DB709DE, 128 bytes long
{16} strcore1.cpp(82) : non-object block at $3DB709B2, 11 bytes long
{15} strcore1.cpp(82) : non-object block at $3DB70988, 9 bytes long
{14} File Conversion Utility: File wincore.cpp, Line 475, Assertion Failed!
ASSERT_VALID fails with illegal pointer
: File , Line 15183

So I was actually looking for an approach that follows the MFC  framework exit procedure
0
 

Author Comment

by:veltkamp
ID: 1317978
While the above response will work...I get the following trace dump:

SENDING command id 0x03FE to CConvView target
PumpMessage - Received WM_QUIT
Warning: destroying CSingleDocTemplate with live document
Detected memory leaks!
Dumping objects ->
{19} strcore1.cpp(82) : non-object block at $3DB70BA8, 6 bytes long
{17} plex.cpp(29) : non-object block at $3DB709DE, 128 bytes long
{16} strcore1.cpp(82) : non-object block at $3DB709B2, 11 bytes long
{15} strcore1.cpp(82) : non-object block at $3DB70988, 9 bytes long
{14} File Conversion Utility: File wincore.cpp, Line 475, Assertion Failed!
ASSERT_VALID fails with illegal pointer
: File , Line 15183

So I was actually looking for an approach that follows the MFC  framework exit procedure
0
 

Expert Comment

by:engllf
ID: 1317979
The cleanest way is to set the button ID to ID_APP_EXIT.
It follows the framework exit procedure.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Expert Comment

by:engllf
ID: 1317980
If you use PostQuitMessage, it will exits the message loop immediately and there is no proper cleanup.
0
 

Expert Comment

by:kalaru
ID: 1317981
In u'r view source file , add the foll code
void CFormTestView::OnButton2()
{
      // TODO: Add your control notification handler code here

      AfxGetMainWnd()->SendMessage(WM_CLOSE);
      
}

Button2 is the button in u'r FormView , on pressing which, WM_CLOSE is sent to the MainFrame. This will close the Appln on clicking the button in a Formview.
And there're no memory leaks also.

Hope this helps u.
Hope this works.
0
 

Author Comment

by:veltkamp
ID: 1317982
I was going to give this a "C" untill the comment by kalaru was added...his response was to the point and complete, earlier responses by engllf were a little off-the-cuff and not as well thought out.  If I know how to give 100 "A" points to kalaru, I'd do it!!

Thaks for both your help on this simple question.
0
 

Author Comment

by:veltkamp
ID: 1317983
Sorry engllf...I ment my earlier comment to apply mostly to rayb (the original responder) but didn't scoll up far enough to see his name when composing my message.  BTY, setting the button ID to ID_APP_EXIT has no effect...presses on the button were not handled and there was no action.  But thanks for trying to help!!.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

19 Experts available now in Live!

Get 1:1 Help Now