> WINDOWPLACEMENT m;
> ((CMainFrame*)((CCmApp
> *)AfxGetApp())->GetMainWnd())->GetWindowPlacement(&m);
> if (m.showCmd == SW_SHOWMINIMIZED)
> {
>       m.showCmd = SW_SHOWMAXIMIZED;
>       ((CMainFrame*)((CCmApp
> *)AfxGetApp())->GetMainWnd())->SetWindowPlacement(&m);
>
>       CTabCtrl m_TabControl;
>       int tab_index =1;
>       m_TabControl.SetCurSel(tab_index);

Why are you declaring a tab control here? You need to get hold of the tab
control already on your dialogue. You can most easily do this by using
ClassWizard to map the component's ID to a CTabCtrl member variable (the m_
prefix was a hint that it was a member of your class).

The reason it asserts is because you declare a tab control but never call
Create() on it, so there's no Windows component - most class member methods
in MFC classes only work when there's a Windows component attached to the
class.

> }

Having seen your reply to Phil about what you're doing, I recommend calling
ShowWindow(SW_SHOWMAXIMIZED), not using GetWindowPlacement() and
SetWindowPlacement(). Although they work, ShowWindow() seems more
appropriate here and is less cumbersome to use.

Your code would become:

> CWnd *pWndMain = AfxGetMainWnd();
> if (pWndMain->IsIconic() )
>{
>       pWndMain->ShowWindow(SW_SHOWMAXIMIZED);
>
>       int tab_index =1;
>       m_TabControl.SetCurSel(tab_index);      // m_TabControl is mapped.
>}

(AfxGetMainWnd() is a built-in shortcut for AfxGetApp()->m_pMainWnd)

Let us know if you need more help, such as mapping controls to member
variables.

--
Jason Teagle
[EMAIL PROTECTED]




Reply via email to