當前位置:編程學習大全網 - 編程語言 - 使用vc編程時, Tab Control切換兩個子窗口時,只能顯示第壹個,為什麽?

使用vc編程時, Tab Control切換兩個子窗口時,只能顯示第壹個,為什麽?

給妳壹個程序妳自己看看吧,不知道對妳有幫助沒?

BOOL CGraduationDlg::OnInitDialog()

{

CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.

ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);

if (pSysMenu != NULL)

{

CString strAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if (!strAboutMenu.IsEmpty())

{

pSysMenu->AppendMenu(MF_SEPARATOR);

pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

}

}

// Set the icon for this dialog. The framework does this automatically

// when the application's main window is not a dialog

SetIcon(m_hIcon, TRUE); // Set big icon

SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

m_tab.InsertItem(0,"前束與外傾角的匹配"); //添加參數壹選項卡

m_tab.InsertItem(1,"主銷內傾角和後傾角的匹配"); //添加參數二選項卡

m_dialog1.Create(IDD_DIALOG1,GetDlgItem(IDC_TABTEST));

m_dialog2.Create(IDD_DIALOG2,GetDlgItem(IDC_TABTEST));

//獲得IDC_TABTEST客戶區大小

CRect rs;

m_tab.GetClientRect(&rs);

//調整子對話框在父窗口中的位置

rs.top+=20;

rs.bottom-=0;

rs.left+=0;

rs.right-=0;

//設置子對話框尺寸並移動到指定位置

m_dialog1.MoveWindow(&rs);

m_dialog2.MoveWindow(&rs);

//分別設置隱藏和顯示

m_dialog1.ShowWindow(true);

m_dialog2.ShowWindow(false);

//設置默認的選項卡

m_tab.SetCurSel(0);

return FALSE; // return TRUE unless you set the focus to a control

}

void CGraduationDlg::OnSysCommand(UINT nID, LPARAM lParam)

{

if ((nID & 0xFFF0) == IDM_ABOUTBOX)

{

CAboutDlg dlgAbout;

dlgAbout.DoModal();

}

else

{

CDialog::OnSysCommand(nID, lParam);

}

}

// If you add a minimize button to your dialog, you will need the code below

// to draw the icon. For MFC applications using the document/view model,

// this is automatically done for you by the framework.

void CGraduationDlg::OnPaint()

{

if (IsIconic())

{

CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle

int cxIcon = GetSystemMetrics(SM_CXICON);

int cyIcon = GetSystemMetrics(SM_CYICON);

CRect rect;

GetClientRect(&rect);

int x = (rect.Width() - cxIcon + 1) / 2;

int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon

dc.DrawIcon(x, y, m_hIcon);

}

else

{

CDialog::OnPaint();

}

}

// The system calls this to obtain the cursor to display while the user drags

// the minimized window.

HCURSOR CGraduationDlg::OnQueryDragIcon()

{

return (HCURSOR) m_hIcon;

}

void CGraduationDlg::OnSelchangeGraduation(NMHDR* pNMHDR, LRESULT* pResult)

{

// TODO: Add your control notification handler code here

int CurSel = m_tab.GetCurSel();

switch(CurSel)

{

case 0:

m_dialog1.ShowWindow(true);

m_dialog2.ShowWindow(false);

break;

case 1:

m_dialog1.ShowWindow(false);

m_dialog2.ShowWindow(true);

break;

default:

;

}

*pResult = 0;

}

  • 上一篇:我最喜歡的明星:壹篇完美的中考作文。
  • 下一篇:全面重寫Autopilot,特斯拉自動駕駛的升維革命
  • copyright 2024編程學習大全網