WEB开发网
开发学院软件开发VC 深入浅出CPropertySheet 阅读

深入浅出CPropertySheet

 2007-10-07 20:23:26 来源:WEB开发网   
核心提示:四、改变属性页标签文字的字体属性代码如下m_NewFont.CreateFont (14, 0, 0, 0, 800, TRUE, 0, 0, 1, 0, 0, 0, 0, _T("Arial") ); GetTabControl()->SetFont (&m_NewFont);五、在属性页标

四、改变属性页标签文字的字体属性

代码如下

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
}

上一页  1 2 3 4  下一页

Tags:深入浅出 CPropertySheet

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接