BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting a Scrolled event from TScrollBox

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Jon Berndt
Guest





PostPosted: Fri Mar 25, 2005 5:45 am    Post subject: Getting a Scrolled event from TScrollBox Reply with quote



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





PostPosted: Fri Mar 25, 2005 9:22 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote



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





PostPosted: Fri Mar 25, 2005 12:16 pm    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote




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





PostPosted: Fri Mar 25, 2005 6:35 pm    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote


"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





PostPosted: Sat Mar 26, 2005 1:48 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote

"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





PostPosted: Sun Mar 27, 2005 10:15 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote

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





PostPosted: Mon Mar 28, 2005 6:37 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote


"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





PostPosted: Mon Mar 28, 2005 6:39 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote


"Hans Galema" <notused (AT) notused (DOT) nl> wrote


Quote:
No. He did not.

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





PostPosted: Wed Mar 30, 2005 8:36 am    Post subject: Re: Getting a Scrolled event from TScrollBox Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.