Solved

Associating a dialog box to a view

Posted on 1997-12-10
1
188 Views
Last Modified: 2010-04-10
I have a dialog box which has some controls. I want to invoke it from a menu item in a view. Also, I want to handle the ONCOMMAND handlers of the dialog box controls in the view. When I added code for the dialog, I selected 'Select and existing class' and I selected the view class, instead of 'Add a new class'.
The problem is, in the below code, since I did not specify a separate class 'Dialog' when I built the dialog, I cannot even call the Domodal function.
void View::OnShowDialog()
{
      Dialog dlg;
      dlg.DoModal();
}
How to achieve what I want to?
Thanks.
0
Comment
Question by:pcasxd0
1 Comment
 
LVL 7

Accepted Solution

by:
galkin earned 50 total points
ID: 1175760
If you want to handle command messages by view and not dialog you must do the following:
1.Pass pointer to the view to dialog constructor, and store this pointer in dialog member variable.
2.Overide OnCmdMessage for your dialog class and in this function call m_pView->OnCmdMessage, whether m_pView is pointer to view class.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

792 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