| View previous topic :: View next topic |
| Author |
Message |
Jon Berndt Guest
|
Posted: Fri Mar 25, 2005 5:45 am Post subject: Getting a Scrolled event from TScrollBox |
|
|
Is it possible to get a scrolling message from a TScrollBox? I'd like to
redraw some things after (and during) TScrollBox scrolling.
Jon
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Fri Mar 25, 2005 9:22 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
Jon Berndt wrote:
| Quote: | Is it possible to get a scrolling message from a TScrollBox?
|
Yes. But you would have to derive a new class from TScrollBox
first and add MESSAGE_MAP and messagehandlers for for messages
WM_VSCROLL and WM_HSCROLL.
| Quote: | I'd like to
redraw some things after (and during) TScrollBox scrolling.
|
Where are you drawing on then ? On the TScrollBox?
If you use now a TScrollBox from the IDE where you droppend
some other components with the help of the IDE then I can
imagine that you do not like to derive a new class first.
But if want to (re)draw things then do the following.
Just drop a TPainBox on your existing TScrollBox. Align
alClient. Don't bother about the other components on the TScrollBox.
The TPaintBox has an OnPaint event which the TScrollBox
does not have. In the OnPaint handler you can query
the Position of a TScrollBar of a TScrollBox.
You will get an OnPaint for every change of Position.
Try this:
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
static int times = 0;
Label2->Caption = IntToStr ( ++times );
Label3->Caption = IntToStr ( ScrollBox1->VertScrollBar->Position );
PaintBox1->Canvas->MoveTo ( 0, 0 );
PaintBox1->Canvas->LineTo ( PaintBox1->Width, PaintBox1->Height );
}
Hans.
|
|
| Back to top |
|
 |
Jon Berndt Guest
|
Posted: Fri Mar 25, 2005 12:16 pm Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
| Quote: | If you use now a TScrollBox from the IDE where you droppend
some other components with the help of the IDE then I can
imagine that you do not like to derive a new class first.
|
That is correct! :-)
| Quote: | But if want to (re)draw things then do the following.
Just drop a TPainBox on your existing TScrollBox. Align
alClient. Don't bother about the other components on the TScrollBox.
The TPaintBox has an OnPaint event which the TScrollBox
does not have. In the OnPaint handler you can query
the Position of a TScrollBar of a TScrollBox.
|
This sounds like it might work. But, what do you mean by, "Don't bother
about the other components on the TScrollBox.". Do you mean it is still OK
to drop other components on the TScrollBox? Or, now I will be dropping them
on the TPaintBox?
Jon
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Mar 25, 2005 6:35 pm Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
"Hans Galema" <notused (AT) notused (DOT) nl> wrote
| Quote: | Yes. But you would have to derive a new class from TScrollBox
first and add MESSAGE_MAP and messagehandlers for for
messages WM_VSCROLL and WM_HSCROLL.
|
If you subclass the WindowProc property, then you don't need to derive a new
component.
Gambit
|
|
| Back to top |
|
 |
Jon Berndt Guest
|
Posted: Sat Mar 26, 2005 1:48 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
| Quote: | "Hans Galema" <notused (AT) notused (DOT) nl> wrote in message
news:4243d8be$1 (AT) newsgroups (DOT) borland.com...
Yes. But you would have to derive a new class from TScrollBox
first and add MESSAGE_MAP and messagehandlers for for
messages WM_VSCROLL and WM_HSCROLL.
If you subclass the WindowProc property, then you don't need to derive a
new
component.
Gambit
|
"Subclass the WindowProc property"? Can you give me a reference to read up
on for that? I've written components before (successfully!), but it's been a
while. I vaguely remember reading about the WindowProc property.
Also, you mentioned using a PaintBox, previously. Thanks for that, too. I
did try that and it works very well indeed for what I am doing.
Jon
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Sun Mar 27, 2005 10:15 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
Jon Berndt wrote:
| Quote: | Also, you mentioned using a PaintBox, previously.
|
No. He did not.
| Quote: | Thanks for that, too. I
did try that and it works very well indeed for what I am doing.
|
You gave it to the wrong man who then kept it.
Hans.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Mar 28, 2005 6:37 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
"Jon Berndt" <jsb (AT) hal-pc (DOT) dot.org> wrote
| Quote: | "Subclass the WindowProc property"? Can you give
me a reference to read up on for that?
|
Subclass a windows control
http://web.archive.org/web/20040218004538/bcbdev.com/faqs/faq76.htm
Gambit
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Mar 28, 2005 6:39 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
"Hans Galema" <notused (AT) notused (DOT) nl> wrote
Yes, actually I did. Look at the "Drawing on a TScrollBox?" discussion on
3/22 in this same newsgroup.
Gambit
|
|
| Back to top |
|
 |
Hans Galema Guest
|
Posted: Wed Mar 30, 2005 8:36 am Post subject: Re: Getting a Scrolled event from TScrollBox |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | Yes, actually I did. Look at the "Drawing on a TScrollBox?" discussion on
3/22 in this same newsgroup.
|
Indeed. That was for me a confusing remark of Jon as I had just
mentioned using a paintbox.
I apologize.
Hans.
|
|
| Back to top |
|
 |
|