我想在propertysheet标签上添加位图,使与propertypage的背景相一致。请各位兄台赐教!多谢
解决方案 »
- 明明知道找工作是为了挣钱,招聘单位为什么总问“你为什么要换工作”?
- 请教这个问题
- 谁能进来帮我看看!SetupDiEnumDeviceInterfaces函数出错~
- 请问关于串口流控制的过程,以及在API编程中如何使用问题
- 多媒体定时器个数问题
- (急)另一个关于获得View指针的问题.先谢了!
- 编一个抓取局域网内的数据帧的程序,要用到那些类,或者那些API
- 在线等待!!如何解决win2000下不能使用_inp,_outp的问题(100分)"Wanted"
- 关于系统托盘图标的应用
- MFC中如何弹出非模态对话框
- 要想让COM向javascript传递字符数组,如何实现?我收到的总是undifined
- 请问:VK_ALT需要包含哪个头文件?
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 width=rectClient.Width()*2/3;
//移动并改变属性单窗口的尺 寸
SetWindowPos(NULL,pt.x-width/2,pt.y-winRect.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); bitmap.LoadBitmap(IDB_BITMAP_TEST);
imagelist.Create(16,16,ILC_COLOR8,0,4);
imagelist.Add(&bitmap,RGB(0,0,0));
pTab->SetPadding(CSize(5,5)); pTab->SetImageList(&imagelist); TCITEM tm;
tm.mask=TCIF_IMAGE;
for(int index=0;index<=2;index++)
{
pTab->GetItem(index,&tm);
tm.iImage=index;
pTab->SetItem(index,&tm);
} //激活每个属性页,防止重画
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
}
imagelist.Create(16,16,ILC_COLOR8,0,4);//分割位图
imagelist.Add(&bitmap,RGB(0,0,0));//添加位图
pTab->SetPadding(CSize(5,5));//扩展标签 pTab->SetImageList(&imagelist);//设置位图列表 TCITEM tm;
tm.mask=TCIF_IMAGE;
for(int index=0;index<=2;index++)
{
pTab->GetItem(index,&tm);
tm.iImage=index;
pTab->SetItem(index,&tm);//设置标签位图
} //激活每个属性页,防止重画
int nCurPos=GetActiveIndex();
for(int i=0;i<GetPageCount();i++)
SetActivePage(i);
SetActivePage(nCurPos);
CFontSheet 具有三个属性页:
CFontPage
CEffectPage
CColorPage
-----------------
class CFontSheet : public CPropertySheet{
.....
public:
CFontPage m_FontPage;
CEffectPage m_EffectPage;
CColorPage m_ColorPage;
...
};
------------------------
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);//设置标签为滚动显示方式!
}