+ -
当前位置:首页 → 问答吧 → windows API函数编程实现异形窗口问题

windows API函数编程实现异形窗口问题

时间:2011-12-16

来源:互联网

求指导异形窗口的实现,用windows API函数编程,不要C++的。
异形区域,我老是画不出来~~

作者: s58420411   发布时间: 2011-12-16

我按照搜到的资料,做了一个,只能实现无边框,无标题,并不能实现不规则的窗体~~以下是个人做的WM_CREATE消息部分,得到的区域还是四方的,不是按照window.bmp内德图片轮廓的区域,什么地方不对,求指导。
//window.bmp背景是白色的
...

case WM_CREATE:
dwStyle=GetWindowLong(hwnd,GWL_STYLE);
dwStyle=WS_CHILD;
SetWindowLong(hwnd,GWL_STYLE,dwStyle);
hpicture=(HBITMAP)LoadImage(hInstance,
"window.bmp",
IMAGE_BITMAP,
cxClient,//客户坐标
cyClient,//same
LR_LOADFROMFILE|LR_LOADTRANSPARENT);
GetObject(hpicture,sizeof(BITMAP),&picture);
hmedc=CreateCompatibleDC(hdc);
SelectObject(hmedc,&hpicture);
hrgnpicture=CreateRectRgn(0,0,picture.bmWidth,picture.bmHeight);
for(x=0;x<=picture.bmWidth;x++)
for(y=0;y<=picture.bmHeight;y++)
{
pixelcolor=GetPixel(hmedc,x,y);
if(pixelcolor==backgroundcr)//backgroundcr=RGB(255,255,255)
{
hsmall=CreateRectRgn(x,y,x+1,y+1);
CombineRgn(hrgnpicture,hrgnpicture,hsmall,RGN_XOR);
DeleteObject(hsmall);
}
}
SelectObject(hmedc,&hpicture);
SetWindowRgn(hwnd,hrgnpicture,TRUE);//完成异形区域?!
DeleteDC(hmedc);
DeleteObject(hpicture);
...

作者: s58420411   发布时间: 2011-12-16

mark,同等解答.....

作者: mdbsdn   发布时间: 2011-12-16