The study of Programming Windows with MFC--CRgn
2010-08-05 10:30
387 查看
1.Create Rgn
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.
Function | Description |
---|---|
CreateRectRgn | Creates a rectangular region from a set of coordinates |
CreateRectRgnIndirect | Creates a rectangular region from a RECT structure or a CRect object |
CreateEllipticRgn | Creates an elliptical region from a set of coordinates |
CreateEllipticRgnIndirect | Creates an elliptical region from a RECT structure or a CRect object |
CreateRoundRectRgn | Creates a rectangular region with rounded corners |
CreatePolygonRgn | Creates a polygonal region from a set of points |
CreatePolyPolygonRgn | Creates a region composed of multiple polygons from a set of points |
CreateFromPath | Creates a region from a path |
CreateFromData | Creates a region by applying two-dimensional coordinate transformations to an existing region |
CopyRgn | Creates a region that is a copy of an existing region |
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.
相关文章推荐
- The study of Programming Windows with MFC-Palette
- The Study of Programming Windows with MFC--Bitmap2
- The study of Programming Windows with MFC--BitMap
- The study of Programming Windows with MFC--Ip Address control and Date control
- The study of Programming Windows with MFC--print's example
- The study of Programming Windows with MFC--Common Control
- The Study of Programming Windows with MFC--Imagelist and ComboBoxEx
- The study of Programming Windows with MFC-printing tips
- The study of Programming Windows with MFC
- The Study of Programming Windows with MFC--Slider,Spin,ToolTip
- The study of chapter 13 in programming windows with mfc-printing with document and views
- The Study of Programming Windows with MFC--Progress and Animate control
- the study of programmng windows with mfc--timer
- Tricks of the Windows game programming gurus
- Professional WCF Programming: .NET Development with the Windows Communication Foundation
- WinFX Workflow:Simplify Development With The Declarative Model Of Windows Workflow Foundation. From Don Box & Dharma Shukla
- Programming Windows with MFC - Chapter 12 Toolbars
- Test-Driven C# Improve the Design and Flexibility of Your Project with Extreme Programming Techniques
- The Introduction of Windows Programming and WTL
- 【redis启动失败】he Windows version of Redis allocates a memory mapped heap for sharing with the forked pr