乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      關(guān)于CPropertySheet類的編程

       yiherainbow 2007-10-07
       關(guān)于CPropertySheet類的編程     CSDN Blog推出文章指數(shù)概念,文章指數(shù)是對(duì)Blog文章綜合評(píng)分后推算出的,綜合評(píng)分項(xiàng)分別是該文章的點(diǎn)擊量,回復(fù)次數(shù),被網(wǎng)摘收錄數(shù)量,文章長(zhǎng)度和文章類型;滿分100,每月更新一次。

      使用CPropertySheet類,在無(wú)模式狀態(tài)下會(huì)有三個(gè)按鈕(確認(rèn)/取消/應(yīng)用)  
      我想改變?nèi)齻€(gè)按鈕的標(biāo)題,另還想增加按鈕,  
      不知如何實(shí)現(xiàn)?  
      謝謝  
      ---------------------------------------------------------------  
       
      為了最大限度的發(fā)揮屬性頁(yè)的效用,首先讓我們先從  CPropertySheet  繼承一個(gè)新類,取名為  CMyPropSheet.  
      接著便可以進(jìn)行下面的各種操作:  
       
       一、隱藏屬性頁(yè)默認(rèn)按鈕    
      隱藏掉Apply應(yīng)用按鈕:    
       
      propsheet.m_psh.dwFlags    ¦=  PSH_NOAPPLYNOW;  
      或隱藏掉Cancel取消按鈕:CWnd  *pWnd  =  GetDlgItem(  IDCANCEL  );  
      pWnd->ShowWindow(  FALSE  );  
       
       二、移動(dòng)屬性頁(yè)按鈕  
      首先,要獲取按鈕的句柄,然后就可以象對(duì)待窗體一樣處理它們了.  下面代碼先隱藏掉Apply和Help銨鈕,再把OK和Cancel按移動(dòng)到右側(cè)。  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;  
      }  
       
       
      下面代碼移動(dòng)所有按鈕到右側(cè),并且重新置屬性頁(yè)為合適的大小.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;  
      }  
       
       
       三、改變屬性頁(yè)上的標(biāo)簽文字  
      首先修改TC_ITEM結(jié)構(gòu),然后用  SetItem  來(lái)修改標(biāo)簽文字,如下代碼: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);  
       
       四、改變屬性頁(yè)標(biāo)簽文字的字體屬性  
      代碼如下m_NewFont.CreateFont  (14,  0,  0,  0,  800,  TRUE,  0,  0,  1,  0,  0,  0,  0,  _T("Arial")  );  
             GetTabControl()->SetFont  (&m_NewFont);  
       
       五、在屬性頁(yè)標(biāo)簽上顯示位圖    
      可以用  CImageList  建立圖像.  用  SetItem  來(lái)設(shè)置,如下代碼所示: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;  
      }  
       
       
       六、在屬性頁(yè)左下角顯示位圖  
      如下代碼所示:  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  
      }  
       
       
       七、在屬性頁(yè)右下角顯示3D文字Logo  
      代碼如下:void  CMyPropSheet::OnPaint  ()    
      {  
             /////////////////////////////////////////////////////////////////////////  
                 //在TAB按鈕旁邊顯示3D文字提示,jingzhou  xu  
                 Cstring  m_LogoName  =  “屬性頁(yè)”;  
      //            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來(lái)計(jì)算字體logo大小,依靠于設(shè)備環(huán)境,使用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字體顯示,先黑后白,最后再用默認(rèn)色  
                 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();  
                 /////////////////////////////////////////////////////////////////////////  
      }  
       
       八、在屬性頁(yè)中動(dòng)態(tài)加入其它控件  
      下面演示如何在左下角加入一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_
       

      MSDN say:

      BOOL CMySheet::OnInitDialog()
      {
           CPropertySheet::OnInitDialog();

           RECT rc;

           // resize the sheet
           GetWindowRect (&rc);
           ScreenToClient (&rc);
           rc.right += 50;
           rc.bottom += 50;
           MoveWindow (&rc);

           // resize the CTabCtrl
           CTabCtrl* pTab = GetTabControl ();
           ASSERT (pTab);
           pTab->GetWindowRect (&rc);
           ScreenToClient (&rc);
           rc.right += 50;
           rc.bottom += 50;
           pTab->MoveWindow (&rc);

           // resize the page
           CPropertyPage* pPage = GetActivePage ();
           ASSERT (pPage);
           // store page size in m_PageRect
           pPage->GetWindowRect (&m_PageRect);
           ScreenToClient (&m_PageRect);
           m_PageRect.right += 50;
           m_PageRect.bottom += 50;
           pPage->MoveWindow (&m_PageRect);

           // move the OK, Cancel, and Apply buttons
           CWnd* pWnd = GetDlgItem(IDOK);
           pWnd->GetWindowRect(&rc);
           rc.bottom += 50;
           rc.top += 50;
           ScreenToClient(&rc);
           pWnd->MoveWindow(&rc);

           pWnd = GetDlgItem(IDCANCEL);
           pWnd->GetWindowRect(&rc);
           rc.bottom += 50;
           rc.top += 50;
           ScreenToClient(&rc);
           pWnd->MoveWindow(&rc);

           pWnd = GetDlgItem(ID_APPLY_NOW);
           pWnd->GetWindowRect(&rc);
           rc.bottom += 50;
           rc.top += 50;
           ScreenToClient(&rc);
           pWnd->MoveWindow(&rc);

           CenterWindow();

           return TRUE;
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多