日期:2014-05-18  浏览次数:21111 次

如何禁止窗体的重绘???

下面是C++代码,但是不知道如何在c#下使用。。。

禁止窗体重绘:
SendMessage(hWnd, WM_SETREDRAW, FALSE, 0L);
允许窗体重绘:
SendMessage(hWnd, WM_SETREDRAW, TRUE, 0L);


------解决方案--------------------
一样的。

C#申明下API函数。然后就可以用了。
------解决方案--------------------
[DllImport( "USER32.DLL ", CharSet=CharSet.Auto, SetLastError=true)] 
public static extern bool SendMessage( 
IntPtr hWnd, // handle to destination window 
int Msg, // message 
int wParam, // first message parameter 
[MarshalAs(UnmanagedType.LPTStr)]StringBuilder lParam // second message parameter 
); 
const int WM_GETTEXT =0x000B;
const int FALSE = 0x0000;
const int TRUE = 0x0001;
SendMessage((IntPtr)this.Handle,WM_SETREDRAW,FALSE,0);

------解决方案--------------------
C# code

[DllImport( "USER32.DLL ", CharSet=CharSet.Auto, SetLastError=true)]  
public static extern bool SendMessage(  
IntPtr hWnd, // handle to destination window  
int Msg, // message  
int wParam // first message parameter  
);  
const int WM_GETTEXT =0x000B; 
const int FALSE = 0x0000;
const int TRUE = 0x0001;
SendMessage((IntPtr)this.Handle,WM_SETREDRAW,FALSE,0);

------解决方案--------------------
C# code

[DllImport( "USER32.DLL ", CharSet=CharSet.Auto, SetLastError=true)]  
public static extern bool SendMessage(  
IntPtr hWnd, // handle to destination window  
int Msg, // message  
int wParam, // first message parameter  
int lParam
);  
const int WM_GETTEXT =0x000B; 
const int FALSE = 0x0000;
const int TRUE = 0x0001;
SendMessage((IntPtr)this.Handle,WM_SETREDRAW,FALSE,0);

------解决方案--------------------
学习 学习
------解决方案--------------------
牛人啊