如何用GDI绘制一个透明的椭圆?我尝试了 SetBkMode()
但我仍然得到一个白色椭圆 bk。
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT); // doesnt work
Ellipse(hdc, 0,0,500,500);
EndPaint(hwnd, &ps);
break;
}
最佳答案
The ellipse is outlined by using the current pen and is filled by using the current brush.
因此,需要设置一个透明的笔刷。为此,使用 GetStockObject(HOLLOW_BRUSH)
获取它并使用 SelectObject()
为给定的设备上下文激活它。所以你的代码可以是这样的:
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
Ellipse(hdc, 0,0,500,500);
EndPaint(hwnd, &ps);
break;
}
关于c++ - 透明椭圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6086024/