我想设计一个文本框,其中每行的索引都在一个单独的列表框旁边。所有内容几乎完成但滚动仍然是我的问题。当我使用WndProc
来控制滚动时,{ {1}}效果非常好并且同时使两个控件滚动,但是当我想通过列表框发送WM_VSCROLL
时,它不起作用。我想我可以使用技巧并迭代{ {1}}当用户移动鼠标滚轮但它也不起作用时。
WM_MOUSEWHEEL
WM_VSCROLL
是我的列表框的名称, private const int WM_VSCROLL = 0x115;
private const int WM_MOUSEWHEEL = 0x20A;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_VSCROLL )
{
Message newMessage = Message.Create(Sequence.Handle, m.Msg, m.WParam, m.LParam);
Sequence.DirectMessage(newMessage);//turn to thread
}
else if(m.Msg == WM_MOUSEWHEEL)
{
if((int)m.WParam<0)
{
Message newMessage = Message.Create(Sequence.Handle, WM_VSCROLL,(IntPtr)1,(IntPtr) 0);
Message newMessage2 = Message.Create(this.Handle, WM_VSCROLL, (IntPtr)1, (IntPtr)0);
Sequence.DirectMessage(newMessage);
base.WndProc(ref newMessage2);
}
else
{
Message newMessage = Message.Create(Sequence.Handle, WM_VSCROLL, (IntPtr)0, (IntPtr)0);
Message newMessage2 = Message.Create(this.Handle, WM_VSCROLL, (IntPtr)0, (IntPtr)0);
Sequence.DirectMessage(newMessage);
base.WndProc(ref newMessage2);
}
}
}
是我文本框的推荐。我会很感激任何帮助....
答案 0 :(得分:0)
与WM_SCROLL
:
[DllImport("user32.dll", EntryPoint = "SendMessage")]
internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
private const int WM_VSCROLL = 0x115;
private const int WM_MOUSEWHEEL = 0x20A;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_VSCROLL || m.Msg == WM_MOUSEWHEEL)
{
SendMessage(Sequence.Handle, (UInt32)m.Msg, m.WParam, m.LParam);
}
base.WndProc(ref m);
}