Board index » cppbuilder » OnChange of scrollbars in TScrollBox

OnChange of scrollbars in TScrollBox


2003-09-30 02:21:30 AM
cppbuilder106
Hi!
I wrote a component TFlowContainer that is derived from TScrollBox. But
there are no events, if on of the scrollbar is chanced. How can I get notice
if the user chances the scrollbars of my TFlowContainer anyway?
Thanks
Gunter
 
 

Re:OnChange of scrollbars in TScrollBox

Hi!
I wrote a component TFlowContainer that is derived from TScrollBox. But
there are no events, if on of the scrollbar is chanced. How can I get notice
if the user chances the scrollbars of my TFlowContainer anyway?
Thanks
Gunter
 

Re:OnChange of scrollbars in TScrollBox

"Gunter Gemmel" wrote:
Quote

I wrote a component TFlowContainer that is derived from TScrollBox. But
there are no events, if on of the scrollbar is chanced. How can I get
notice
if the user chances the scrollbars of my TFlowContainer anyway?

Why do you want to know the user scrolled your component? The TScrollBox
should handle that all, that's what it is designed for. If you really need
to know you can catch WM_VSCROLL and WM_HSCROLL messages.
Peter
 

{smallsort}

Re:OnChange of scrollbars in TScrollBox

Because the content has to be changed. Is there a short example, how to
catch these messages?
Gunter
"Peter Agricola" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"Gunter Gemmel" wrote:
>
>I wrote a component TFlowContainer that is derived from TScrollBox. But
>there are no events, if on of the scrollbar is chanced. How can I get
notice
>if the user chances the scrollbars of my TFlowContainer anyway?
>

Why do you want to know the user scrolled your component? The TScrollBox
should handle that all, that's what it is designed for. If you really need
to know you can catch WM_VSCROLL and WM_HSCROLL messages.


Peter


 

Re:OnChange of scrollbars in TScrollBox

"Gunter Gemmel" wrote:
Quote
Because the content has to be changed. Is there a short example, how to
catch these messages?
It depends on what you are trying to accomplish. If you want to change
excisting behaviour or your actions have to take place before the originals
or you want to extend your new component ( eg with before~ or afterscroll
events) you have to override the WndProc function. If you just want to catch
the messages in this app I would make a MESSAGE_MAP. From both approaches
are examples in the Help.
Peter
 

Re:OnChange of scrollbars in TScrollBox

I figured out further, that there is an stack overflow error in the BEGIN...
line.
Gunter.
"Gunter Gemmel" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
I did the following:

In the .h file of TFlowContainer

protected:
virtual void __fastcall HandleVScroll(TMessage &msg);

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_VSCROLL, TMessage, HandleVScroll)
END_MESSAGE_MAP(TFlowContainer);

int the .cpp file:


//--------------------------------------------------------------------------
-
void __fastcall TFlowContainer::HandleVScroll(TMessage &msg)
{
// Let the default occur
TScrollBox::Dispatch( &msg );

}

When I start my program, it breaks down whith a protection fault.

Any idea?

Gunter.

"Peter Agricola" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
news: XXXX@XXXXX.COM ...
>
>"Gunter Gemmel" wrote:
>>Because the content has to be changed. Is there a short example, how
to
>>catch these messages?
>
>It depends on what you are trying to accomplish. If you want to change
>excisting behaviour or your actions have to take place before the
originals
>or you want to extend your new component ( eg with before~ or
afterscroll
>events) you have to override the WndProc function. If you just want to
catch
>the messages in this app I would make a MESSAGE_MAP. From both
approaches
>are examples in the Help.
>
>
>Peter
>
>


 

Re:OnChange of scrollbars in TScrollBox

"Gunter Gemmel" wrote:
Quote
>BEGIN_MESSAGE_MAP
>MESSAGE_HANDLER(WM_VSCROLL, TMessage, HandleVScroll)
>END_MESSAGE_MAP(TFlowContainer);
In the last line change TFlowContainer in TScrollBox, because these macro's
override the Dispatch method and create a switch statement. The last macro
calls the inherited dispatch, so you must give here the ancestor of your
control.
END_MESSAGE_MAP(TScrollBox);
Quote
>int the .cpp file:
>
>

//--------------------------------------------------------------------------
>-
>void __fastcall TFlowContainer::HandleVScroll(TMessage &msg)
>{
>// Let the default occur
>TScrollBox::Dispatch( &msg );
>
>}
Don't call TScrollBox::Dispatch in your function. It will be called by the
end_message_map macro
Peter
 

Re:OnChange of scrollbars in TScrollBox

This works fine, but if I scroll by using the mouse wheel VSCROLL isnt
cought. Is there a way to catch the OnChange event, that handels all
position changes?
Thanks again for your support.
Gunter.
"Peter Agricola" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"Gunter Gemmel" wrote:
>>BEGIN_MESSAGE_MAP
>>MESSAGE_HANDLER(WM_VSCROLL, TMessage, HandleVScroll)
>>END_MESSAGE_MAP(TFlowContainer);

In the last line change TFlowContainer in TScrollBox, because these
macro's
override the Dispatch method and create a switch statement. The last macro
calls the inherited dispatch, so you must give here the ancestor of your
control.
END_MESSAGE_MAP(TScrollBox);


>>int the .cpp file:
>>
>>
>

//--------------------------------------------------------------------------
>>-
>>void __fastcall TFlowContainer::HandleVScroll(TMessage &msg)
>>{
>>// Let the default occur
>>TScrollBox::Dispatch( &msg );
>>
>>}

Don't call TScrollBox::Dispatch in your function. It will be called by the
end_message_map macro


Peter



 

Re:OnChange of scrollbars in TScrollBox

"Gunter Gemmel" wrote:
Quote
This works fine, but if I scroll by using the mouse wheel VSCROLL isnt
cought.
You can catch also WM_MOUSEWHEEL message.
Quote
Is there a way to catch the OnChange event, that handels all
position changes?
There is no such event in TScrollBox or it's ancestors. The only method
suited for your purpose to override would be ScrollBy in TWinControl, but
this method isn't virtual. TScrollBox is not a container for one defined
item like a string, a picture or a boolean value wich can change. That's why
such an OnChange event would be meaningless. TScrollBox can be seen as a
panel bigger than the parentwindow so you can put more or bigger controls on
it than fit in the window. It automatically takes care for scrolling 'in
view'. But this scrolling doesn't change the TScrollBox.
I don't know what you try to accomplish but I have doubts about TScrollBox
being the correct ancestor for your control.
Peter
 

Re:OnChange of scrollbars in TScrollBox

Please clip your messages.
Look at: info.borland.com/newsgroups/netiquette.html
"Gunter Gemmel" wrote:
Quote
Im writing an program like visio and the drawing area is a large bitmap, i
have to update the bitmap in certain regions, whenever the user changes
the
view. The bitmap is placed in a tscrollbox

I've never done graphics programming but I know there are techniques for
drawing large bitmaps wich can't be drawn in once because of resource usage.
They cut the image in parts and draw only that part wich is visible. I think
that kind of technique will help you too. Search Google for drawing large
bitmaps or start here a new thread with the words 'large bitmaps' in the
subject.
Peter