Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TScrollBox and scrollbars

353 views
Skip to first unread message

Graham Stratford

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Can't you just draw the entire TImage.Picture.Bitmap? Then it will draw the
revealed section automatically. It really doesn't make much sense to use a
TImage in a TScrollBox, and then do this drawing yourself. If you have to
draw dynamically, just use a TScrollBar with a TPanel (or TPaintBox or
whatever) and trap the scrollbar movements for drawing.

Graham

"Paul Nicholls" <pha...@southcom.com.au> wrote in message
news:393602cf@dnews...
> Hi all, I have a TScrollBox with a TImage inside it to act as a canvas for
> some drawing. I am drawing grid dots onto the image during the Form.Show
> event and I was wondering how I could catch when the scrollbox 'canvas' is
> scrolled and hidden parts are now revealed. I want to do this so I can
> update the grid dots onto the newly revealed sections of the image which
at
> the moment are blank.
> Any hints/tips/code? I am using Delphi 3 Standard.
>
> Thanks in advance,
> Paul Nicholls,
> Live long and optimise!
>
> Home Page: www.southcom.com.au/~phantom
> Email : pha...@southcom.com.au
>
> < IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
> < http://www.alladvantage.com/go.asp?refid=BEM-274 >
>
>


Paul Nicholls

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
>Can't you just draw the entire TImage.Picture.Bitmap? Then it will draw the
>revealed section automatically. It really doesn't make much sense to use a
>TImage in a TScrollBox, and then do this drawing yourself.

I am using TImage for persistence. It means I don't have to draw the
background stuff all the time in a paint method or similar. The problem is
that the scrollbox doesn't have any scrolling events for me to trap to
update the image when the image is 'expanded'when the scrollbox is scrolled.

>If you have to
>draw dynamically, just use a TScrollBar with a TPanel (or TPaintBox or
>whatever) and trap the scrollbar movements for drawing.

I am also storing controls inside the the scrollbox as I thought this was
the easiest way to store the controls and allow them to scroll and move
around. I want to draw on the image when displaying linking lines between
components when they are joined together...
--

Graham Stratford

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Well if you are using a TImage, then all you have to do is draw to your
TImage. If you make it the full size of whatever you want to scroll around
(DON'T set alignment to alClient), then it will just scroll. Whatever pixels
you had drawn on the TImage's bitmap will appear as God (and the VCL
designers) intended them to.

I guess I still may not be understanding what you want to do. Here's what I
think you want:

1. Put a TScrollBox on the form. Let's say that Height = 300, Width = 400.
2. Put a TImage in the TScrollBox. Set its dimensions to 900x700
3. Put your controls on the TImage (they will still have the TScrollBox as
their parent, but will appear above the TImage.
4. Draw, scroll, etc. to your heart's content.

I did something like this a couple of years ago (a quiz program with buttons
and edit fields on a scrolling form) and it worked fine.

Is this not what you wanted?

Graham

"Paul Nicholls" <pha...@southcom.com.au> wrote in message

news:39360dca@dnews...

Graham Stratford

unread,
Jun 1, 2000, 3:00:00 AM6/1/00
to
Oh yes. If you do what I said, the Left and Top values for any controls you
drop in the box will change as you scroll, often to negative values. If you
don't like that, put in a TPanel, set it to the full dimensions, then a
TImage on that (set to alClient), then the controls.

Graham

"Graham Stratford" <stratford.@NOSPAMkb.jcs.co.jp> wrote in message
news:39361a37@dnews...

Alex Denissov

unread,
Jun 2, 2000, 3:00:00 AM6/2/00
to
Paul,

If you need to catch scrolling events, you may use WM_HSCROLL or WM_VSCROLL
messages, for example:

-----------------------------------------

unit EnhScrollBox;

interface

uses
Windows, Messages, SysUtils, Classes, Controls, Forms;

type
TEnhScrollBox = class(TScrollBox)
private
FOnScrollHorz: TNotifyEvent;
FOnScrollVert: TNotifyEvent;
protected
procedure DoScrollHorz; dynamic;
procedure DoScrollVert; dynamic;
procedure WMScrollHorz(var Msg: TMessage); message WM_HSCROLL;
procedure WMScrollVert(var Msg: TMessage); message WM_VSCROLL;
published
property OnScrollHorz: TNotifyEvent read FOnScrollHorz write
FOnScrollHorz;
property OnScrollVert: TNotifyEvent read FOnScrollVert write
FOnScrollVert;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Additional', [TEnhScrollBox]);
end;

{ TEnhScrollBox }

procedure TEnhScrollBox.DoScrollHorz;
begin
if Assigned(FOnScrollHorz) then FOnScrollHorz(Self);
end;

procedure TEnhScrollBox.DoScrollVert;
begin
if Assigned(FOnScrollVert) then FOnScrollVert(Self);
end;

procedure TEnhScrollBox.WMScrollHorz(var Msg: TMessage);
begin
inherited;
DoScrollHorz;
end;

procedure TEnhScrollBox.WMScrollVert(var Msg: TMessage);
begin
inherited;
DoScrollVert;
end;

end.

---------------------------------------
The new position may be obtained from standard HorzScrollBar and
VertScrollBar properties.

--
Alex Denissov
http://www.geocities.com/den_alex

"Paul Nicholls" <pha...@southcom.com.au> wrote in message

news:393602cf@dnews...
> Hi all, I have a TScrollBox with a TImage inside it to act as a canvas for
> some drawing. I am drawing grid dots onto the image during the Form.Show
> event and I was wondering how I could catch when the scrollbox 'canvas' is
> scrolled and hidden parts are now revealed. I want to do this so I can
> update the grid dots onto the newly revealed sections of the image which
at
> the moment are blank.
> Any hints/tips/code? I am using Delphi 3 Standard.
>
> Thanks in advance,

Paul Nicholls

unread,
Jun 5, 2000, 3:00:00 AM6/5/00
to
Thanks Alex.

--


Paul Nicholls,
Live long and optimise!

< IF YOU WANT TO EARN MONEY WHILE YOU SURF ON THE NET GO HERE: >
< http://www.alladvantage.com/go.asp?refid=BEM-274 >

0 new messages