Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

parent

Posted on 1999-07-07
3
Medium Priority
?
240 Views
Last Modified: 2013-11-20
if an application is mdi, who is the parent of the view window(either mdichild or mdimainframe). GetParentFrame inside view will give pointer to child or mainframe
0
Comment
Question by:sunraj
[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
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 20 total points
ID: 1309211
GetParentFrame will give you the child frame of view. To get to main frame of app, call AfxGetMainWnd and then cast it to CFrameWnd.

CWnd *pWnd = AfxGetMainWnd ();
CFrameWnd *pFrame = static_cast<CFrameWnd *>(pWnd);
0
 

Author Comment

by:sunraj
ID: 1309212
what does the keyword static_cast mean here...

can you please tell what is static_cast
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1309213
This is one of the casting operators. Its recommended to use the casting operators. static_cast is not very safe cause it does not do any run time checking for the casting. e.g. in this case we know that pWnd is CFrameWnd type object, so i safely u sed static_cast. The safe one is dynamic_cast. It does the runtime checking to check if the pointer is being casted to right type.
Lets say that i have an pointer to CTreeCtrl and if i try to cast it as CEdit then i am totally screwing up the memory of that object. And if i try to use that pointer , it will Assert...

so the right way is that first i make sure that the pointer is of type to which i am casting ..

like

if (pWnd->IsKindOf (RUNTIME_CLASS (CEdit)) {
CEdit *pEdit = dynamic_cast<CEdit *>(pWnd);
}

For more information .. have look at the online documentation for these casting operators. Its way of making sure that we are not doing any illegal pointer castings.


Hope this info helps!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

660 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