simplest way to use scrollbars without Autoscroll?

  • Thread starter Thread starter =?ISO-8859-1?Q?Kaimar_Seljam=E4e?=
  • Start date Start date
?

=?ISO-8859-1?Q?Kaimar_Seljam=E4e?=

Hi,

I would like to use Form's AutoScroll property, but only partially.
Everything is ok except scrolling when ActiveControl changes (the first
part of "AutoScroll").
For example my code calls someControl.Focus() which results in scrolling
even if the someControl is partially visible. Tab key and mouse click
behave in the same way :(
Is it possible to disable that part of autoscrolling features and still
use built-in scrollbars? Maybe some WndProc() trick?

I got it to work with AutoScroll=False but I don't like the idea of
implementing all the scrolling from scratch (scrollbar events, page
up/down etc keys, mouse wheel)

Thanks in advance!
Kaimar Seljamäe
 
Hi!
You could use the code below for your control.

protected override void WndProc(ref System.Windows.Forms.Message m)
{
base.WndProc (ref m);
if ((m.Msg == 0x0115))
{
//scroll down
if (m.WParam.ToInt32() == 1)
{
...
}
else
{
//scroll up
if (m.WParam.ToInt32() == 0)
{
...
}
}
}
}

Hope that helps.
Best regards, Adrian.
 
Back
Top