VC中TAB控件在对话框上不显示标签 而是一个白板?
BOOLCDlgScoreAnalysis::OnInitDialog(){CDialog::OnInitDialog();//TODO:Addextrainitiali...
BOOL CDlgScoreAnalysis::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
TCITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = _T("成绩列表");
m_tab.InsertItem(0,&tcItem);
tcItem.pszText = _T("列表统计");
m_tab.InsertItem(1,&tcItem);
m_page1.Create(IDD_DLG_SCORELIST,&m_tab);
m_page2.Create(IDD_DLG_SCORESTATISTICS,&m_tab);
// m_page1.Create(IDD_DLG_SCORELIST,GetDlgItem(IDC_TAB));
// m_page2.Create(IDD_DLG_SCORESTATISTICS,GetDlgItem(IDC_TAB));
//设定在Tab内显示范围
CRect rect;
m_tab.GetClientRect(rect);
rect.top+=20;
rect.bottom-=8;
rect.left+=8;
rect.right-=8;
m_page1.MoveWindow(&rect);
m_page2.MoveWindow(&rect);
//用数组吧对话框对象指针保存起来
// pDialog[0]=&m_page1;
// pDialog[1]=&m_page2;
// //显示初始页面
// pDialog[0]->ShowWindow(SW_SHOW);
// pDialog[1]->ShowWindow(SW_HIDE);
m_page1.ShowWindow(SW_SHOW);
m_page2.ShowWindow(SW_HIDE);
m_tab.SetCurSel(0);
//保存当前选择
m_CurSelTab=0;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgScoreAnalysis::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString str;
m_CurSelTab=m_tab.GetCurSel();
switch(m_CurSelTab)
{
case 0:
m_page1.UpdateData(TRUE);
m_page1.ShowWindow(TRUE);
m_page2.ShowWindow(FALSE);
case 1:
m_page2.UpdateData(TRUE);
m_page1.ShowWindow(FALSE);
m_page2.ShowWindow(TRUE);
}
// pDialog[m_CurSelTab]->ShowWindow(SW_HIDE);
// m_CurSelTab=m_tab.GetCurSel();
// pDialog[m_CurSelTab]->ShowWindow(SW_SHOW);
*pResult = 0;
} 展开
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
TCITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = _T("成绩列表");
m_tab.InsertItem(0,&tcItem);
tcItem.pszText = _T("列表统计");
m_tab.InsertItem(1,&tcItem);
m_page1.Create(IDD_DLG_SCORELIST,&m_tab);
m_page2.Create(IDD_DLG_SCORESTATISTICS,&m_tab);
// m_page1.Create(IDD_DLG_SCORELIST,GetDlgItem(IDC_TAB));
// m_page2.Create(IDD_DLG_SCORESTATISTICS,GetDlgItem(IDC_TAB));
//设定在Tab内显示范围
CRect rect;
m_tab.GetClientRect(rect);
rect.top+=20;
rect.bottom-=8;
rect.left+=8;
rect.right-=8;
m_page1.MoveWindow(&rect);
m_page2.MoveWindow(&rect);
//用数组吧对话框对象指针保存起来
// pDialog[0]=&m_page1;
// pDialog[1]=&m_page2;
// //显示初始页面
// pDialog[0]->ShowWindow(SW_SHOW);
// pDialog[1]->ShowWindow(SW_HIDE);
m_page1.ShowWindow(SW_SHOW);
m_page2.ShowWindow(SW_HIDE);
m_tab.SetCurSel(0);
//保存当前选择
m_CurSelTab=0;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgScoreAnalysis::OnSelchangeTab(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString str;
m_CurSelTab=m_tab.GetCurSel();
switch(m_CurSelTab)
{
case 0:
m_page1.UpdateData(TRUE);
m_page1.ShowWindow(TRUE);
m_page2.ShowWindow(FALSE);
case 1:
m_page2.UpdateData(TRUE);
m_page1.ShowWindow(FALSE);
m_page2.ShowWindow(TRUE);
}
// pDialog[m_CurSelTab]->ShowWindow(SW_HIDE);
// m_CurSelTab=m_tab.GetCurSel();
// pDialog[m_CurSelTab]->ShowWindow(SW_SHOW);
*pResult = 0;
} 展开
1个回答
展开全部
#if !defined(AFX_MYTABCTRL_H__B78ED5AE_F226_11D8_9778_8B75F9B63865__INCLUDED_)
#define AFX_MYTABCTRL_H__B78ED5AE_F226_11D8_9778_8B75F9B63865__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyTabCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl window
class CMyTabCtrl : public CTabCtrl
{
// Construction
public:
CMyTabCtrl();
CDialog *m_tabPages[3];
int m_tabCurrent;
int m_nNumberOfPages;
// Attributes
public:
// Operations
public:
void Init();
void SetRectangle();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyTabCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyTabCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CMyTabCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYTABCTRL_H__B78ED5AE_F226_11D8_9778_8B75F9B63865__INCLUDED_)
/////////////////////////////////////////////////////////////////////////////////////////////////
// MyTabCtrl.cpp : implementation file
//
#include "stdafx.h"
//#include "Car.h"
#include "MyTabCtrl.h"
#include "CheckSelfDlg.h"
#include "CtrlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl
CMyTabCtrl::CMyTabCtrl()
{
m_tabPages[0]=new CCheckSelfDlg;
m_tabPages[1]=new CCtrlDlg;
//m_tabPages[2]=new CCheckSelfDlg;
m_nNumberOfPages=2;
}
CMyTabCtrl::~CMyTabCtrl()
{
for(int nCount=0; nCount < m_nNumberOfPages; nCount++){
delete m_tabPages[nCount];
}
}
void CMyTabCtrl::Init()
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_CHECK_SELF_DLG, this);
m_tabPages[1]->Create(IDD_CTRL_DLG, this);
// m_tabPages[2]->Create(IDD_CHANGE_DLG, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
// m_tabPages[2]->ShowWindow(SW_HIDE);
SetRectangle();
/*
CheckRadioButton(IDC_NET_CHECK_RADIO,
IDC_MANUAL_CHECK_RADIO,
IDC_NET_CHECK_RADIO);
UpdateData(FALSE);
*/
}
void CMyTabCtrl::SetRectangle()
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
nX=itemRect.left;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++){
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
//{{AFX_MSG_MAP(CMyTabCtrl)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl message handlers
void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTabCtrl::OnLButtonDown(nFlags, point);
if(m_tabCurrent != GetCurFocus()){
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
}
CTabCtrl::OnLButtonDown(nFlags, point);
}
#define AFX_MYTABCTRL_H__B78ED5AE_F226_11D8_9778_8B75F9B63865__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// MyTabCtrl.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl window
class CMyTabCtrl : public CTabCtrl
{
// Construction
public:
CMyTabCtrl();
CDialog *m_tabPages[3];
int m_tabCurrent;
int m_nNumberOfPages;
// Attributes
public:
// Operations
public:
void Init();
void SetRectangle();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyTabCtrl)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyTabCtrl();
// Generated message map functions
protected:
//{{AFX_MSG(CMyTabCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYTABCTRL_H__B78ED5AE_F226_11D8_9778_8B75F9B63865__INCLUDED_)
/////////////////////////////////////////////////////////////////////////////////////////////////
// MyTabCtrl.cpp : implementation file
//
#include "stdafx.h"
//#include "Car.h"
#include "MyTabCtrl.h"
#include "CheckSelfDlg.h"
#include "CtrlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl
CMyTabCtrl::CMyTabCtrl()
{
m_tabPages[0]=new CCheckSelfDlg;
m_tabPages[1]=new CCtrlDlg;
//m_tabPages[2]=new CCheckSelfDlg;
m_nNumberOfPages=2;
}
CMyTabCtrl::~CMyTabCtrl()
{
for(int nCount=0; nCount < m_nNumberOfPages; nCount++){
delete m_tabPages[nCount];
}
}
void CMyTabCtrl::Init()
{
m_tabCurrent=0;
m_tabPages[0]->Create(IDD_CHECK_SELF_DLG, this);
m_tabPages[1]->Create(IDD_CTRL_DLG, this);
// m_tabPages[2]->Create(IDD_CHANGE_DLG, this);
m_tabPages[0]->ShowWindow(SW_SHOW);
m_tabPages[1]->ShowWindow(SW_HIDE);
// m_tabPages[2]->ShowWindow(SW_HIDE);
SetRectangle();
/*
CheckRadioButton(IDC_NET_CHECK_RADIO,
IDC_MANUAL_CHECK_RADIO,
IDC_NET_CHECK_RADIO);
UpdateData(FALSE);
*/
}
void CMyTabCtrl::SetRectangle()
{
CRect tabRect, itemRect;
int nX, nY, nXc, nYc;
GetClientRect(&tabRect);
GetItemRect(0, &itemRect);
nX=itemRect.left;
nY=itemRect.bottom+1;
nXc=tabRect.right-itemRect.left-1;
nYc=tabRect.bottom-nY-1;
m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW);
for(int nCount=1; nCount < m_nNumberOfPages; nCount++){
m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW);
}
}
BEGIN_MESSAGE_MAP(CMyTabCtrl, CTabCtrl)
//{{AFX_MSG_MAP(CMyTabCtrl)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyTabCtrl message handlers
void CMyTabCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTabCtrl::OnLButtonDown(nFlags, point);
if(m_tabCurrent != GetCurFocus()){
m_tabPages[m_tabCurrent]->ShowWindow(SW_HIDE);
m_tabCurrent=GetCurFocus();
m_tabPages[m_tabCurrent]->ShowWindow(SW_SHOW);
m_tabPages[m_tabCurrent]->SetFocus();
}
CTabCtrl::OnLButtonDown(nFlags, point);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询