绘制到屏幕的 DC C++ 后强制屏幕重绘
我正在创建一个 Windows Mobile 自定义 SIP,当用户按下或“悬停”在键盘上的按钮上时,我使用 ::GetDC(NULL) 将其相应的选定图像(iPhone 式)绘制到屏幕的 DC。 它是用 Win32 C++ 开发的。
我的问题是我永远无法让屏幕自行重新绘制,从而擦除之前绘制的键。 我已经尝试了所有我能想到的强制方法,::RedrawWindow() 以及使用 NULL 或任何 Get..Window 函数作为 HWND 的所有不同参数组合,以及所有标志组合(INVALIDATE | UPDATENOW | ERASENOW) | 所有儿童等)。 我还尝试过使矩形无效并使用 ::GetActiveWindow 和 ::GetForegroundWindow 强制重新绘制底层应用程序,使用 ::GetDesktopWindow 等进行变体。我基本上已经没有想法了,这是阻止我的最后一件事在我的 Windows Mobile 设备上使用它。 有人有什么想法吗? 任何帮助将不胜感激。
我提供了一些屏幕截图来说明我的困境。
在 http://img13.imageshack.us/img13/9861/cezoom1 之前。 png http://img3.imageshack.us/img3/7481/ 之后cezoom2.png
提前致谢!
I'm creating a Windows Mobile custom SIP and as the user presses or "hovers" over a button on the keyboard I draw it's corresponding selected image (iPhone-esque) to the screen's DC using ::GetDC(NULL). It is developed in Win32 C++.
My problem is that I can never get the screen to repaint itself, erasing the previously drawn key. I've tried everything I could think of to force it, ::RedrawWindow() with all different combos of params using NULL or any of the Get..Window functions as the HWND, and all combo of flags (INVALIDATE | UPDATENOW | ERASENOW | ALLCHILDREN etc). I've also tried invalidating the rect and forcing a repaint of the underlying app using ::GetActiveWindow and ::GetForegroundWindow, variations using ::GetDesktopWindow, etc. I've essentially run out of ideas and it's the last thing holding me up from using it on my Windows Mobile device. Does anyone have any ideas? Any help would be greatly appreciated.
I've included some screenshots to illustrate my dilemma.
Before Screenshot
After Screenshot
Before http://img13.imageshack.us/img13/9861/cezoom1.png After http://img3.imageshack.us/img3/7481/cezoom2.png
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不创建一个临时窗口并绘制到其中,而不是绘制到背景 DC? 当您销毁窗口时,背景应该自动重新绘制。
我只是猜测,因为我不了解 Windows Mobile,但 Windows 可能会缓存最后绘制到 DC 中的内容,并在每次使窗口无效时重新绘制它。
Rather than drawing to the background DC, why don't you create a temporary window and draw into that? When you destroy the window, the background should get repainted automatically.
I'm just guessing, because I don't know Windows Mobile, but it could be that Windows is caching the last thing that was drawn into the DC and repainting it every time you invalidate the window.
你试过在屏幕 hWnd 上使用 InvalidateRect 吗?
Have you tried InvalidateRect on the screen hWnd?