Drawing squares, circles, and painted rectangles in Borland C++ Builder

Hi everybody,

I'm new in this community and in the C++ also...

I know that this question is too easy to answer but I realy would like this help.
In C++ Builder I have a form and a ScrollBox. How can I draw a square, a circle, a painted rectangle, a line and write a single char inside the ScrollBox but without using a TShape or TLabel component ?
If you have an example script it would be great!

ps: I don't want to use TShape component because actually I need to draw hundreds of shapes in the scrollbox and I think if I use a TShape or TLabel it will consume a lot of CPU...

ps2: sorry my english :(
 
PETERJORDANAsked:
Who is Participating?
 
George TokasCommented:
I think that your approach is a bit wrong..
Anyway.. You can use whatever code you can find on the web to draw the shapes you want as long as you obtain a handle on the form's canvas.
Also the Canvas property (on TForm) have some interesting functions such as rectangle  and ellipse and some more. You can find those at the help of BCB.
Now why I'm saying that your approach is wrong.
TShape and TLabel are wrappers to help you create applications FAST. Also the components are REAL FAST. Immagine that some 50 lines of code using standard code or using TCanvas functions can be implemented with only a few lines(3 or 4).

Regards,
gtokas.
0
 
PETERJORDANAuthor Commented:
thanks for your help gtokas.

Let me tell you what I am doing: now I've placed under ScrollBox a TImage component and I'm drawing over it. It seems to be all right 'till now. Also I need to do an extra code for the autosize of TImage component because when the form is maximized I have to do the same with it.

I just dont know how can I clean the images on the TImage.

Regards,

Peter.
0
 
George TokasCommented:
That means that you can create a rectangle with some color black lets say..
Made it on the same size as TImage and copy it to TImage..
The easiest way..

gtokas.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.