c++ - native C++ 中的渐变画笔?

标签 c++ winapi native

在c#中,你可以使用drawing2d.lineargradientbrush,但在c++中我现在只找到了CreateSolidBrush函数。原生gdi dll中有没有创建渐变画笔的函数?我在 msdn 找不到这样的东西。 谢谢

最佳答案

绘制垂直渐变:

void VerticalGradient(HDC hDC, const RECT& GradientFill, 
                      COLORREF rgbTop, COLORREF rgbBottom)
{
    GRADIENT_RECT gradientRect = { 0, 1 };
    TRIVERTEX triVertext[ 2 ] = {
        GradientFill.left - 1,
        GradientFill.top - 1,
        GetRValue(rgbTop) << 8,
        GetGValue(rgbTop) << 8,
        GetBValue(rgbTop) << 8,
        0x0000,         
        GradientFill.right,
        GradientFill.bottom,
        GetRValue(rgbBottom) << 8,
        GetGValue(rgbBottom) << 8,
        GetBValue(rgbBottom) << 8,
        0x0000
    };
    GradientFill(hDC, triVertext, 2, &gradientRect, 1, GRADIENT_FILL_RECT_V);
}

关于c++ - native C++ 中的渐变画笔?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1418399/

相关文章:

c++ - 在 VC++ 中静态链接库

c++ - 如何确保即使在异常终止时也会调用 UnhookWindowsHookEx?

c++ - 处理来自子类的 Windows 消息

仅在 Google Pixel 6P 上发生 Android native 崩溃

c++ - 在 C++ 列表中按字母顺序插入字符串

c++ - 函数计算被跳过的字符串类的字符?

c++ - 如何关闭 Code::Blocks 的自动完成

c - WinMain() 到 main() 宏中的奇怪错误

ios - Cordova-ios 中的状态栏保持半透明

reactjs - 纬度的值不能在 native react 中从字符串转换为 double