How do I force a repaint of only the background so a control doesn't repaint over it again?

倾然丶 夕夏残阳落幕 提交于 2019-12-12 06:57:33

问题


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?


回答1:


About how to redraw visible borders.

The rounded rectangle drawn by RoundRect is used as representative

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

Simple code demonstration:

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

Link you need: Redraw Border



来源:https://stackoverflow.com/questions/56694648/how-do-i-force-a-repaint-of-only-the-background-so-a-control-doesnt-repaint-ove

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!