Link to home
Start Free TrialLog in
Avatar of lukis
lukis

asked on

set focus on view

I have a sdi split window app.

From a function in one view I would like to put the focus back on the other view.

I asked this Q before, and I was told I could use:
CSplitterWnd::GetActivePain()
from Anywhere in my code.

Or do the following:
CView1::function()
{
  // code above
   pview2->SetFocus();
}

the problem I have is how do I use SetActivePane from within a cview class. Do I need to get the CSplitterWnd object from CMainFrame? How?

And if I was using the second method how do I get pview2 so that it corresponds to the view on screen.

I think both probs are along similar lines, and probably indicate some lack of understanding in c++.

If someone could please explain to me how I should be trying to so this I would be very grateful.
thanks.
ASKER CERTIFIED SOLUTION
Avatar of naveenkohli
naveenkohli

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 lukis
lukis

ASKER

thanks,
but doesn't this require me to already have the correct csplitterwnd object to pass to the function?
How do I get this object if it is in the CmainFrame object?
This is a utility function which you can use from anywhere. Since the splitter window variable is in mainframe therefore it is easy to get to it cause we can get the pointer to mainframe from anywhere. Declare the CSplitterWnd memeber variable as public in CMainFrmae class and then whereever u need it, get the pointer to mainframe and then use it.

CMainFrame *pFame = static_cast<CMainFrame *>(AfxGetMainWnd ());
ASSERT (pFrame != NULL);

// Then we have access to spliter window variable
//pFRame->m_wnSpliterWnd;
Avatar of lukis

ASKER

Thanks. I really appreciate the help.