[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

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);

0
Sherpa
Asked:
Sherpa
  • 2
1 Solution
 
MarkusLoiblCommented:
Do you really need 2 Doc-Templates?
I think, dynamically switching different views having the same document) is not a problem!
0
 
AVaulinCommented:
Use ((CMDIFrameWnd*)AfxGetMainWnd())->MDINext().
0
 
SherpaAuthor Commented:
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.

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now