Solved

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

Posted on 2004-09-14
3
2,345 Views
Last Modified: 2013-11-17
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 :(
 
0
Comment
Question by:PETERJORDAN
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
George Tokas earned 500 total points
ID: 12062413
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
 

Author Comment

by:PETERJORDAN
ID: 12063556
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
 
LVL 16

Expert Comment

by:George Tokas
ID: 12065222
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now