如何为子控件绘制透明区域?
我有一个 CTabCtrl 子类,我正在尝试覆盖 WM_PAINT 来执行自定义绘图。 唯一的问题是,当我更改选定的选项卡时,我会在对话框中留下工件,其中在新代码绘制在顶部之前旧绘制代码尚未被删除。 (标准选项卡控件使选定的选项卡比未选定的选项卡大 2 个像素,因此当您从选定更改为未选定时,您将保留之前的绘制伪影)。
“重新粉刷”该区域的最佳方法是什么? 我尝试过获取父控件的 DC 并将其 BitBlt'ing 到子 DC 上,但这不起作用,因为父 DC 已经包含该控件的图像。
I have a CTabCtrl subclass which I'm trying overriding WM_PAINT to perform custom drawing. The only problem is, when I change the selected tab, I get artifacts left on the dialog where the old paint code hasn't been erased before the new code is painted on top. (The standard tab controls have the selected tab appear 2 pixels bigger than non-selected tabs, so when you change from selected to non-selected, you are left with the previous paint artifacts).
What is the best way of "repainting" this area? I've tried getting the parent control's DC and BitBlt'ing that onto the child's DC, but that doesn't work because the parent DC already contains an image of this control.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否也覆盖 WM_ERASEBACKGROUND 消息? 您可能应该这样做并擦除控件中的区域。
您可以使用 DrawThemeParentBackground 来绘制背景(XP 及更高版本),如果你不想替换所有的绘图逻辑。
Do you override the WM_ERASEBACKGROUND message as well? You should probably do that and erase the area in the control.
You could use DrawThemeParentBackground to draw the background (XP and later) if you don't want to replace all the drawing logic.