别人的一个问题,大家来讨论讨论!
sxbyl 2001-01-14 02:57:00 最近脑子里一团浆糊,这个问题在浆糊里搅了几圈每搅出个好的解决方法,大家帮忙看看,好的解决方案大分送上。(因为结果不可预知,所以加分在结账的时候进行),问题如下:
主要是CTabCtrl控件的使用问题,可能很傻?
下面这一段摘自msdn:
A "tab control" is analogous to the dividers in a notebook or the label is a file cabinet ,
by using a tab control, an application can define multiple pages for the saem area o a window
or dialog box, Each page consist of a set of information of a group of controls that the application
displays when the user selects the corresponding tab, A special type of Tab control idsplay tabs
that look like buttons, clicking a button should immediately perorm a command instead of displaying
a page.
the CTabCtrl class provides the functionity of the windows common tab control.
总的来说,就是实现很多windows程序中的属性对话框的问题,属性对话框在vc中编程时,用到CPropertyPage
& CPropertySheet,并提供“确认”,“取消”,“应用”按纽。
我现在在CFormView中使用CTabCtrl控件,由于我的客户区被分成左右部分(右边用来绘制矢量图 CView)
CFormView被放在客户区左边。
可怕的是在CFormView中要放置>120个以上的控件,如果分成6页来实现将是比较可以的(还有别的办法吗?)
遇到这样的问题想到CTabCtrl控件是可以理解的,VC++中的Project--setting 就是这样的应用。
在dephi中,可以在设计阶段选择CTabCtrl(是这个名字吗?)的不同页面来设计各自的界面,但vc中不行,
好象vb中也不行,而很多vc的资料中讲CTabCtrl控件的用法时,提供了如下方法:
1:映射CTabCtrl控件的TCN_SELCHANGE(TCN_SELCHANGING?)消息事件,
2:在其中调用GetCurSel()函数确定控件的哪一页获的焦点。
如下:
void CXXXView::OnSelchangeXXX(NMHDR* pNMHDR,LRESULT* pResult)
{
Switch(GetCurSel())
{
case 页面一:
页面一的处理代码;
case 页面二:
....
}
}
下面是页面一处理代码的示例:
#define SIZEOF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
{
static UINT aGroup1[]={DLG_CHBOX1,DLG_CHBOX2,DLG_CHBOX3,....}
static UINT aGroup2[]={DLG_LABEL2,DLG_LABLE7,...}
ShowControls(aGroup1,SIZEOF_ARRAY(aGroup1),TRUE);
ShowControls(aGroup2,SIZEOF_ARRAY(aGroup2),FALSE);
}
void CXXXView::ShowControls(UINT* pControls,UINT cControls,BOOL fVisible)
{
for(UINT nIndex=0;nIndex<cControls,nIndex++)
{
CWnd* pwnd=GetDlgItem(pControls[nIndex]);
if(pwnd)
{
pwnd->ShowWindow(fVisible?SW_SHOW:SW_HIDE);
pwnd->EnableWindow(fvisible);
}
}
}
在处理其他事件。
这样做导致的结果是,在CFormView中我必须放6组以上的控件(每组>20个),并且得堆着放?
天哪?如果我要修改,我该怎么办?
有更好的办法吗?