windows應用開發由淺入深(三)有關不規則窗口

相關類:

1、CRgn:Encapsulates a Windows graphics device interface (GDI) region.即、CRgn表示一個GDI封裝區

MSDN描述:

A region is an elliptical or polygonal area within a window. To use regions, you use the member functions of class CRgn with the clipping functions defined as members of class CDC.

封裝區是窗口的橢圓區域或者不規則區域。對封裝區的所有操作,是通過CRgn的成員方法實現的,而CRgn是通過CDC類定義的裁剪方法得到的。

The member functions of CRgn create, alter, and retrieve information about the region object for which they are called.

CRgn的成員方法可創建、修改封裝區,並可以檢索封裝區對象信息。


2、CRect:A CRect contains member variables that define the top-left and bottom-right points of a rectangle.這是用左上點座標和右下點座標表示的矩形工作區


相關函數:

1、GetWindowRect():      獲取表示矩形工作區區域的的CRect類。

2、CRgn.CreateRoundRectRgn():      Creates a rectangular region with rounded corners that is stored in the CRgn object. 

                                                                   創建圓角矩形封裝區,參數是圓角的信息,存儲進CRgn實例中。

3、SetWindowRgn();                         Sets  the window region of a window.   設置窗口的封裝區域。


示例

void CmainDlg::OnBnClickedOk()
{
	// TODO: 在此添加控件通知處理程序代碼
	CRect cRect;
	CRgn cRgn;
	GetWindowRect(&cRect);
	cRect -= cRect.TopLeft();
	cRgn.CreateRoundRectRgn(cRect.left,cRect.top,cRect.right,cRect.bottom,150,150);
	SetWindowRgn(cRgn,TRUE);
}








發佈了32 篇原創文章 · 獲贊 14 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章