Solved

Associating a dialog box to a view

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

Technology Partners: 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
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 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.

729 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