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 

Palettes - moving vertical bars

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
JohnS
Guest





PostPosted: Thu Apr 05, 2007 6:37 am    Post subject: Palettes - moving vertical bars Reply with quote



Hi,

I'm using Delphi 6 Pro and running windows XP.
I want to generate moving black and white vertical bars across the
full width of the screen.
The speed of the bars to be under program control.

I was thinking along the lines of using a palette of about 200 entries
and changing the entries to create movement.

There seems to be very little info about the use of palettes and what
there is appears to be confusing.

Has anyone done something similar or can point me in the right
direction.

Thanks,
Back to top
Peter Below (TeamB)
Guest





PostPosted: Thu Apr 05, 2007 8:48 pm    Post subject: Re: Palettes - moving vertical bars Reply with quote



JohnS wrote:

Quote:
I'm using Delphi 6 Pro and running windows XP.
I want to generate moving black and white vertical bars across the
full width of the screen.
The speed of the bars to be under program control.

I was thinking along the lines of using a palette of about 200 entries
and changing the entries to create movement.

There seems to be very little info about the use of palettes and what
there is appears to be confusing.

Has anyone done something similar or can point me in the right
direction.

Palettes have fallen out of use since the standard color depth found on
the classic desktop PC is now at least 16K colors, if not more.

What you want to do sounds like a pretty standard animation task.
Create a form with Borderstyle bsNone, drop a TPaintbox on it and set
its Align to alClient. In the forms OnCreate event, set its Windowstate
to wsMaximized. You now have a full screen drawing area at your
disposal. In the OnCreate event, create two instances of TBitmap and
store them into two fields of the form (or one fields typed as array
[0..1] of Tbitmap). Add an OnDestroy event to the form and there free
the two bitmaps (this is not automatic).

Set the size of the two bitmaps to the dimensions of your paintboxes
client area. Fill the first bitmap with the background color of your
image.

You now need two further pieces for this puzzle. The first handles the
actual display of the bitmap. Add a handler to the paintboxes OnPaint
event and in it draw the first bitmap to the paintboxes canvas. Be sure
to test whether the bitmap reference is <> nil before you access it.

The second part handles the animation. You can use a TTimer for that,
drop one on the form, set its Interval to 100 (10 frames per second),
its Enabled property to true, assign a handler to its OnTimer event. In
the event you fill the second bitmap with the background color, then
draw the pattern of bars to its canvas. Then swap the two bitmap
references and call the paintboxes Invalidate method.

You can close the form using Alt-F4, since there is neither close box
nor system menu there is no way to close it with the mouse. You can add
mouse support by adding a context menu for the paintbox, for example.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be
Back to top
JohnS
Guest





PostPosted: Tue Apr 10, 2007 4:41 am    Post subject: Re: Palettes - moving vertical bars Reply with quote



On Apr 6, 1:48 am, "Peter Below (TeamB)" <none> wrote:
Quote:
JohnS wrote:
I'm using Delphi 6 Pro and running windows XP.
I want to generate moving black and white vertical bars across the
full width of the screen.
The speed of the bars to be under program control.

I was thinking along the lines of using a palette of about 200 entries
and changing the entries to create movement.

There seems to be very little info about the use of palettes and what
there is appears to be confusing.

Has anyone done something similar or can point me in the right
direction.

Palettes have fallen out of use since the standard color depth found on
the classic desktop PC is now at least 16K colors, if not more.

What you want to do sounds like a pretty standard animation task.
Create a form with Borderstyle bsNone, drop a TPaintbox on it and set
its Align to alClient. In the forms OnCreate event, set its Windowstate
to wsMaximized. You now have a full screen drawing area at your
disposal. In the OnCreate event, create two instances of TBitmap and
store them into two fields of the form (or one fields typed as array
[0..1] of Tbitmap). Add an OnDestroy event to the form and there free
the two bitmaps (this is not automatic).

Set the size of the two bitmaps to the dimensions of your paintboxes
client area. Fill the first bitmap with the background color of your
image.

You now need two further pieces for this puzzle. The first handles the
actual display of the bitmap. Add a handler to the paintboxes OnPaint
event and in it draw the first bitmap to the paintboxes canvas. Be sure
to test whether the bitmap reference is <> nil before you access it.

The second part handles the animation. You can use a TTimer for that,
drop one on the form, set its Interval to 100 (10 frames per second),
its Enabled property to true, assign a handler to its OnTimer event. In
the event you fill the second bitmap with the background color, then
draw the pattern of bars to its canvas. Then swap the two bitmap
references and call the paintboxes Invalidate method.

You can close the form using Alt-F4, since there is neither close box
nor system menu there is no way to close it with the mouse. You can add
mouse support by adding a context menu for the paintbox, for example.

--
Peter Below (TeamB)
Don't be a vampire (http://slash7.com/pages/vampires),
use the newsgroup archives :http://www.tamaracka.com/search.htmhttp://groups.google.comhttp://www.prolix.be

Peter,
Thanks for that. I hadn't considered that approach.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics 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.