Click here to Skip to main content
16,008,299 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello Friends,

I have created a MFC-MDI app, in which I want to switch view/Open View on a menu click. I am able to open new view, but if view is already opened I want to switch the view and make it active view. But I am not able to activate that view even it is already opened.
I used SetActiveView()and also tried to send message to view, and handle it in view, but not getting expected output. Can anyone help me in this?

Thanks in advance.
Posted

you need to get hold of the view pointer you want to activate
then get its parent frame and call ActivateFrame;

lets say u have the pointer of the view you want to active

CView *pview;
//
// you get pview the view you want to activate
//
//next you just do the following
pview->GetParentFrame()->ActivateFrame(SW_RESTORE);




thats it.

regards
rajesh
 
Share this answer
 
v2
Comments
aamswe 7-Feb-11 1:09am    
Thanks Rajesh!
it works!
I was doing SetActiveWindow() on view pointer, which was not working
SetActiveView should work.
Are you using the correct parent frame object to call the method?

You can also try other methods like BringWindowToTop and SetFocus.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900