如何强制仅重绘背景,以使控件不会再次重绘背景? [英] How do I force a repaint of only the background so a control doesn't repaint over it again?

查看:100
本文介绍了如何强制仅重绘背景,以使控件不会再次重绘背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是由对另一个问题的答复产生的:透明窗口上的通用控件?.

This question was generated by a response to another question: Common Controls on a Transparent Window?.

显然,有一种方法可以只绘制背景,而无需再次绘制控件本身.这将解决在透明背景上具有通用控件按钮的问题.

Apparently, there is a way to only paint the background without a control painting itself again This would solve the problem of having common control buttons on a transparent background.

所以我的问题是,在公共控件绘制自身之后,如何仅绘制公共控件周围的背景?

So my question is, how do I paint only the background around a common control after the common control has painted itself?

推荐答案

关于如何重绘可见边框.

About how to redraw visible borders.

RoundRect绘制的圆角矩形作为代表

The rounded rectangle drawn by RoundRect is used as representative

FrameRgn 函数使用指定的画笔在指定区域周围绘制边框.

The FrameRgn function draws a border around the specified region by using the specified brush.

简单的代码演示:

HRGN hRegion = ::CreateRoundRectRgn (0, 0, ClientWidth, ClientHeight,12,12);
Canvas->Brush->Style = bsSolid;
Canvas->Brush->Color = RGB(96, 96, 96);
::FrameRgn(Canvas->Handle, hRegion, Canvas->Brush->Handle, 2, 2);
::DeleteObject(hRegion); // Don't leak a GDI object

您需要的链接:重绘边框

这篇关于如何强制仅重绘背景,以使控件不会再次重绘背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆