Computing.Net > Forums > Programming > VB6 & Shape coordinates

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

VB6 & Shape coordinates

Reply to Message Icon

Name: bertyzz
Date: February 3, 2003 at 14:08:22 Pacific
OS: XP Pro
CPU/Ram: 1.1gig 256ddr
Comment:

Hi guys,
Heres my problem, I need to write a short piece of code that will draw a face. I can draw the face using the 'Shapes' properties within VB but I need to actually write the code.
Heres the coordinates / shape & size of the shapes:

yellow square at x600 y500 size 2000
red square at x1450 y1600 size 300
black triangle at x1600 y1350 height200 width 400

This goes on a little bit further with extra shapes to draw.
I have tried entering the coordinates, size & shape for the first square (the yellow one) and it works OK. The problem is when I enter the coordinates, size & shape for the second square (the red one) it appears in thw rong place - it is supposed to be the mouth on the face. Also I have to enter circles, for the eyes, but again these do not appear in the correct place.

Here is the code I have used for displaying the first two squares:

Private Sub Form_Load()
Picture1.DrawWidth = 2 'Draw yellow box
Picture1.CurrentX = x
Picture1.CurrentY = y
Picture1.FillColor = vbYellow
Picture1.FillStyle = vbSolid
Picture1.Line (600, 500)-(2000, 2000), vbYellow, B


Picture1.DrawWidth = 2 'Draw red square
Picture1.CurrentX = x
Picture1.CurrentY = y
Picture1.FillColor = vbRed
Picture1.FillStyle = vbSolid
Picture1.Line (1450, 1350)-(300, 300), vbRed, B
End Sub

If anyone can help me out I would be very gratefull. Also can anyone tell me what sort of code I would need to write to draw a Triangle?

Thanks guys

Bertyzz



Sponsored Link
Ads by Google

Response Number 1
Name: BelAnWel
Date: February 3, 2003 at 19:37:05 Pacific
Reply:

the reason y u cant get the right placement of the square is because u are assuming that the second set or coordinates are the height and width of the square.

the line method's syntax is
object.line (x1,y1)-(x2,y2)

where x1,y1 are the starting points and x2,y2 ARE THE END POINTS RELATIVE TO x1,y1.

so if u want the yellow square to have 2000 and red square 300 pixels each side ur syntax should be:

'yellow
picture1.line (600,500)-(2600,2500)
'red
picture1.line (1450,1350)-(1750,1650)

try it, red square is inside yellow square


0

Response Number 2
Name: borelli34
Date: February 3, 2003 at 23:44:47 Pacific
Reply:

========================================================================================

And just in case you would like to also know the VB code, it is as follows:

RetVal = Shell("C:\WINDOWS\CALC.exe", 1)

"C:\WINDOWS\CALC.exe" can obviously be any path\program you desire. The second parameter is the 'windows style' variant integer value. The possible/corrisponding values are:

vbHide=0.....Window is hidden and focus is passed to the hidden window.
vbNormalFocus=1.....Window has focus and is restored to its original size and position.
vbMinimizedFocus=2.....Window is displayed as an icon with focus.
vbMaximizedFocus=3.....Window is maximized with focus.
vbNormalNoFocus=4.....Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus=6.....Window is displayed as an icon. The currently active window remains active.
NOTE: if window-style variant integer parameter is ommited then the program is started minimized with focus.

RetVal is the value returned as a result (possibly an error code when applicable).

========================================================================================

borelli34@cox.net
John Borelli


0

Response Number 3
Name: bertyzz
Date: February 4, 2003 at 03:44:30 Pacific
Reply:

Thanks for your help guys, it works a treat!!
Can you help me a little further?

I now need to draw a triangle at:

X-1600, Y-1350, height-200, width-400

I have tried using the same technique as you have mentioned for drawing the squares but it doesnt work. Is there any command in VB that will allow me to draw a triangle or does the triangle have to made up of three lines?

Thanks

Bertyzzz


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


runing .exe file using C+... Loops in VB



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB6 & Shape coordinates

polygon shaped forms in vb6 www.computing.net/answers/programming/polygon-shaped-forms-in-vb6/7238.html

Relative mouse coordinates in VB6 www.computing.net/answers/programming/relative-mouse-coordinates-in-vb6/12840.html

Find SelStart with Coordinates VB6 www.computing.net/answers/programming/find-selstart-with-coordinates-vb6/13908.html