一个属性框,肯定有sheet与page把。怎么样给page添加标题呢?
以及如果sheet的大小变了,怎么样让page的大小也跟着变呢?
以及如果sheet的大小变了,怎么样让page的大小也跟着变呢?
解决方案 »
- 求助关于VC6.0的MFC动态连接库工程使用静态MFC库的问题
- 如何解析注册表里的 MSSMBIOS 信息
- 送分了!!!一个关于调用API函数操作串口写成的DLL问题!!!
- 紧急请教:如何从一个登录对话框链接到另一个窗口(在线等)
- 求教根据两点经纬度得到球面距离算法
- 自己学COM/ActiveX太郁闷,高分求相关的比较简单的例子!
- 紧急!!!有谁知道搜狐20M闪电邮件可容纳多大的附件?8M的邮件附件是否可容纳???在线给分!!!
- 用如下代码为何得不到状态条指针?
- ATL中可以使用AfxMessageBox函数吗?
- 关于VC数据库-向各位前辈请教
- ◎◎◎如何在工具条位图下面显示汉字◎◎◎
- 创建一个文件夹,容易吧!(我不会啊,哭~)
,不行!运行时coredump!
CString sCaption = _T("New Caption");
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
tcItem.pszText = (LPTSTR)((LPCTSTR)sCaption);
GetTabControl()->SetItem(0, &tcItem ); //第一个标签
2:移动page:
http://www.codeguru.com/propertysheet/move_resize_page.shtml
说清楚点可以吗?
{
// TODO: Add your message handler code here and/or call default
CFontSheet dlg("Test the font property sheet!"); //设置属性页的标题
CString strFontPage;
strFontPage.Format("Font (%d,%d)",point.x,point.y);
dlg.GetPage(0)->m_psp.pszTitle=strFontPage;
dlg.GetPage(0)->m_psp.dwFlags|=PSP_USETITLE;
CString strEffectPage;
strEffectPage.Format("Effect (%d,%d)",point.x+10,point.y+10);
dlg.GetPage(1)->m_psp.pszTitle=strEffectPage;
dlg.GetPage(1)->m_psp.dwFlags|=PSP_USETITLE; CString strColorPage;
strColorPage.Format("Color (%d,%d)",point.x+20,point.y+20);
dlg.GetPage(2)->m_psp.pszTitle=strColorPage;
dlg.GetPage(2)->m_psp.dwFlags|=PSP_USETITLE; dlg.DoModal();
CView::OnLButtonDblClk(nFlags, point);
}
BOOL CFontSheet::OnInitDialog()
{
CPropertySheet::OnInitDialog();
// TODO: Add extra initialization here //改变属性单的大小
//测试程序是在视图类中进行的
//设置属性单的宽度]为当前视图的宽的二分之一!
//不改变属性单的高度,可以省去移动属性页中的控件的麻烦!
CTabCtrl *pTab=this->GetTabControl();
CRect rectPage;
pTab->GetWindowRect(rectPage);
pTab->ScreenToClient(rectPage); //计算属性单和标签控件之间的间距
CRect winRect;
GetWindowRect(winRect);
int dx=winRect.Width()-rectPage.Width();
int dy=winRect.Height()-rectPage.Height(); CRect rectClient;
CMainFrame *pFrame=(CMainFrame*)AfxGetMainWnd();
CPropView *pView=(CPropView*)pFrame->GetActiveView();
pView->GetClientRect(rectClient);
pView->ClientToScreen(rectClient);
CPoint pt=rectClient.CenterPoint();
int height=rectClient.Height()*1/3;
int width=rectClient.Width()*2/3;
//移动并改变属性单窗口的尺 寸
SetWindowPos(NULL,pt.x-width/2,pt.y-height/2,width,winRect.Height(),SWP_NOZORDER|SWP_NOACTIVATE); //移动并改变标签控件的尺寸
pTab->SetWindowPos(NULL,0,0,width-dx,winRect.Height()-dy,SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE); //设置按钮的显示
CButton *pButtonOK,*pButtonCancel,*pButtonApply;
pButtonOK=(CButton*)GetDlgItem(IDOK);
pButtonCancel=(CButton*)GetDlgItem(IDCANCEL);
pButtonApply=(CButton*)GetDlgItem(ID_APPLY_NOW); GetClientRect(rectClient);
// 使各个按钮均匀分布在客户区
int left,right,middle,nSpace;
CRect rcOK,rcCancel,rcApply;
pButtonOK->GetWindowRect(rcOK);
ScreenToClient(rcOK);
pButtonCancel->GetWindowRect(rcCancel);
ScreenToClient(rcCancel);
pButtonApply->GetWindowRect(rcApply);
ScreenToClient(rcApply); nSpace=(rectClient.Width()-60-3*rcOK.Width())/2;
left=rectClient.left+30;
middle=left+nSpace+rcOK.Width();
right=middle+nSpace+rcCancel.Width();
pButtonOK->SetWindowPos(NULL,left,rcOK.top,0,0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
pButtonApply->SetWindowPos(NULL,right,rcApply.top,0,0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
pButtonCancel->SetWindowPos(NULL,middle,rcCancel.top,0,0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
//激活每个属性页,防止重画
int nCurPos=GetActiveIndex();
for(int i=0;i<GetPageCount();i++)
SetActivePage(i);
SetActivePage(nCurPos); return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
这是自动调整属性页大小的代码-----调整为视图窗口的宽度的2/3
---------------------------------
说明一下:
class CFontSheet : public CPropertySheet
{
}
class CFontPage : public CPropertyPage
{
}
class CEffectPage : public CPropertyPage
{
}
class CColorPage : public CPropertyPage
{
}
CFontSheet::CFontSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
//page 0;
AddPage(&m_FontPage);
//page 1;
AddPage(&m_EffectPage);
//page 2
AddPage(&m_ColorPage);
EnableStackedTabs(false);//设置标签为滚动显示方式!
}
-----------------------
必须在OnInitDialog()中设置属性页的位置。在别的地方没用!