?
Solved

Quiting an app from a CFormView button

Posted on 1998-06-15
8
Medium Priority
?
314 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
[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
8 Comments
 
LVL 2

Accepted Solution

by:
rayb earned 150 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
Independent Software Vendors: 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!

 

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

Independent Software Vendors: 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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

777 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