Heya folks!
This one must be too simple to feature on a forum but its something that isn't coming thru for quite some time now!
I have two listview controls that i customized by overriding the WndProc() in order to capture their scroll events.Now I am attempting to use a common scrollbar for the two so that when that main scrolbar scrolls the listview scrollbars also scroll. Currently i am able to scroll the listview downwards but not able to scroll them back up.
Here's the customization part
Code:
[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int SBS_HORZ = 0;
private const int SBS_VERT = 1;
void listView1_Scroll(object sender, MyScrollEventArgs e)
{
ListViewEx listVw = sender as ListViewEx;
Int16 hi = (Int16)((int)e.WParam >> 16);//position
Int16 lo = (Int16)e.WParam;//scroll type
if (e.Orientation == ScrollOrientation.VerticalScroll)
{
if (lo == 5) //SB_THUMBTRACK
{
if (SetScrollPos(this.listView2.Handle, SBS_VERT, hi, true) != 0)
{
SendMessage(this.listView2.Handle, WM_VSCROLL,
(IntPtr)(4 + 0x10000 * hi), IntPtr.Zero);
}
}
else
{
SendMessage(this.listView2.Handle, WM_VSCROLL, e.WParam, IntPtr.Zero);
}
}
if (e.Orientation == ScrollOrientation.HorizontalScroll)
{
if (lo == 5)//SB_THUMBTRACK
{
SetScrollPos(this.listView2.Handle, SBS_HORZ, hi, true);
SendMessage(this.listView2.Handle, WM_HSCROLL,
(IntPtr)(4 + 0x10000 * hi), IntPtr.Zero);
}
else
{
SendMessage(this.listView2.Handle, WM_HSCROLL, e.WParam, IntPtr.Zero);
}
}
And here's the scroll calls that i was originally using and was partially working. I couldn't get the scrollbars to scroll with this, only thumb tracks would scroll each other.
Code:
int16 hi = (int16)((int)e.wparam >> 16);
int16 lo = (int16)(int)e.wparam;
intptr temp;
if (e.orientation == scrollorientation.verticalscroll)
{
if (lo == 5)
{
if (setscrollpos(this.listviewex2.handle, sbs_vert, hi, true) != 0)
{
temp = (intptr)(4 + 0x10000 * hi);
postmessage(this.listviewex2.handle, wm_vscroll, temp, intptr.zero);
//sendmessage(this.listviewex2.handle, wm_vscroll, (intptr)(4 + 0x10000 * hi), intptr.zero);
}
}
else
{
postmessage(this.listviewex2.handle, wm_vscroll, e.wparam, intptr.zero);
//sendmessage(this.listviewex2.handle, wm_vscroll, e.wparam, intptr.zero);
}
}
if (e.orientation == scrollorientation.horizontalscroll)
{
if (lo == 5)
{
setscrollpos(this.listviewex2.handle, sbs_horz, hi, true);
postmessage(this.listviewex2.handle, wm_hscroll, (intptr)(4 + 0x10000 * hi), intptr.zero);
//sendmessage(this.listviewex2.handle, wm_hscroll, (intptr)(4 + 0x10000 * hi), intptr.zero);
}
else
{
postmessage(this.listviewex2.handle, wm_hscroll, e.wparam, intptr.zero);
//sendmessage(this.listviewex2.handle, wm_hscroll, e.wparam, intptr.zero);
}
}
}
catch (exception ex)
{
messagebox.show(ex.tostring());
}
There are a couple of things I wanna know here.
1. How do i scroll one scrollbar from any other.
2. How do i use a main control scrollbar to scroll the two listview scrollbars?
3. How do i make the scrollbars to scroll back up from the lowered state?
I have failed to draw any logic on how to make sure that the two listview scroll bar events don't send each other on an infinite loop.
Plus, I need to scroll them by thumbtracks + scrollbars + mouse scroll wheel!
Somebody! please help me!
-
Roger
-
Roger