强制窗口重绘整个屏幕
我目前正在使用 GDI 绘制图形,但我需要能够重绘整个桌面/屏幕。我的图形是在屏幕上绘制的,但是当我移动绘制的像素时,它会变成一条线,因为我没有重新绘制屏幕(Windows 也不是)。我需要一些东西来强制它重绘整个屏幕,我尝试了以下方法:
UpdateWindow(GetDesktopWindow() );
InvalidateRect( GetDesktopWindow(), NULL, TRUE );
SendMessage( GetDesktopWindow(), WM_PAINT, NULL, NULL );
它们似乎都不起作用,我只需要重绘整个屏幕。
I am currently drawing graphics with GDI but I need to be able to redraw the entire desktop/screen. My graphics are drawn on the screen but when I would move a plotted pixel it would become a line because I am not redrawing the screen ( well windows isn't ). I need something to force it to redraw the entire screen, I've tried the following approaches:
UpdateWindow(GetDesktopWindow() );
InvalidateRect( GetDesktopWindow(), NULL, TRUE );
SendMessage( GetDesktopWindow(), WM_PAINT, NULL, NULL );
None of them seem to work, I just need the entire screen to redraw.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您仍然想强制重新绘制整个桌面,您可以使用
If you still want to force entire desktop to be repainted, you may use
最好的方法可能是保存以前的像素状态/颜色并在移动像素时恢复它。重新绘制整个屏幕似乎需要花费太多精力,而且会严重浪费资源。
The best way might be to save the previous pixel state/color and restore it when you move the pixel. Redrawing the whole screen seems like too much effort and an aweful waste of resources.
您可以使用RedrawWindow 将 hWnd 设置为 NULL。
You can use RedrawWindow with hWnd set to NULL.