CF.NET 平滑滚动面板 -- bitblt 出现空白
我正在尝试在 CF.NET 中编写一个面板,该面板允许我滚动其中的内容而不闪烁。我想我应该尝试使用一个 WrapperPanel 类,其中包含另一个具有实际内容的面板。然后,我会根据滚动位置将内部面板的内容 bitblt 到包装器。
但 bitblt 对我不起作用。它只是让目标表面保持原样,没有明显的变化。
以下是相关代码:
protected override void OnPaint(PaintEventArgs e)
{
//Generate a proper-sized bitmap
using (Bitmap bmp = new Bitmap(ClientSize.Width, ClientSize.Height))
{
using (Graphics bgr = Graphics.FromImage(bmp))
{
//bitblt from interior panel to that bitmap
var srcDC = GetDC(_interiorPanel.Handle);
var bmDC = bgr.GetHdc();
var res = BitBlt(bmDC, 0, YOffSet, Width, Height, srcDC, 0, 0, 0x00CC0020);
System.Diagnostics.Debug.WriteLine(res);
ReleaseDC(_interiorPanel.Handle, srcDC);
bgr.ReleaseHdc(bmDC);
}
//Draw that bitmap to this panel
e.Graphics.DrawImage(bmp, 0, 0);
}
base.OnPaint(e);
}
GetDC() 和 GetHdc() 调用都返回一个值,因此至少它们没有失败。但这就是我对 GDI+ 的故障排除知识的范围。有人能看到我做错了什么吗?
I'm trying to write a panel in CF.NET that allows me to scroll the contents inside without flickering. I thought I'd try having a WrapperPanel class that contains another panel with the actual contents. Then I'd bitblt the contents of the interior panel to the wrapper based on the scrolling position.
But the bitblt isn't working for me. It's just leaving the destination surface as it was, with no visible change.
Here's the relevant code:
protected override void OnPaint(PaintEventArgs e)
{
//Generate a proper-sized bitmap
using (Bitmap bmp = new Bitmap(ClientSize.Width, ClientSize.Height))
{
using (Graphics bgr = Graphics.FromImage(bmp))
{
//bitblt from interior panel to that bitmap
var srcDC = GetDC(_interiorPanel.Handle);
var bmDC = bgr.GetHdc();
var res = BitBlt(bmDC, 0, YOffSet, Width, Height, srcDC, 0, 0, 0x00CC0020);
System.Diagnostics.Debug.WriteLine(res);
ReleaseDC(_interiorPanel.Handle, srcDC);
bgr.ReleaseHdc(bmDC);
}
//Draw that bitmap to this panel
e.Graphics.DrawImage(bmp, 0, 0);
}
base.OnPaint(e);
}
Both the GetDC() and GetHdc() calls return a value, so at least they aren't failing. But that's about the extent of my troubleshooting knowledge with GDI+. Can someone see what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
内饰板是看不见的吗?屏幕外?或者什么?您从 HDC 获取相关数据的唯一方法是通过普通消息泵绘制它,如果它隐藏或在屏幕外,或者如果您手动绘制它(显然您没有这样做),则不会发生这种情况。
这是了解无闪烁 Win32 的绝佳资源: http://www.catch22.net/tuts/闪烁
Is the interior panel invisible? off screen? or what? The only way you'll get relevant data from it's HDC is when it's been painted via the normal message pump, which is not gonna happen if it's hidden or off screen, or if you manually paint it, which you obviously aren't doing.
This is a great resource for learning about flicker free Win32: http://www.catch22.net/tuts/flicker