Click here to Skip to main content
15,749,281 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.

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

thats it.

Share this answer
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