不是需要他不显示,而是需要他不滚动。使用了一个RichTextBox。我希望他按行滚动,而不是按象素滚动。所以加入代码:
this.MyText.VScroll += new System.EventHandler(this.Text_VScroll);private void Text_VScroll(object sender, EventArgs e) {
//引用了SendMessage。让他的滚动条又移动到当前行。
SendMessage(MyText.Handle.ToInt32(), WM_HSCROLL, 0, 0);
}但是这样的后果就是用鼠标移动滚动条时,出现闪烁。
怎么才能让这个RichTextBox按行滚动,切不发生闪烁呢。

解决方案 »

  1.   

    this.Load   +=   new   System.EventHandler(this.Form1_Load); 
    this.Unload   +=   new   System.EventHandler(this.Form1_FormClosed); 
    #region   *******************载入Dll文件信息******************* 
    //WindowPro监视 
    private   delegate   IntPtr   WndProcCallBack(IntPtr   hwnd,   int   Msg,   IntPtr   wParam,   IntPtr   lParam); [DllImport("User32.dll   ",   SetLastError   =   true)] 
    private   static   extern   int   SetWindowLong(IntPtr   hWnd,   int   nIndex,   int   dwNewLong); 
    [DllImport("User32.dll   ",   SetLastError   =   true)] 
    private   static   extern   int   GetWindowLong(IntPtr   hWnd,   int   nIndex); 
    [DllImport("User32.dll   ")] 
    private   static   extern   IntPtr   CallWindowProc(IntPtr   lpPrevWndFunc,   IntPtr   hWnd,   int   Msg,   IntPtr   wParam,   IntPtr   lParam); 
    private   const   int   GWL_WNDPROC   =   -4; 
    #endregion 
    private   IntPtr   newWndProc(IntPtr   hWnd,   int   iMsg,   IntPtr   wParam,   IntPtr   lParam)   { 
    System.String   MText   =   ""; 
    MText   +=   "   m.Msg:"   +   iMsg.ToString()   +   " "; 
    MText   +=   "   m.HWnd:"   +   hWnd.ToString()   +   " "; 
    MText   +=   "   m.LParam:"   +   lParam.ToString()   +   " "; 
    MText   +=   "   m.WParam:"   +   wParam.ToString()   +   " "; 
    Console.WriteLine(MText); 
    return   CallWindowProc(prevWndFunc,   hWnd,   iMsg,   wParam,   lParam); 

    private   IntPtr   prevWndFunc; 
    private   void   Form1_Load(object   sender,   EventArgs   e)   { 
    prevWndFunc   =   new   IntPtr(GetWindowLong(MyText.Handle,   GWL_WNDPROC)); 
    WndProcCallBack   vWndProcCallBack   =   new   WndProcCallBack(newWndProc); 
    SetWindowLong(MyText.Handle,   GWL_WNDPROC,Marshal.GetFunctionPointerForDelegate(vWndProcCallBack).ToInt32()); 

    private   void   Form1_FormClosed(object   sender,   FormClosedEventArgs   e)   { 
    SetWindowLong(MyText.Handle,   GWL_WNDPROC,   prevWndFunc.ToInt32()); 
    prevWndFunc   =   IntPtr.Zero; 
    }