void OnEraseBkGnd(HWND hwnd)
{
/* Vars */
HDC dc; /* Standard Device Context; used to do the painting */ /* rect = Client Rect of the window;
Temp = Temparory rect tangle for the color bands */
RECT rect, temp;
HBRUSH color; /* A brush to do the painting with */ /* Get the dc for the wnd */
dc = GetDC(hwnd); /* Get the client rect */
GetClientRect(hwnd, &rect); /* Start color; Change the R,G,B values
to the color of your choice */
int r1 = 255, g1 = 0, b1 = 0; /* End Color; Change the R,G,B values
to the color of your choice */
int r2 = 255, g2 = 255, b2 = 0; /* loop to create the gradient */
for (int i = 0; i < rect.right; i++)
{
/* Color ref. for the gradient */
int r, g, b;
/* Determine the colors */
r = r1 + (i * (r2 - r1) / rect.right);
g = g1 + (i * (g2 - g1) / rect.right);
b = b1 + (i * (b2 - b1) / rect.right); /* Fill in the rectangle information */ /* The uper left point of the rectangle
being painted; uses i as the starting point*/
temp.left = i;
/* Upeer Y cord. Always start at the top */
temp.top = 0;
/* Okay heres the key part,
create a rectangle thats 1 pixel wide */
temp.right = i + 1;
/* Height of the rectangle */
temp.bottom = rect.bottom; /* Create a brush to draw with;
these colors are randomized */
color = CreateSolidBrush(RGB(r, g, b)); /* Finally fill in the rectangle */
FillRect(dc, &temp, color);
}
}

将OnEraseBkGnd()放到WM_ERASEBKGND事件中。

win32-使用FillRect绘制具有渐变颜色的客户区域背景的更多相关文章

  1. 跟我一起玩Win32开发(23):渐变颜色填充

    GradientFill函数可以对特定的矩形区域或者三角形区域进行渐变颜色的填充.我们先来看看GradientFill函数到底长得什么样子,帅不帅. BOOL GradientFill( _In_   ...

  2. CSS3-canvas绘制线性渐变

    <!doctype html><html><head><meta charset="utf-8"><title>canv ...

  3. 绘制窗体渐变背景的函数[delphi]

    绘制窗体渐变背景的函数,三个参数分别代表起始颜色,终止颜色,绘制方向procedure TForm1.Draw(StartColor:TColor;EndColor:TColor;Direction: ...

  4. 32.QT-制作最强电压电阻表盘,可以自定义阴影效果,渐变颜色,图标,文字标签等-附带demo程序

    由于上位机需要绘制电压电阻表盘,如下图所示: 后来,在网上找阿找,还是没找到满意的,索性自己来画控件算了,由于第一次画控件,所以花了我2天时间,才画好 效果图如下: 上图的所有颜色(包括滑动的渐变/单 ...

  5. 【原】Github系列之三:开源iOS下 渐变颜色的进度条WGradientProgress

    概述 今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移 ...

  6. 渐变颜色的进度条WGradientProgress-备用

    今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移动的, ...

  7. CAGradientLayer渐变颜色动画

    CAGradientLayer渐变颜色动画 或许你用过CAGradientLayer,你知道他是用于渐变颜色的,但你是否直到,CAGradientLayer的渐变颜色是可以动画的哦. 源码: // / ...

  8. iOS实现渐变颜色

    下面是我的两种实现: 1.直接图片展示,注意图片的变形问题; 2.用CAGradientLayer渐变颜色实现; 代码如下: // // ViewController.m // ImageStrenc ...

  9. win2d 渐变颜色

    本文告诉大家如何在 win2d 使用渐变颜色 线条渐变 在 UWP 的 Win2d 使用渐变颜色需要 CanvasLinearGradientBrush 做颜色,本文告诉大家如何在 win2d 使用 ...

  10. 好看的css渐变颜色大全网址

    60个渐变颜色 https://webkul.github.io/coolhue/ 60个非常有用的CSS代码片段 https://baijiahao.baidu.com/s?id=160278735 ...

随机推荐

  1. [转帖]Python学习之十七_django的入门

    Python学习之十七_django的入门 前言 Python学习了一周, 慢慢总结摸索. 自己还是有多不会的地方. 感慨这些年浪费的时间. 所有的时间都是选择大于努力. 努力最多感动自己. 生活是需 ...

  2. [转帖]使用 TiUP 升级 TiDB

    本文档适用于以下升级路径: 使用 TiUP 从 TiDB 4.0 版本升级至 TiDB 7.1. 使用 TiUP 从 TiDB 5.0-5.4 版本升级至 TiDB 7.1. 使用 TiUP 从 Ti ...

  3. 【转帖】Linux 系统双网卡绑定 bond的7种模式

    第一种模式:mod=0 ,即:(balance-rr) Round-robin policy(平衡抡循环策略)第二种模式:mod=1,即: (active-backup) Active-backup ...

  4. [转帖]Innodb存储引擎-锁(数据库锁的查看、快照读&当前读、MVCC、自增长与锁、外键与锁、行锁、并发事务的问题、阻塞、死锁、锁升级、锁的实现)

    文章目录 锁 lock 与latch 读锁/写锁/意向锁 INNODB_TRX/INNODB_LOCKS/INNODB_LOCK_WAITS 一致性非锁定读(快照读) 一致性锁定读(当前读) MVCC ...

  5. Gitlab使用说明

          零.gitlab简介   Gitlab是一个成熟的代码管理工具.为企业和组织提供内部的源代码的存储和管理功能.         一.gitlab角色总览   gitlab中的角色分管理员和 ...

  6. express学会CRUD

    使用express 搭建项目 1==> express 项目名 -e 2==> 然后按照提示就可以了 cd 项目名 3==>进入项目 下载依赖 cnpm i 4==>启动项目 ...

  7. vite构建打包产物

    构建打包产物 build: { assetsInlineLimit: 10240, //静态资源(不会包含js,css)不超过10kb 转化为 base64 [不好含css js] outDir: & ...

  8. elemetui-中在input框中回车

    在input框中回车 <el-input @keyup.enter.native="gotoLogin" class="my-el-input" plac ...

  9. logstash 与ElasticSearch:从CSV文件到搜索宝库的导入指南

    logstash 与ElasticSearch:从CSV文件到搜索宝库的导入指南 使用 logstash 导入数据到 ES 时,由三个步骤组成:input.filter.output.整个导入过程可视 ...

  10. 【三】tensorboard安装、使用教学以及遇到的问题

    相关文章: [一]tensorflow安装.常用python镜像源.tensorflow 深度学习强化学习教学 [二]tensorflow调试报错.tensorflow 深度学习强化学习教学 [三]t ...