我在我的对话框条CAdjustDlg中添加一个tab控件,CAdjustDlg在CMainFrame中创建,停靠在主窗口下方,我在执行的时候tab控件却显示不了,我的代码如下,希望得到高手指点,如果需要,可以留下qq或者e-mail,我把源代码发过去。
/////////////////////////////////////////////////////////////////////////////
// CAdjustDlg message handlersvoid CAdjustDlg::InitTabCtrl()
{
    m_Tab1.InsertItem(0,_T("123"));
    m_dlgSsfs.Create(IDD_ADJUST_SSFS, this);//
m_pDlg1[0] = &m_dlgSsfs; m_Tab1.InsertItem(1,_T("456"));
    m_dlgSsjs.Create(IDD_ADJUST_SSJS,this);//
    m_pDlg1[1] = &m_dlgSsjs;

m_Tab1.InsertItem(2,_T("789"));
    m_dlgZytz.Create(IDD_ADJUST_ZYTZ,this);//
    m_pDlg1[2] = &m_dlgZytz;
}BOOL CAdjustDlg::OnInitDialog() 
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
    InitTabCtrl();

    ShowDialog(0);    // 
       
    return TRUE;  // return TRUE unless you set the focus to a control
         // EXCEPTION: OCX Property Pages should return FALSE
}void CAdjustDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult) 
{
// TODO: Add your control notification handler code here
    ShowDialog(m_Tab1.GetCurSel());
*pResult = 0;
}void CAdjustDlg::ShowDialog(int nShow)
{
    CRect rect;
    m_Tab1.GetWindowRect(rect);
    m_Tab1.AdjustRect(FALSE, rect);
 //   ScreenToClient(rect);    for (int n = 0; n < 3; n++)
{
        if (nShow == n)
        {
            m_pDlg1[n]->MoveWindow(rect);
            m_pDlg1[n]->ShowWindow(SW_SHOW);
        }
         else
        {
            m_pDlg1[n]->ShowWindow(SW_HIDE);
        }
    }}BOOL CAdjustDlg::DestroyWindow() 
{
// TODO: Add your specialized code here and/or call the base class
    m_dlgSsjs.DestroyWindow();
    m_dlgSsfs.DestroyWindow();
    m_dlgZytz.DestroyWindow();
    return CDialog::DestroyWindow();
}

解决方案 »

  1.   

    m_Tab1.GetWindowRect(rect);得到的是屏幕坐标,m_pDlg1[n]->MoveWindow(rect);需要的是相对父窗口的坐标你在m_Tab1.GetWindowRect(rect);后加上ScreenToClient(&rect) 适宜市
      

  2.   

    在m_Tab1.GetWindowRect(rect);后加上ScreenToClient(&rect)
    还是不行啊
      

  3.   

    dialog是怎么创建的,如果是dialogbar,OnInitDiaolg是不执行的
      

  4.   

    是dialogbar,有什么办法可以补救吗?