没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|其它|编辑:郝浩|2006-02-16 16:51:00.000|阅读 1730 次
概述:
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
为了最大限度的发挥属性页的效用,首先让我们先从 CPropertySheet 继承一个新类,取名为 CMyPropSheet.
接着便可以进行下面的各种操作:
一、隐藏属性页默认按钮
隐藏掉Apply应用按钮:
propsheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
或隐藏掉Cancel取消按钮:CWnd *pWnd = GetDlgItem( IDCANCEL );
pWnd->ShowWindow( FALSE );
二、移动属性页按钮
首先,要获取按钮的句柄,然后就可以象对待窗体一样处理它们了. 下面代码先隐藏掉Apply和Help铵钮,再把OK和Cancel按移动到右侧。
BOOL CMyPropSheet::OnInitDialog ()
{
BOOL bResult = CPropertySheet::OnInitDialog();
int ids [] = {IDOK, IDCANCEL};//, ID_APPLY_NOW, IDHELP
};
// Hide Apply and Help buttons
CWnd *pWnd = GetDlgItem (ID_APPLY_NOW);
pWnd->ShowWindow (FALSE);
pWnd = GetDlgItem (IDHELP);
pWnd->ShowWindow (FALSE);
CRect rectBtn;
int nSpacing = 6; // space
between two buttons...
for( int i =0; i < sizeof(ids)/sizeof(int); i++)
{
GetDlgItem (ids [i])->GetWindowRect
(rectBtn);
ScreenToClient (&rectBtn);
int btnWidth =
rectBtn.Width();
rectBtn.left =
rectBtn.left + (btnWidth + nSpacing)* 2;
rectBtn.right =
rectBtn.right + (btnWidth + nSpacing)* 2;
GetDlgItem (ids [i])->MoveWindow(rectBtn);
}
return bResult;
}
下面代码移动所有按钮到右侧,并且重新置属性页为合适的大小.
BOOL CMyPropSheet::OnInitDialog ()
{
BOOL bResult = CPropertySheet::OnInitDialog();
int ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW };
CRect rectWnd;
CRect rectBtn;
GetWindowRect (rectWnd);
GetDlgItem (IDOK)->GetWindowRect (rectBtn);
int btnWidth = rectBtn.Width();
int btnHeight = rectBtn.Height();
int btnOffset = rectWnd.bottom - rectBtn.bottom;
int btnLeft = rectWnd.right - rectWnd.left;
rectWnd.bottom = rectBtn.top;
rectWnd.right = rectWnd.right + btnWidth + btnOffset;
MoveWindow(rectWnd);
rectBtn.left = btnLeft;
rectBtn.right = btnLeft + btnWidth;
for (int i = 0; i < sizeof (ids) / sizeof (int); i++)
{
rectBtn.top = (i + 1) *
btnOffset + btnHeight * i;
rectBtn.bottom = rectBtn.top +
btnHeight;
GetDlgItem (ids [i])->MoveWindow
(rectBtn);
}
return bResult;
}
三、改变属性页上的标签文字
首先修改TC_ITEM结构,然后用 SetItem 来修改标签文字,如下代码:
TC_ITEM item;
item.mask = TCIF_TEXT;
item.pszText = "New Label";
//Change the label of the first tab (0 is the index of the
first tab)...
GetTabControl ()->SetItem (0, &item);
四、改变属性页标签文字的字体属性
代码如下m_NewFont.CreateFont (14, 0, 0, 0, 800, TRUE, 0, 0, 1, 0, 0, 0, 0, _T("Arial")
);
GetTabControl()->SetFont (&m_NewFont);
五、在属性页标签上显示位图
可以用 CImageList 建立图像. 用 SetItem 来设置,如下代码所示:
BOOL CMyPropSheet::OnInitDialog ()
{
BOOL bResult = CPropertySheet::OnInitDialog();
m_imageList.Create (IDB_MYIMAGES, 13, 1,
RGB(255,255,255));
CTabCtrl *pTabCtrl = GetTabControl ();
pTabCtrl->SetImageList (&m_imageList);
TC_ITEM item;
item.mask = TCIF_IMAGE;
for (int i = 0; i < NUMBER_OF_TABS; i++)
{
item.iImage = i;
pTabCtrl->SetItem (i, &item );
}
return bResult;
}
六、在属性页左下角显示位图
如下代码所示:
void CMyPropSheet::OnPaint ()
{
CPaintDC dc(this); // device
context for painting
int nOffset = 6;
// load IDB_BITMAP1 from our
resources
CBitmap bmp;
if (bmp.LoadBitmap (IDB_BITMAP1))
{
// Get the
size of the bitmap
BITMAP
bmpInfo;
bmp.GetBitmap (&bmpInfo);
// Create an
in-memory DC compatible with the
// display DC we''re using to
paint
CDC
dcMemory;
dcMemory.CreateCompatibleDC (&dc);
// Select the bitmap into the
in-memory DC
CBitmap*
pOldBitmap = dcMemory.SelectObject (&bmp);
// Find a
bottom-left point for the bitmap in the client area
CRect
rect;
GetClientRect (&rect);
int nX
= rect.left + nOffset;
int nY
= rect.top + (rect.Height () - bmpInfo.bmHeight) - nOffset;
// Copy the
bits from the in-memory DC into the on-
// screen DC to actually do the
painting. Use the centerpoint
// we computed for the target
offset.
dc.BitBlt (nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory, 0, 0, SRCCOPY);
dcMemory.SelectObject (pOldBitmap);
}
// Do not call CPropertySheet::OnPaint()
for painting messages
}
七、在属性页右下角显示3D文字Logo
代码如下:
void CMyPropSheet::OnPaint ()
{
//在TAB按钮旁边显示3D文字提示,jingzhou xu
Cstring m_LogoName = “属性页”;
// if(m_LogoName == "")
// return;
GetWindowRect(rect);
ScreenToClient(rect);
LOGFONT logFont;
ZeroMemory((void*)&logFont,sizeof(logFont));
strcpy(logFont.lfFaceName,"宋体");
logFont.lfHeight = -12;
logFont.lfWeight = 400;
logFont.lfCharSet =
GB2312_CHARSET;
logFont.lfOutPrecision = 3;
logFont.lfClipPrecision = 2;
logFont.lfQuality = 1;
logFont.lfPitchAndFamily = 2;
m_font.CreateFontIndirect(&logFont);
SetFont(&m_font);
CFont *pOldFont = pDC->SelectObject(&m_font);
rect.left += 6;
rect.right -= 6;
rect.bottom -= 1;
rect.top = rect.bottom -
ITEMBUTTON_HEIGHT + 1;
CFont m_LogoFont;
CString sLogoString;
m_LogoFont.CreateFont(rect.Height()*4/5, 0, 0, 0, FW_BOLD, 1, FALSE, FALSE,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
FIXED_PITCH | FF_ROMAN,
"楷体_GB2312");
sLogoString = m_LogoName;
RECT m_rDataBox;
CopyRect(&m_rDataBox,&rect);
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
CFont* oldFont = pDC->SelectObject(&m_LogoFont);
CSize sz = pDC->GetTextExtent(sLogoString,
sLogoString.GetLength());
//用GetTextExtent来计算字体logo大小,依靠于设备环境,使用logo位于右下角
m_rDataBox.left =
m_rDataBox.right - sz.cx - tm.tmAveCharWidth/2;
m_rDataBox.top =
m_rDataBox.bottom - sz.cy - tm.tmHeight/5;
pDC->SetBkMode(TRANSPARENT);
//用3D字体显示,先黑后白,最后再用默认色
COLORREF oldColor = pDC->SetTextColor(GetSysColor(COLOR_3DDKSHADOW));
pDC->DrawText(sLogoString,
sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE |
DT_CENTER);
m_rDataBox.left -=
tm.tmAveCharWidth;
pDC->SetTextColor(GetSysColor(COLOR_3DHILIGHT));
pDC->DrawText(sLogoString,
sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE |
DT_CENTER);
m_rDataBox.left += 3*tm.tmAveCharWidth/5;
pDC->SetTextColor(RGB(0,0,255));
pDC->DrawText(sLogoString,
sLogoString.GetLength(), &m_rDataBox, DT_VCENTER | DT_SINGLELINE |
DT_CENTER);
//释放资源
pDC->SelectObject(oldFont);
pDC->SetTextColor(oldColor);
m_LogoFont.DeleteObject();
}
八、在属性页中动态加入其它控件
下面演示如何在左下角加入一Edit控件:
MyPropSheet.h中:
public:
CEdit m_edit;
MyPropSheet.cpp中:BOOL CMyPropSheet::OnInitDialog ()
{
BOOL bResult = CPropertySheet::OnInitDialog ();
CRect rect;
int nHeight = 24;
int nWidth = 120;
int nOffset = 6;
GetClientRect (&rect);
// Find a bottom-left point
for the edit control in the client area
int nX = rect.left + nOffset;
int nY = rect.top + (rect.Height() - nHeight) -
nOffset;
// finally create the edit
control
m_Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"),
NULL,
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
nX, nY, nWidth, nHeight, m_hWnd, 0, 0 );
return bResult;
}
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
面对“数字中国”建设和中国制造2025战略实施的机遇期,中车信息公司紧跟时代的步伐,以“集约化、专业化、标准化、精益化、一体化、平台化”为工作目标,大力推进信息服务、工业软件等核心产品及业务的发展。在慧都3D解决方案的实施下,清软英泰建成了多模型来源的综合轻量化显示平台、实现文件不失真的百倍压缩比、针对模型中的大模型文件,在展示平台上进行流畅展示,提升工作效率,优化了使用体验。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
本站的模型资源均免费下载,登录后即可下载。模型仅供学习交流,勿做商业用途。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号