如何刷新整个设备的屏幕(Windows Mobile)?

时间:2010-03-26 22:33:33

标签: c# .net windows-mobile compact-framework pinvoke

我正在开发一个简单的应用程序,每2秒在屏幕的设备上下文中绘制一个alpha混合图片,我想在绘图操作之前刷新屏幕内容(擦除绘制的图片),

我已经使用了很多技巧但不幸的是,屏幕无法正确刷新,某些地区仍保留部分绘制的图片

我对此问题感到非常沮丧:(

这些是我使用过的源代码,我正在使用C#

SendMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, IntPtr.Zero, IntPtr.Zero); // wasted time in the refreshing process is enough to keep this.

UpdateWindow(HWND_BROADCAST);// does not work at all!

InvalidateRect(IntPtr.Zero,IntPtr.Zero,true); // the same goes here.

SendMessage(HWND_BROADCAST, WM_PAINT, IntPtr.Zero, IntPtr.Zero); // pfffff !

SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, new IntPtr(SPI_SETNONCLIENTMETRICS), IntPtr.Zero); // trying to refresh the explorer, no resutl

我还使用了EnumWindows并回拨,非常慢,并且不适合我的情况。

我想刷新整个屏幕

请帮忙!

此致

瓦利德

2 个答案:

答案 0 :(得分:1)

您可以在绘制任何内容之前复制屏幕图像,这样您就可以利用屏幕外的构图;而且您不需要先要求其他所有内容重绘。

答案 1 :(得分:0)

Declare Function SendMessage Lib "coredll.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
Declare Function GetDesktopWindow Lib "coredll.dll" () As IntPtr
Private Const WM_WININICHANGE As Long = &H1A ' 0x1a = 26 ; &HF2 = 242

SendMessage(GetDesktopWindow(),WM_WININICHANGE,& HF2,0)