Board index » delphi » Strategy advice

Strategy advice


2003-12-19 11:05:55 PM
delphi231
Hello newsgroup
I have a component that I am adapting to suit my requirements. it is a
TCustomPanel descendant, and I am altering it to function something like the
TaskPane displayed when you initially open Microsoft Word 2002*. It has a
custom Paint routine, and I have it draw two slender buttons at the top and
bottom of the Panel depending upon whether all of the child controls that
have been placed on it are in the viewable area, or offscreen. In addition
the panel has a 'title' bar and buttons which are also painted at the top of
the panel by the Paint method.
I do a 'hit test' to check whether the cursor is over either button, and
scroll the contents of the Panel accordingly (very simply by iterating over
all of the child controls and incrementing or decrementing the .top property
of each until the top - or bottommost - control has come into view).
That all works pretty well - but for one thing... when child controls are
'scrolled' up or down, they appear on top of the scroll buttons (and title
bar) when they reach those regions, and I am not sure how I can stop them
from being 'overpainted'. Ideally child controls would gradually disappear
from view when reaching the co-ordinate positions of the buttons/title bar -
I'd thought about changing the 'visible' property of each control to
'false', but I don't want them to suddenly 'pop' in and out of view.
I've read a few newsgroup threads about BS_OWNERDRAW, and I was wondering
whether it might be possible and practical to try to manually draw over
those sections of any controls entering the scroll button regions - but that
seems like a lot of work, and quite a complicated way of going about it.
I don't really have any idea about how this works, but clearly Windows stops
drawing visual controls when they are outside of the viewable parent area -
is there some way I could 'trick' the child controls to achieve the same
effect?
At present, those are the only ideas that I have, and I would be very grateful
for any advice to alternative suggestions!
* I _swear_ I came across a purpose built freeware component on Torry.net a
few weeks ago, but I despite hours of searching I can not find it again now!
 
 

Re:Strategy advice

Peter Davies writes:
Quote
I do a 'hit test' to check whether the cursor is over either button, and
scroll the contents of the Panel accordingly (very simply by iterating over
all of the child controls and incrementing or decrementing the .top property
of each until the top - or bottommost - control has come into view).
Usually such scroll buttons are windowed child controls.
I am sure i have seen such a component in the JediVCL
sourceforge.net/projects/jvcl
 

Re:Strategy advice

Peter Davies wrote on Fri, 19 Dec 2003 15:05:55 -0000 ...
Isn't this something like the PageScroller control that comes with
Delphi? You could always look at the source for this.
Marc Rohloff
marc rohloff at bigfoot dot com
 

Re:Strategy advice

Peter Davies writes:
Quote
I have a component that I am adapting to suit my requirements. it is a
TCustomPanel descendant, and I am altering it to function something
like the TaskPane displayed when you initially open Microsoft Word
2002*. It has a custom Paint routine, and I have it draw two slender
buttons at the top and bottom of the Panel depending upon whether all
of the child controls that have been placed on it are in the viewable
area, or offscreen.
I'd think you could use a TPageScroller for that. it is on the Win32 page
of the Component Palette.
Quote
In addition the panel has a 'title' bar and buttons which are also
painted at the top of the panel by the Paint method. I do a 'hit
test' to check whether the cursor is over either button, and scroll
the contents of the Panel accordingly (very simply by iterating over
all of the child controls and incrementing or decrementing the .top
property of each until the top - or bottommost - control has come
into view).
You will run into major problems if that is how you intend to scroll the
controls. You won't be able to adjust the coordinates of anything with
an Align property other than alNone. I think TScrollBox or TPageScroller
will shed some light on how to move child controls. (Ultimately, I think
Windows handles the whole thing.)
Quote
That all works pretty well - but for one thing... when child controls
are 'scrolled' up or down, they appear on top of the scroll buttons
(and title bar) when they reach those regions, and I am not sure how I
can stop them from being 'overpainted'. Ideally child controls would
gradually disappear from view when reaching the co-ordinate positions
of the buttons/title bar - I would thought about changing the 'visible'
property of each control to 'false', but I don't want them to
suddenly 'pop' in and out of view.
I think the answer to this particular problem lies in adjusting the
client region of your control. You control's title and buttons would be
in the non-client area, at least as far as Delphi is concerned. You
should override the AdjustClientRect method to exclude the button and
title regions.
Or you could use a TPageScroller.
Quote
I've read a few newsgroup threads about BS_OWNERDRAW, and I was
wondering whether it might be possible and practical to try to
manually draw over those sections of any controls entering the scroll
button regions - but that seems like a lot of work, and quite a
complicated way of going about it.
Yes, that would be a lot of work, especially when you consider that not
all controls have owner-draw support.
--
Rob
 

Re:Strategy advice

Much food for thought here -
Robert: "Usually such scroll buttons are windowed child controls. I am sure
i have seen such a component in the JediVCL"
Thanks for that - I used the existing component architecture as a reference,
and since the title/caption was being created as a Persistent, I 'copied'
the technique when creating my two scroll buttons.
Marc: "Isn't this something like the PageScroller control that comes with
Delphi? You could always look at the source for this."
Yes indeed :-) But the CustomPanel has a tailored appearance that I really
like - with caption and close/hide buttons at the top (and my scroll buttons
at the top and bottom, rather than at the side), and I don't have much
confidence that I would be able to re-engineer a TScrollBox to achieve the same
visual effect
Rob: "You will run into major problems if that is how you intend to scroll
the controls. You won't be able to adjust the coordinates of anything with
an Align property other than alNone. I think TScrollBox or TPageScroller
will shed some light on how to move child controls. (Ultimately, I think
Windows handles the whole thing.)"
Agreed - I am planning to have the Panel take control of child control
positioning, though, so hopefully that won't be too much of a restriction.
At this point I am not really interested in generalising the component, I
just want to hardwire it for my purposes in this project.
I had a cursory look at the TScrollBox listing, and there's lots of good
stuff in there, so I will be having a thorough read.
Thanks to all
 

Re:Strategy advice

Peter Davies writes:
Quote
Yes indeed :-) But the CustomPanel has a tailored appearance that I
really like - with caption and close/hide buttons at the top (and my
scroll buttons at the top and bottom, rather than at the side),
TPageScroller has an Orientation property. It can scroll horizontally or
vertically.
--
Rob