Solved

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

Posted on 2004-09-14
3
2,282 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

810 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