更新时间:2016-01-24 23:30:04浏览次数:1+次
FillRgn(hdc,Rgn,(HBRUSH)GetStockObject(LTGRAY_BRUSH));
函数的第二个参数就是区域的句柄,另外两个参数,一个是hdc,一个是画刷句柄,在矩形的操作中,都很熟悉了。SelectObject(hdc,GetStockObject(GRAY_BRUSH));
PaintRgn(hdc,hEllipRgn);
FrameRgn(hdc,hEllipRgn,(HBRUSH)GetStockObject(GRAY_BRUSH),2,4);
第三个参数为画刷句柄,第四个参数为左右两边的边框宽度,第五个参数为上下两边的边框高度。
下面是绘制的效果图:
InvertRgn(hdc,hRgn);
反转区域的效果图如下:
#include "windows.h"
#include <tchar.h>
TCHAR txt[100]=_T("C++技术网http://www.cjjjs.com");
// - 项目是Unicode字符集
LRESULT CALLBACK WinProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
static POINT pt[]={100,10,200,10,200,110,100,110,50,10,110,50,110,120,10,120};
static int pc[]={4,4};
switch (message)
{
case WM_PAINT:
{
hdc = BeginPaint(hwnd,&ps);
HRGN hEllipRgn = CreatePolyPolygonRgn(pt,pc,2,WINDING);
InvertRgn(hdc,hEllipRgn);
EndPaint(hwnd,&ps);
DeleteObject(hEllipRgn);
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
break;//跳出到默认处理
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrev,LPSTR lpCmd,int iShow)
{
TCHAR ClassName[] = _T("MyClass");
TCHAR title1[] = _T("C++技术网http://www.cjjjs.com");
WNDCLASS wndClass;
wndClass.cbClsExtra=0;
wndClass.cbWndExtra=0;
wndClass.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndClass.hInstance = hInstance;
wndClass.lpfnWndProc = WinProc;
wndClass.lpszClassName = ClassName;
wndClass.lpszMenuName=NULL;
wndClass.style=CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
if(!RegisterClass(&wndClass))return 0;
HWND hwnd = CreateWindow(ClassName,title1,WS_OVERLAPPEDWINDOW,10,100,550,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
MSG msg;
while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
相关资讯