开发者

Transparent Ellipse

开发者 https://www.devze.com 2023-03-07 07:46 出处:网络
How do you draw a transparen开发者_JAVA百科t ellipse with GDI? I tried SetBkMode() but I still get a white ellipse bk.

How do you draw a transparen开发者_JAVA百科t ellipse with GDI? I tried SetBkMode() but I still get a white ellipse bk.

case WM_PAINT:
{
    hdc = BeginPaint(hwnd, &ps);
    SetBkMode(hdc, TRANSPARENT); // doesnt work
    Ellipse(hdc, 0,0,500,500);
    EndPaint(hwnd, &ps);
    break;
}


Borrowed from Fill an ellipse in C++:

The ellipse is outlined by using the current pen and is filled by using the current brush.

Therefore, you need to set a transparent brush. For that, use GetStockObject(HOLLOW_BRUSH) to obtain it and SelectObject() to activate it for a given device context. So your code can be like this:

case WM_PAINT:
{
    hdc = BeginPaint(hwnd, &ps);
    SelectObject(hdc, GetStockObject(HOLLOW_BRUSH));
    Ellipse(hdc, 0,0,500,500);
    EndPaint(hwnd, &ps);
    break;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消