您的位置:首页 > 其它

The study of Programming Windows with MFC--CRgn

2010-08-05 10:30 387 查看
1.Create Rgn


FunctionDescription
CreateRectRgnCreates a rectangular region from a set of coordinates
CreateRectRgnIndirectCreates a rectangular region from a RECT structure or a CRect object
CreateEllipticRgnCreates an elliptical region from a set of coordinates
CreateEllipticRgnIndirectCreates an elliptical region from a RECT structure or a CRect object
CreateRoundRectRgnCreates a rectangular region with rounded corners
CreatePolygonRgnCreates a polygonal region from a set of points
CreatePolyPolygonRgnCreates a region composed of multiple polygons from a set of points
CreateFromPathCreates a region from a path
CreateFromDataCreates a region by applying two-dimensional coordinate transformations to an existing region
CopyRgnCreates a region that is a copy of an existing region
dc.BeginPath();

TextOut(0,0,_T("Create Font Rng"));

dc.EndPath();

CRgn rgn;

rgn.CreateFromPath(&dc);



2.Combine Rgn

dc.BeginPath();

TextOut(0,0,_T("Create Font Rng"));

dc.EndPath();

CRgn rgn1,rgn2;

CRect rect;

rgn1.CreateFromPath(&dc);

rgn1.GetRgnBox(&rect);

rgn2.CreateRectRgnIndirect(&rect);

rgn1.CombineRgn(&rgn2,&rgn1,RGN_DIFF);



3.Using Region

CDC::FillRgn fills a region using a specified brush.




CDC::PaintRgn fills a region using the current brush.




CDC::InvertRgn inverts the colors in a region.




CDC::FrameRgn borders a region with a specified brush.



One of the more imaginative uses for a region is to pass it to the CWnd::SetWindowRgn function so that it becomes a window region. A window region is a clipping region for an entire window. Windows doesn't allow anything outside the window region to be painted, including title bars and other nonclient-area window elements. Create an elliptical region and pass its handle to SetWindowRgn, and you'll get an elliptical window. If the window is a top-level window and its title bar is hidden from view, use an OnNcHitTest handler to convert HTCLIENT hit-test codes into HTCAPTION codes so that the window can be dragged by its client area. A more practical use for nonrectangular window regions is to create stylized text bubbles that are actually windows and that receive messages just as other windows do. With SetWindowRgn to assist you, it's not terribly difficult to create a popup window class that displays help text in a window shaped like a thought balloon and that automatically destroys itself when it's clicked.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: