[.net] VScrollBar usage

Started by
-1 comments, last by chrisliando 16 years, 1 month ago
Hi I am using C++ Whidbey and .Net 2.0. I use 2 listViews in Details view. I want to scroll BOTH listView AT THE SAME TIME using VScrollBar component, so I disabled the original listView scrollbars. I have successfully scroll the listView content but only from up to bottom, but I cannot do the reverse when the listView contents has reached bottom, it cannot returned upward.. I was confused how to check the VScrollBar value if it always the same with the increment. Please help me to scroll from bottom back to up. Thank you very much. Here is my code: using namespace System::Runtime::InteropServices; [DllImport("user32.dll")] static bool ShowScrollBar(System::IntPtr hWnd, int wBar, bool bShow); [DllImport("user32.dll")] static bool EnableScrollBar(System::IntPtr hWnd, UInt32 wSBflags, UInt32 wArrows); [DllImport("user32.dll")] static IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, UIntPtr wParam, IntPtr lParam); private: static int const SB_VERT = 1; private: static int const ESB_DISABLE_BOTH = 0x3; private: static int const ESB_ENABLE_BOTH = 0x0; private: static int const WM_VSCROLL = 0x115; private: System::Void Results_Load(System::Object^ sender, System::EventArgs^ e) { EnableScrollBar(this->lvSource->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); EnableScrollBar(this->lvDestination->Handle, Convert::ToUInt32(SB_VERT), ESB_DISABLE_BOTH); } private: System::Void vScrollBar1_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { if ( vScrollBar1->Value < vScrollBar1->Maximum ) SendMessage(this->lvSource->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); SendMessage(this->lvDestination->Handle, Convert::ToUInt32(WM_VSCROLL), System::UIntPtr(Convert::ToUInt64(ScrollEventType::SmallIncrement)), System::IntPtr(0)); }

This topic is closed to new replies.

Advertisement