Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending focus from one CDialog to another

Status
Not open for further replies.

Vachaun22

Programmer
Oct 7, 2003
171
0
0
US
I have a CSplitterWnd that loads to dialog resources into it. One dialog contains a CTreeCtrl only, and the other contains various other controls.

Currently I have the dialog with only the tree control attached to accelerators, in which case I have overridden PreTranslateMessage to attach command handlers to tab/shift+tab presses on the tree control.

At this point, I get the parent window (which has member variables for each pane in the splitter) and reference the variable for the right pane which has a public function that is to set focus to one of it's controls.

The code path works, as TRACE0 messages are being output as expected. However, if I try to work with any of the controls in the right panes dialog window, I'm getting an assertion.

The assertion occurs as a result of

CEdit* pWnd = (CEdit*)GetDlgItem( IDC_ESN );

being called. And the assertion is thrown from winocc.cpp at line 92:

CWnd* CWnd::GetDlgItem(int nID) const
{
ASSERT:):IsWindow(m_hWnd)); // <-- ASSERTION

if (m_pCtrlCont == NULL)
return CWnd::FromHandle:):....
....
}

So I see that m_hWnd isn't a window, but I'm not sure why. Am I to assume that m_hWnd is actually the HWND of the dialog?

If you can assist me with passing control focus from one dialog window to another, that'd be great.
 
I figured out my problem. I wasn't get enough ancestors when I was getting the parent window of the dialog with the tree control.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top