simplest way to use scrollbars without Autoscroll?

  • Thread starter =?ISO-8859-1?Q?Kaimar_Seljam=E4e?=
  • 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
 
A

Adrian

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top