?
Solved

MDI application with multiple forms

Posted on 2003-02-24
10
Medium Priority
?
273 Views
Last Modified: 2013-11-20
Hi;
I have two forms in Application. In each form
I have a button called exit. I want to close
the corresponding form when I click on the
exit button. How can I handle this?

I tried to trigger OnClose() and OnDestroy()
functions from the exit button click event but
obviously that didn't work. What should i do?
Please help me

0
Comment
Question by:Ashik
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 8007236
PostMessage(WM_CLOSE, 0, 0);
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8007310
Call CDialog::OnOK on CDialog::OnCancel

Good Luck
0
 
LVL 2

Accepted Solution

by:
kozmo_jonny earned 400 total points
ID: 8007460
by writing: PostMessage(WM_CLOSE, 0, 0);

its the same as writing "OnClose()",

what u should write is:

GetParent()->PostMessage(WM_CLOSE, 0, 0);
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!

 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8007562
sorry it was a spelling mistake...

Call CDialog::OnOK
Or CDialog::OnCancel

Good Luck
0
 
LVL 2

Expert Comment

by:kozmo_jonny
ID: 8007576
roshmon:

if u would have checked your code before applying it here u would have got the following message:

error C2248: 'OnOK' : cannot access protected member declared in class 'CDialog'
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 8007610
I think the questioner is saying 'form' for the derived class of CDialog (May be he is a VB programmer).

thats Y I commented like that.

Roshmon
0
 
LVL 2

Expert Comment

by:kozmo_jonny
ID: 8007775
u'r right, but this is not the VB section, but the MFC section.

ciao
0
 

Author Comment

by:Ashik
ID: 8008036
Hi Mr. Kozmo Jonny
It is working fine .....
GetParent()->PostMessage(WM_CLOSE, 0, 0);
Thanks a lot
0
 
LVL 2

Expert Comment

by:kozmo_jonny
ID: 8008089
all u need 2do now is hand in the points ;-)))

u'r more than welcome
0
 

Author Comment

by:Ashik
ID: 8093699
Hi;
GetParent()->PostMessage(WM_CLOSE, 0, 0);
worked fine
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

571 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