如何让 bitblt 复制子控件而不将子控件绘制到屏幕上?
这是我的问题的简短内容:在自定义控件中,是否有一种方法可以将父控件绘制/位传输到其子控件到背景图像,但不能让子控件实际在控件上绘制?
详细信息: 我正在尝试推出自己的双缓冲(在紧凑框架上),但遇到了很多问题。我有一个相当复杂的用户控件。它有一个视图Panel
(固定大小),其中有滚动Panel
(可变大小)。滚动 Panel
中有多个卡片 Panel
。卡片面板垂直堆叠,包含两个 DataGrid
和两个 Label
。
这是我的控件的视觉轮廓
View Panel | +--> Scroll Panel | +---> Card Panel | | | +--> Label | +--> Label | +--> Data Grid | +--> Data Grid | +---> Card Panel | | | +--> Label | +--> Label | +--> Data Grid | +--> Data Grid (...)
OK,现在解决问题。我覆盖了滚动面板的 onpaint 并执行 bitblt 来获取图像以显示为“自定义绘画”。我通过保存来测试图像,这正是我想要的。
问题是数据网格和标签仍然进行正常的绘制。所以当我滚动时就会留下文物。因此,我重写 OnPaint,不对网格和标签执行任何操作。但是当我这样做时,bitblt 不再拾取网格(但奇怪的是它仍然拾取标签)。
那么,在自定义控件中,是否有一种方法可以让父控件将其子控件绘制/bitblt到背景图像,但不让子控件实际在控件上绘制?
注意:如果您有兴趣查看我的完整代码,可以在此处查看。
Here is the short of my question: in a custom control, is there a way to get a parent paint/bitblt its children controls to a background image, but not have the children controls actually paint on the control?
Details:
I am trying to roll my own double buffering (on the compact framework) and am having a lot of problems. I have a fairly complex user control. It has a view Panel
(fixed size) with scroll Panel
(variable size) in it. The scroll Panel
has several card Panels
in it. The card panels are stacked vertically contain two DataGrids
and two Labels
.
Here is a visual outline of my control
View Panel | +--> Scroll Panel | +---> Card Panel | | | +--> Label | +--> Label | +--> Data Grid | +--> Data Grid | +---> Card Panel | | | +--> Label | +--> Label | +--> Data Grid | +--> Data Grid (...)
OK, so now to the problem. I override the on paint for the Scroll Panel and do a bitblt to get an image to show as a "custom painting". I tested the image by saving it off and it is exactly what I want.
The problem is that the datagrids and labels still do their normal painting. So when I scroll then are leaving artifacts behind. So, I override the OnPaint to do nothing for the grid and the label. But when I do that the bitblt does not pickup the grids anymore (but oddly it picks up the labels still).
So, in a custom control, is there a way to get a parent paint/bitblt its children controls to a background image, but not have the children controls actually paint on the control?
NOTE: If you are interested to see my full code you can see it here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论