-
January 20th, 2013, 10:37 AM
#1
Communicating between ChildView and PropertiesView class in MSVC++ MDI/MFC/Doc/View
Hello to everyone,
I have a standard MSVC++ 2012 project created with the project wizard as follows...
Is a MDI/MFC/Doc/View project
Has Tabbed Children Views
It has an extra Properties window created by the wizard called PropertiesWnd.cpp
PropertiesWnd.cpp uses a CMFCPropertyGridProperty control to display properties.
(I understand how to use this control)
------------------------------------------------------
Scenario:
When I click inside a ChildView window, I need for information about that view to be displayed in the properties control on PropertiesWnd.cpp.
Another way to word my Scenario is to say...
I need to access properties of the Child View class from the the PropertiesWnd class to update the properties control when I click the child view window.
------------------------------------------------------
Some Info...
You can't #include the ChildView.h file in the PropertiesWnd.cpp or .h file. It breaks the architecture.
Therefore, I dont understand the architecture rqmts to do this.
I tried to do this inside my PropertiesWnd.cpp � But it breaks the architecture because to do this I must #include the ChildView.h file inside PropertiesWnd.cpp or PropertiesWnd.h�
Inside a function I put...
...
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->GetMainWnd();
CMDIChildWnd *pChild = (CMDIChildWnd*)pFrame->GetActiveFrame();
yourMDIView *pView = (yourMDIView*)pChild->GetActiveView();
// Now update the variable or member of your choice
pView->a = 1;
...
The code itself works, but the framework will not allow it.
So My Question Is:
How can I update my properties window with variables from the ChildView that I click on?
I need to be able to access the data of the ChildView from the PropertiesWnd.cpp
Or
How can/should this be done?
Thank you very much for your help.
-
January 21st, 2013, 05:53 AM
#2
Re: Communicating between ChildView and PropertiesView class in MSVC++ MDI/MFC/Doc/Vi
Originally Posted by arealperson
So My Question Is:
How can I update my properties window with variables from the ChildView that I click on?
I need to be able to access the data of the ChildView from the PropertiesWnd.cpp
Or
How can/should this be done?
You should get the data from the document, not the view. Get the active document by calling CFrameWnd::GetActiveDocument.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|