强制窗口重绘整个屏幕

发布于 2024-09-09 03:35:22 字数 326 浏览 1 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

如果没有 2024-09-16 03:35:22

如果您仍然想强制重新绘制整个桌面,您可以使用

RECT rect;
::GetClientRect(::GetDesktopWindow(), &rect);
::RedrawWindow(::GetDesktopWindow(), &rect, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);

If you still want to force entire desktop to be repainted, you may use

RECT rect;
::GetClientRect(::GetDesktopWindow(), &rect);
::RedrawWindow(::GetDesktopWindow(), &rect, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);
无法回应 2024-09-16 03:35:22

最好的方法可能是保存以前的像素状态/颜色并在移动像素时恢复它。重新绘制整个屏幕似乎需要花费太多精力,而且会严重浪费资源。

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.

紅太極 2024-09-16 03:35:22

您可以使用RedrawWindow 将 hWnd 设置为 NULL。

You can use RedrawWindow with hWnd set to NULL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文