Panel

  • Thread starter Thread starter Charles A. Lackman
  • Start date Start date
C

Charles A. Lackman

Hello,

Is there a way to catch the scroll event inside a panel? When the user
changes the scroll poition, I need to know.

Any assistance will be greatly appreciated.

Thanks,

Chuck
 
Dear Charles,
Following code might help you. you have to
create a class as native window and the events will be recieved by you
in this class. I did this for testing purpose so it is not extensivly
tested. I used it to track Scrolling in the RichTextBox but if the user
is using the buttons to scroll then it'll work but if the user is using
the scrollbar to scroll then it sometimes does not raise event.

Native Window Class code : CustomNativeWindow.Cs

public delegate void WindowProc(System.Windows.Forms.Message uMsg);
public class CustomNativeWindow:System.Windows.Forms.NativeWindow
{
public event WindowProc WindowProcedure;
public CustomNativeWindow(IntPtr pWindowHandle)
{
base.AssignHandle(pWindowHandle);
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc (ref m);
WindowProcedure(m);
}
public void SendWndProc(System.Windows.Forms.Message uMsg)
{
base.WndProc(ref uMsg);
}
}

you have to create your custom panel by inherting it from the native
window
and write the following code in the custom panel constructor.

nativeWindow=new CustomNativeWindow(this.Handle);
nativeWindow.WindowProcedure+=new
WindowProc(nativeWindow_WindowProcedure);

I hope it helps.

Regards,
Naveed Ahmad Bajwa
Kalsoft Pvt Ltd
 
Back
Top