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

Painting position calculated from Parent or child?

0 views
Skip to first unread message

Raymond J. Schappe

unread,
Mar 29, 2002, 11:53:33 PM3/29/02
to
I was trying to kill a few hours creating a marble/drawing game for my 3 yr.
old and I ran into a problem/question.

At first I created two objects TMarbleHole and TMarbleBoard

Just for testing these new components I added the calculations as to where
each TMarbleHole should be placed in the parent's (TMarbleBoard) create
method

This worked well for a quick test, but now I would like to have the
positions and sizes of the TMarbleHoles resized and repositioned when the
parent TMarbleBoard is resized...

Two questions, first when I created lots of child components (TMarbleHole's)
in the parent's create (TMarbleBoard) I noticed that this was pretty
slow!!! - quite a lag time.

Second, where should I place the code to paint the children, at what
position, and what size... the position and size are really dependant upon
the parent's size...

Can someone point me in right direction?

Thanks,
--Raymond

Raymond J. Schappe
Isthmus Technology Solutions, LLC
______________________________________


Peter Below (TeamB)

unread,
Mar 30, 2002, 8:26:18 AM3/30/02
to
In article <3ca54398$1_2@dnews>, Raymond J. Schappe wrote:
> I was trying to kill a few hours creating a marble/drawing game for my 3 yr.
> old and I ran into a problem/question.
>
> At first I created two objects TMarbleHole and TMarbleBoard
>
> Just for testing these new components I added the calculations as to where
> each TMarbleHole should be placed in the parent's (TMarbleBoard) create
> method
>
> This worked well for a quick test, but now I would like to have the
> positions and sizes of the TMarbleHoles resized and repositioned when the
> parent TMarbleBoard is resized...
>
> Two questions, first when I created lots of child components (TMarbleHole's)
> in the parent's create (TMarbleBoard) I noticed that this was pretty
> slow!!! - quite a lag time.

Is the board already visible when you create the children? Even if it is not
you can probably speed up the total sequence by enclosing the creation of the
children in

DisableAlign;
try
...create children
finally
EnableAlign;
end;



> Second, where should I place the code to paint the children,

If you derive the children from TGraphicControl (which would be sensible) you
paint them in an overriden Paint method.

> at what position, and what size... the position and size are really
> dependant upon the parent's size...

Placing and sizing the children is the task of the board. Since it has to be a
TCustomControl descendent (needs a window handle to be able to host controls)
it has a Resize method which you can override. First call the inherited method
(which fires the OnResize event), then look at clientwidth and clientheigth,
iterate over the Controls array and size and position the children. The
operation will cause them to repaint themselves.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


Raymond J. Schappe

unread,
Mar 30, 2002, 11:04:18 AM3/30/02
to
Peter,

Thanks!!! That was exactly what I needed!

What I have done so far fits well... I just need to go a bit farther...<g>

Thanks,
-- Raymond


Raymond J. Schappe
Isthmus Technology Solutions, LLC
______________________________________
>

> Is the board already visible when you create the children? Even if it is
not
> you can probably speed up the total sequence by enclosing the creation of
the
> children in
>
> DisableAlign;
> try
> ...create children
> finally
> EnableAlign;
> end;
>
>

0 new messages