Professional Documents
Culture Documents
0
Private Sub Form_Paint()
' Draw a line with a thickness of 1 pixel.
DrawWidth = 1
Line (0, 200)-(ScaleWidth, 200), vbBlack
' Draw a line with a thickness of 5 pixels.
DrawWidth = 5
Line (0, 400)-(ScaleWidth, 400), vbBlack
' Draw a line with a thickness of 10 pixels.
DrawWidth = 10
Line (0, 600)-(ScaleWidth, 600), vbBlack
End Sub
Here are some tips on how you can monitor some lines in a straight line on a for
m
Random lines
To follow that track the mouse, click on the form, press and hold the right butt
on and move.
Release button to finish.
Straight Lines
To draw straight lines, click on the form, from the starting point and press and
hold the button, move the mouse pointer to the destination point and release th
e button.
Coding
For this function, move the code as shown below.
It can be used on any control that contains an hdc.
Option Explicit
Const PS_SOLID = 0
Const Epp = 10 'size of the line
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Lon
g
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObj
ect As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal n
Width As Long, ByVal crColor As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long,
ByVal Y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, _
ByVal X As Long, ByVal Y As Long, lpPoint As Any) As Long
-----------
Line1.X1 = 0
Line1.Y1 = 0
Line1.X2 = 0
Line1.Y2 = 0
Line1.Visible = False
Picture1.Visible = False
Picture1.Visible = True
'*************************************************
'All this extra code will draw a square on any angle, but not the rectangle
'that I want to use
Dim X1 As Long
Dim X2 As Long
Dim Y1 As Long
Dim Y2 As Long
Dim SlopeT As Long 'Top part of slope fraction
Dim SlopeB As Long 'Bottom part of slope fraction
SlopeT = (h - f) * 1
SlopeB = (g - e) * -1
X1 = e + SlopeT
Y1 = f + SlopeB
Picture1.Line (e + SlopeT, f + SlopeB)-(e, f), RGB(50, 75, 255)
'the other side
SlopeT = (f - h) * -1
SlopeB = (e - g) * 1
X2 = g + SlopeT
Y2 = h + SlopeB
Picture1.Line (g + SlopeT, h + SlopeB)-(g, h), RGB(50, 75, 255)
'And the last line
Picture1.Line (X1, Y1)-(X2, Y2), RGB(50, 75, 255)
End Sub
--------------------------------------------------------------------------------
The Angle.
regarding the code below, i didn't anderstand how do you set the angle to be 90
dgrees left or right?
thanks.
Code:
Public Const PI As Long = 3.14159265358979
Public Function RadToDeg(dAngle As Double) As Double
RadToDeg = dAngle * (PI / 180)
End Function
Any ideas on how to solve this problem?
--------------------------------------------------------------------------------
Angle Calculation
Hey there
I would like to ask about angel calculations, using grid..does anyone know how t
o go about this cause i can't seem to find examples on this in vb.... esp vb gra
phics
thanks
--------------------------------------------------------------------------------
How I Get Angle Between Two Lines?
I only get the angle between two segment lines of 0º to 180º.
HowIi get of 0º to 360º?
The result I get is from 0º to 180º and I want from 0º to 360º.
Marco mota
--------------------------------------------------------------------------------
GFX.RotateTransform(angle) In VB6?
I read a little on how to use this, but then i realized it was talking about .NE
T....is there any equilivence to this in VB6? basically I want to rotate an imag
e.
--------------------------------------------------------------------------------
Rotate By Angle (in Dx)
Hi,
how can I rotate the object(dx) by angle???
thanks
--------------------------------------------------------------------------------
Angle Between Two Lines
I have two lines AB, BC with known coordinates. they both have a common coordina
te at point B.
How to find angle between AB and BC wrt VB6.
any Help for formula for finding angle at B.
--------------------------------------------------------------------------------
Finding An Angle
with known value of TanA, how to find the value of A.
A is in radians. i am using VB6.
any help pl.