Solved

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

Posted on 2004-09-14
3
2,301 Views
Last Modified: 2010-08-05
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...

Thanks
0
Comment
Question by:PETERJORDAN
3 Comments
 
LVL 4

Accepted Solution

by:
Delphian earned 500 total points
ID: 12071357
TScrollBar doesn't have a Canvas. And you need it to Draw.

You have some choices:
1- Derive your own  TScrollBar and add a canvas to it
2- Replace the TScrollBar for a control that have a Canvas property
3- Use a TPaintBox. Appear to me that control is designed to be a
a drawings'  blackboard

Tips:
#1 Way
See the code on Forms unit (TCUstomForm class) - it's pascal but the changes to
C++ are minimal and are easier to read (if you can read C++ code, pascal is not
a problem). Read on help about TControlCanvas unit

#2 Way
You can use a Panel. Or research on VCL source code for other containers
with a canvas (don't look on help - go rightly to source code)

#3 Way
No need. Press F1.

I hope this helps,

Fabricio
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

828 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