BeginPath&EndPath&SelectClipPath

路径的使用:

SelectClipPath函数:

函数功能:该函数选择当前的路径作为设备环境的一个剪切区域。通过使用特定的模式把新的区域与任何存在的剪切区域合并。

函数原型:

BOOL SelectClipPath( int nMode );

Parameters

nMode

Specifies the way to use the path. The following values are allowed:

  • RGN_AND   The new clipping region includes the intersection (overlapping areas) of the current clipping region and the current path. 新剪切的区域包括当前剪切区域和当前路径的一个交集!

  • RGN_COPY   The new clipping region is the current path.新剪切区域就是当前剪切区域

  • RGN_DIFF   The new clipping region includes the areas of the current clipping region, and those of the current path are excluded.新剪切区域包括当前路径区域外的当前剪切区域

  • RGN_OR   The new clipping region includes the union (combined areas) of the current clipping region and the current path.新剪切区域包括当前区域与当前路径的并集

  • RGN_XOR   The new clipping region includes the union of the current clipping region and the current path, but without the overlapping areas. 新剪切区域包括当前区域与当前路径的并集但不包括重叠区域!

RGB_AND显示效果:

RGB_DIFF显示效果:

使用代码:

 CString str = "hello kity!";
 CSize cs;
 pDC->TextOut(30,30,str);
 cs = pDC->GetTextExtent(str);

 
 //路径的设置
 pDC->BeginPath();
 pDC->Rectangle(30,30,30+cs.cx,30+cs.cy);
 pDC->EndPath();
 pDC->SelectClipPath(RGN_AND);

 str.LoadString(ID_FILE_NEW);
 pDC->TextOut(0,200,str);

 

BeginPath:

           路径的使用  
与其它原有的GDI对象不同的是,MFC类库没有专门用一个C++类来封装路径对象(或许在以后的版本中会得到支持)。有关路径的定义和使用等各种操作都必须通过调用API函数(或CDC类中对应的成员函数)来实现。

BeginPath         {路径开始}    EndPath         {路径结束}
StrokePath        {绘制路径}    FillPath          {填充路径}
StrokeAndFillPath {绘制并填充路径}
使用代码:

 RECT rect={0,0,600,200}; 
 LOGFONT lf;
 memset(&lf, 0, sizeof(LOGFONT));       // clear out structure.
 lf.lfHeight = 120;                     // request a 12-pixel-height font
 strcpy(lf.lfFaceName, "Arial");        // request a face name "Arial".
 

 CFont font;
 VERIFY(font.CreatePointFontIndirect(&lf, pDC));  
 
 // Do something with the font just created...
 //CFont* def_font = dc.SelectObject(&font);

 CFont* pOldfont=pDC->SelectObject(&font); 
 pDC->BeginPath(); 
 pDC->TextOut(400,100,"龙腾");  
 pDC->EndPath();  
 pDC->SelectObject(pOldfont); 
 CPen pen1(PS_SOLID,2,RGB(0,0,255));   
 CPen* pOldPen=pDC->SelectObject(&pen1);  
 //pDC->StrokePath();                       //绘制路径    
 CBrush brush1(RGB(255,0,0)); 
 CBrush* pOldBrush=pDC->SelectObject(&brush1);  
 //pDC->FillPath();                        //填充路径  
 pDC->StrokeAndFillPath();                 //绘制并填充路径   
 pDC->SelectObject(pOldBrush); 
 pDC->SelectObject(pOldPen);


 


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值