Solved

Associating a dialog box to a view

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now