Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Activating window

Activating window

Scheduled Pinned Locked Moved C / C++ / MFC
data-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    F Dost
    wrote on last edited by
    #1

    does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost

    L F M 3 Replies Last reply
    0
    • F F Dost

      does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Yeah its pretty easy, use the SetActiveWindow (hwnd ) function.. You need to get the window handle for the window you want to activate though.. Do that by hwnd = FindWindow(NULL, "Put the window title here") SetActiveWindow (hwnd )

      1 Reply Last reply
      0
      • F F Dost

        does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost

        F Offline
        F Offline
        Felix Cho
        wrote on last edited by
        #3

        If you are talking about the MDI "document windows", you need to send WM_MDI* messages to the "MDI client", the window that is usually in the dark gray colour.

        1 Reply Last reply
        0
        • F F Dost

          does anyone know how make a window active when multiple windows are open. in an mdi applicatin under window menu item there is a list of all open files and the active one is checked, i want to know how that code works, so that when i click on my tree node that window should be activated, Thanks, F.Dost

          M Offline
          M Offline
          Masaaki Onishi
          wrote on last edited by
          #4

          Hello, the codegurus around the world.;) I often use this function from "HOW-TO VISUAL C++ 4.0" by Scott ? to change the active view on MDI application.

          void CMainFrame::SwitchToView(CDocTemplate* pTemplate, CRuntimeClass* pViewClass)
          {
          CMDIChildWnd* pMDIActive = MDIGetActive();
          CDocument* pDoc = pMDIActive->GetActiveDocument();
          CView* pView;

          POSITION pos = pDoc->GetFirstViewPosition();
          while(pos != NULL)
          {
          	pView = pDoc->GetNextView(pos);
          	if(pView->IsKindOf(pViewClass))
          	{
          		//the requested view has already been created; show it
          		pView->GetParentFrame()->ActivateFrame();
          		return;
          	}
          }
          
          //The requested view hasn't been created yet
          CMDIChildWnd\* pNewFrame = (CMDIChildWnd\*)
          	pTemplate->CreateNewFrame(pDoc, NULL);
          
          if(pNewFrame == NULL) return;
          
          pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
          

          }

          and call this function anywhere like this.

          ((CMainFrame\*)AfxGetMainWnd())->SwitchToView(theApp.m\_pAppTemplate,
          		RUNTIME\_CLASS(CAppView));
          

          Have a nice day! -Masaaki Onishi-

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups