SetFocus in CDialogBar
10-Jul-94 08:33:47
Sb: #30395-SetFocus in CDialogBar
Fm: Steve McAdams 72274,3160
To: Charles Beavers 71240,612
>> but I can't see how to get a pointer to the main frame from the view <<
The following will, in general, get the main frame for you from anywhere:
CWnd* frame = AfxGetApp()->m_pMainWnd; // all you need in many cases
if (frame != NULL)
{
CWnd* temp = frame->GetParentFrame(); // in case set to view
if (temp != NULL) frame = temp;
}
There is more code that you need to be absolutely bulletproof from anywhere
under any conditions (such as when m_pMainWnd is NULL). If you ensure that
your frame is pointed to by m_pMainWnd (such as by specifically setting
m_pMainWnd in the frame's OnCreate handler) you only need the first line of the
above. -steve [McAdams Research]