Solved

Quiting an app from a CFormView button

Posted on 1998-06-15
8
286 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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
 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 35
dog bark java program 15 95
post4 challenge 28 100
Updating statistics with error notification email in SQL server 4 95
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

773 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