473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,395 developers and data experts.

Drawing Graphics

debasisdas
8,127 Expert 4TB
This article contains the basic syntax to draw graphics of various shapes and sizes in Visual Basic 6.0. Different types of geometrical shapes (rectangle, square, circle, arc, ellipse etc.) can be drawn on the form by using the following syntax.

Basic syntax (for line, rectangle, square)
=============================
Expand|Select|Wrap|Line Numbers
  1. OBJECT.LINE [STEP] (X1, Y1) [STEP] -(X2, Y2), [COLOR], [B[F]]
STEP -- KEYWORD SPECIFYING THAT THE STARTING POINT COORDINATES ARE RELATIVE TO THE CURRENT GRAPHICS POSITION GIVEN BY THE "CURRENTX" & "CURRRENTY" PROPERTIES.

X1, Y1 -- SINGLE VALUES INDICATING THE COORDINATES OF THE STARTING POINT FOR THE LINE OR RECTANGLE. IF OMITTED THE LINE BEGINS AT THE POSITION INDICATED BY CURRENTX AND CURRENTY.

STEP -- KEYWORD SPECIFYING THAT THE END POINT COORDINATES ARE RELATIVE TO THE LINE STARTING POINT.

X2, Y2--SINGLE VALUES INDICATING THE COORDINATES OF THE END POINT FOR LINE BEING DRAWN.

COLOR -- INDICATES THE COLOR OF THE LINE. CAN USE RGB() OR QBCOLOR() FUNCTIONS, OR NAMED COLOR CONSTANTS SUCH AS vbGreen.
IF OMITTED, THE CURRENT VALUE OF THE FORECOLOR PROPERTY IS USED.

B -- ("BOX") - IF INCLUDED, CAUSES A BOX TO BE DRAWN USING THE COORDINATES TO SPECIFY OPPOSITE CORNERS OF THE BOX.

F -- ("FILL") - CAN ONLY BE USED WITH "B" OPTION. IF USED, "F" SPECIFIES THAT THE BOX IS TO BE FILLED WITH SAME COLOR USED TO DRAW THE BOX. IF B IS NOT FILLED WITH F(F option is not used), THE BOX IS FILLED WITH CURRENT "FILLCOLOR" AND "FILLSTYLE". DEFAULT VALUE FOR FILLSTYLE IS TRANSPARENT.

Expand|Select|Wrap|Line Numbers
  1. Me.Line Step(7000, 5000)-Step(2000, 4000), QBColor(5), BF
Basic Syntax (for elliptical shapes - arc, circle, ellipse)
================================================
Expand|Select|Wrap|Line Numbers
  1. OBJECT.CIRCLE [STEP] (X, Y), RADIUS, [COLOR, START, END, ASPECT]
STEP -- SPECIFIES THAT THE CENTER OF THE CIRCLE OR ELLIPSE IS RELATIVE TO THE CURRENT COORDINATES GIVEN BY THE "CURRENTX" & "CURRENTY" PROPERTIES.

X, Y -- COORDINATES INDICATING THE CENTER POINT OF THE CIRCLE OR ELLIPSE.

RADIUS -- INDICATES THE RADIUS OF THE CIRCLE OR ELLIPSE.

START, END -- WHEN AN ARC (A PARTIAL CIRCLE) IS TO BE DRAWN, START AND END SPECIFY THE BEGINNING AND THE ENDING POSITION OF THE ARC.
THE RANGE FOR BOTH IS -2Pi RADIAN TO 2Pi RADIAN. THE DEFAULT VALUE FOR START IS 0 RADIANS AND THAT FOR END IS 2Pi RADIANS. IN OTHER WORDS, THE DEFAULT IS TO DRAW A COMPLETE CIRCLE OR ELLIPSE.

ASPECT -- INDICATES THE ASPECT RATIO OF THE CIRCLE/ELLIPSE. DEFAULT IS 1.0, WHICH YIELDS A PERFECT CIRCLE ON ANY SCREEN.

Expand|Select|Wrap|Line Numbers
  1. Me.Circle (ScaleWidth / 2, ScaleHeight / 2), Switch(ScaleWidth >= ScaleHeight, ScaleHeight / 2, ScaleWidth < ScaleHeight, ScaleWidth / 2), vbRed, 0, 3, 0.8
Hope it helps the user to draw any basic objects on form or picturebox.
Sep 11 '07 #1
4 12269
Killer42
8,435 Expert 8TB
I've just been doing a bit of editing, to correct a bit of the English and so on. I'm concerned about the text for the BF options on Line. You seem to be contradicting yourself. First you say the box will be filled with "the same color used to draw the box", then you say it's FillColor.

Which is it? (I can't remember.)
Sep 12 '07 #2
debasisdas
8,127 Expert 4TB
I've just been doing a bit of editing, to correct a bit of the English and so on. I'm concerned about the text for the BF options on Line. You seem to be contradicting yourself. First you say the box will be filled with "the same color used to draw the box", then you say it's FillColor.

Which is it? (I can't remember.)
Thanx for pointing to the error.
Actually this is a TYPO . I missed the NOT by mistake.
Any more suggestions are most welcome.
Sep 12 '07 #3
Killer42
8,435 Expert 8TB
Thanx for pointing to the error.
Actually this is a TYPO . I missed the NOT by mistake.
Any more suggestions are most welcome.
Ah. Well, I've learned something there. I didn't know the relationship between the F option and the Fillcolor property. Have drawn boxes plenty of times, and filled them, but it was always trial and error.
Sep 13 '07 #4
Thanks a lot .. i got the required output.
Jan 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Steve Long | last post by:
Hello, (total GDI newbie) I'm having trouble drawing just a simple line to display in a picturebox. I just want a straight, dotdash line. I have two methods, one works and one doesn't (it cause...
1
by: Paul Hoad | last post by:
I'm trying to use MeasureString() to determine the length in pixels of a string However to do I need a System.Drawing.Graphics object to do this I need to create a System.Drawing.Graphics...
4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
1
by: Hadar | last post by:
Hi, I'm getting "object is currently in use elsewhere" when I use System.Drawing.Graphics.MesureString. This is what I do: My controls use a utility class the helps it to mesure strings. To...
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
2
by: Peter Proost | last post by:
Hi group, I got the following piece of code which draws a square with stars round it, now I want the stars to rotate round the square, I can do this with the mx.rotate and a timer and an...
3
by: Eduard Witteveen | last post by:
Hello list, I have code the draw MyDrawingObject information on a System.Drawing.Graphics object. The code is more/less the following: I now want to rotate / mirror the object i draw. I've...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
0
by: Hasim AH | last post by:
Hi .. Just getting interested to learn C# and needs help. I want to write C# application so that the program will execute and draw graphics when the user select the drawing menu from the main...
2
by: Carl | last post by:
I'm new to C#, and I have only limited programming experience. I've been doing the video tutorials at MS's website, and they're very helpful, but I decided to experiment with GDI+ and have gotten...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.