MFC中窗口隐藏后再显示,子窗口没刷新(WS_CLIPCHILDREN,WS_CLIPSIBLINGS)

问题描述

非模态对话框下,显示了子窗口,但窗口隐藏后,再通过任务栏显示出来时,子窗口内容就不显示了。

  • 正确的显示如下:
    在这里插入图片描述

  • 显示异常的情况
    -在这里插入图片描述

原因分析

显示父窗口时,父窗口会进行重绘(我的理解,可能有误:它不负责子窗口的重绘),默认情况下(即子窗口未指定WS_CLIPCHILDREN),父窗口会将子窗口与父窗口重叠的部分使用背景色进行绘制。

解决方案

创建子窗口加上WS_CLIPCHILDREN(剪去子窗口区域)。意思就是父窗口重绘时,不重绘子窗口背景。
MSDN上描述:

WS_CLIPCHILDREN Excludes the area occupied by child windows when you
draw within the parent window. Used when you create the parent window.

其他说明

  • WS_CLIPSIBLINGS
    MSDN原文

WS_CLIPSIBLINGS Clips child windows relative to each other; that is,
when a particular child window receives a paint message, the
WS_CLIPSIBLINGS style clips all other overlapped child windows out of
the region of the child window to be updated. (If WS_CLIPSIBLINGS is
not given and child windows overlap, when you draw within the client
area of a child window, it is possible to draw within the client area
of a neighboring child window.) For use with the WS_CHILD style only.

此窗口样式表示剪去兄弟窗口区域,即不绘制兄弟窗口与自己重叠的部分。父窗口为重叠窗口(overlapped),那么多个子窗口间就会存在重叠的情况,此样式可以对重叠部分的绘制进行控制。

参考

https://blog.csdn.net/lixiang987654321/article/details/26092029

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值