Link to home
Start Free TrialLog in
Avatar of Sherpa
Sherpa

asked on

switching between MDI child windows of different views

How can I programmatically switch between two open child windows (of different views) in a MDI application from CMainApp, the same way as it is done by selecting a window via the menu? (i.e. the corresponding window comes to the top, becomes active and has focus, etc...)

A kind of BringWindowToTop or SetWindowPos should make it, but it doesn't seem to work on MDI childs...

My documents and views are initialized in InitInstance as follows:

      CMultiDocTemplate* pDocTemplate1;
      pDocTemplate1 = new CMultiDocTemplate(
            IDR_TYPE1,
            RUNTIME_CLASS(CDoc1),            // document 1
            RUNTIME_CLASS(CChildFrame),       // custom MDI child frame
            RUNTIME_CLASS(CView1));            // view 1
      AddDocTemplate(pDocTemplate1);

      CMultiDocTemplate* pDocTemplate2;
      pDocTemplate2 = new CMultiDocTemplate(
            IDR_TYPE2,
            RUNTIME_CLASS(CDoc2),            // document 2
            RUNTIME_CLASS(CChildFrame),       // custom MDI child frame
            RUNTIME_CLASS(CView2));            // view 2
      AddDocTemplate(pDocTemplate2);

Avatar of MarkusLoibl
MarkusLoibl
Flag of Germany image

Do you really need 2 Doc-Templates?
I think, dynamically switching different views having the same document) is not a problem!
ASKER CERTIFIED SOLUTION
Avatar of AVaulin
AVaulin
Flag of Ukraine image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sherpa
Sherpa

ASKER

Sorry, my fault :-)
I didn't explain my problem good enough...
I don't want to switch just to the next view, but to a (known) definite one among possibly many other open ones.
And I don't want to make a loop through all my open views to find the one I want to bring to top.

Avatar of Sherpa

ASKER

To MarkusLoibl:
Yes, unfortunately I really need to have two document templates...