win32-使用FillRect绘制具有渐变颜色的客户区域背景
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绘制具有渐变颜色的客户区域背景的更多相关文章
- 跟我一起玩Win32开发(23):渐变颜色填充
GradientFill函数可以对特定的矩形区域或者三角形区域进行渐变颜色的填充.我们先来看看GradientFill函数到底长得什么样子,帅不帅. BOOL GradientFill( _In_ ...
- CSS3-canvas绘制线性渐变
<!doctype html><html><head><meta charset="utf-8"><title>canv ...
- 绘制窗体渐变背景的函数[delphi]
绘制窗体渐变背景的函数,三个参数分别代表起始颜色,终止颜色,绘制方向procedure TForm1.Draw(StartColor:TColor;EndColor:TColor;Direction: ...
- 32.QT-制作最强电压电阻表盘,可以自定义阴影效果,渐变颜色,图标,文字标签等-附带demo程序
由于上位机需要绘制电压电阻表盘,如下图所示: 后来,在网上找阿找,还是没找到满意的,索性自己来画控件算了,由于第一次画控件,所以花了我2天时间,才画好 效果图如下: 上图的所有颜色(包括滑动的渐变/单 ...
- 【原】Github系列之三:开源iOS下 渐变颜色的进度条WGradientProgress
概述 今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移 ...
- 渐变颜色的进度条WGradientProgress-备用
今天我们来实现一个iOS平台上的进度条(progress bar or progress view).这种进度条比APPLE自带的更加漂亮,更加有“B格”.它拥有渐变的颜色,而且这种颜色是动态移动的, ...
- CAGradientLayer渐变颜色动画
CAGradientLayer渐变颜色动画 或许你用过CAGradientLayer,你知道他是用于渐变颜色的,但你是否直到,CAGradientLayer的渐变颜色是可以动画的哦. 源码: // / ...
- iOS实现渐变颜色
下面是我的两种实现: 1.直接图片展示,注意图片的变形问题; 2.用CAGradientLayer渐变颜色实现; 代码如下: // // ViewController.m // ImageStrenc ...
- win2d 渐变颜色
本文告诉大家如何在 win2d 使用渐变颜色 线条渐变 在 UWP 的 Win2d 使用渐变颜色需要 CanvasLinearGradientBrush 做颜色,本文告诉大家如何在 win2d 使用 ...
- 好看的css渐变颜色大全网址
60个渐变颜色 https://webkul.github.io/coolhue/ 60个非常有用的CSS代码片段 https://baijiahao.baidu.com/s?id=160278735 ...
随机推荐
- [转帖]signal 11 (SIGSEGV)错误排查
https://www.jianshu.com/p/a4250c72d391 jni调试最蛋疼的就是signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault a ...
- [转帖]TiDB-merge region相关问题
一.开启region merge # 控制 Region Merge 的 size 上限,当 Region Size 大于指定值时 PD 不会将其与相邻的 Region 合并 pd-ctl confi ...
- [转帖]文件操作之zip、bzip2、gzip、tar命令
文件操作之zip.bzip2.gzip.tar命令 原创 丁同学19902015-10-15 00:02:51博主文章分类:liunx基础著作权 文章标签linux tarlinux文件压缩linux ...
- [转帖]Lightning 实操指南
2.2.2 Lightning 实操指南 这一节将介绍如何使用 Lightning 导入数据的实操 2.2.2.1 TiDB Lightning 快速开始 注意 TiDB Lightning 运行后, ...
- [转帖]华为毕昇 JDK 8u292、11.0.11 发布!
https://baijiahao.baidu.com/s?id=1705499834793298544&wfr=spider&for=pc 2021 年 6 月 30 日,毕昇 JD ...
- 渗透学习笔记(cookies、XSS注入)
1.cookie 插件:cookie-editor JavaScript语法: 获取:document.cookie; 设置:document.cookie="username=felix& ...
- 批量修改SVN的用户名和密码的尝试
起源 公司规定每6个月需要修改一次密码,否则每天都有邮件和内网提醒.因为邮箱密码和svn等一系列应用绑定,避免每次修改密码后需要手工输入修改多个svn仓库的帐号和密码. PS.同一个前缀的svn不用重 ...
- 淘宝一面:“说一下 Spring Boot 自动装配原理呗?”
本文已经收录进 Github 95k+ Star 的Java项目JavaGuide .JavaGuide项目地址 : https://github.com/Snailclimb/JavaGuide . ...
- ChatGenTitle:使用百万arXiv论文信息在LLaMA模型上进行微调的论文题目生成模型
ChatGenTitle:使用百万arXiv论文信息在LLaMA模型上进行微调的论文题目生成模型 相关信息 1.训练数据集在Cornell-University/arxiv,可以直接使用: 2.正式发 ...
- C/C++ 实现FTP文件上传下载
FTP(文件传输协议)是一种用于在网络上传输文件的标准协议.它属于因特网标准化的协议族之一,为文件的上传.下载和文件管理提供了一种标准化的方法,在Windows系统中操作FTP上传下载可以使用WinI ...