c#: SetScrollPos (user32.dll)

后端 未结 1 731
北恋
北恋 2021-01-21 01:04

I want to have 2 (rich)texboxes (vc# 2k8) with same scrolling... so when I scroll tb1 the tb2 scrolls to the same position. I use this functions:

[DllImport(\"us         


        
1条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 01:35

    I found answer

    [DllImport("user32.dll")]
    static extern int SetScrollPos(IntPtr hWnd, int nBar,
                    int nPos, bool bRedraw);
    
    [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
    static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
    
    
    
    public void ScrollTo(int Position) {
        SetScrollPos((IntPtr)textBox1.Handle, 0x1, Position, true);
        PostMessage((IntPtr)textBox1.Handle, 0x115, 4 + 0x10000 * Position, 0);
    } 
    

    0 讨论(0)
提交回复
热议问题