Solved

Associating a dialog box to a view

Posted on 1997-12-10
1
183 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

770 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