I am working a problem VB-2005 and I am a little confused. If I used the following, I can draw lines. But if I try to use what lesson calls for I cannot draw lines.
graphicsObject.DrawLine(New Pen(Color.Black), _
e.X, e.Y, DIAMETER, DIAMETER)
Versus
graphicsObject.DrawLine(New Pen(Color.Black), _
x1, y1, x2, y2)
is this because I used the following statement ealier in the program?
' set diameter of MouseDown line
Private Const DIAMETER As Integer = 8
7 1244
You haven't made it clear which one works, and which doesn't. Or what happens when it doesn't work.
You never point which event you are coding this and what is the value of x1,y1 and x2,y2!
Is it x1,y1 and x2,y2 are constant or following the mouse pointer?
graphicsObject.DrawLine(New Pen(Color.Black), _
e.X, e.Y, DIAMETER, DIAMETER)
This one works (and it is following the mouse) my eventual goal is going to be to calculate the distance between end points of this line.
First post what you did in your code and describe about your problem in detail. (Do not simply post 2 or 3 line of code.)
First post what you did in your code and describe about your problem in detail. (Do not simply post 2 or 3 line of code.)
Here is what I have so far, most of it was based off of an example. I am suppose to use the following, but when I do I can not draw the line: - graphicsObject.DrawLine(New Pen(Color.Black), x1, y1, x2, y2)
-
-
Public Class LineLengthForm
-
-
Dim x1 As Integer
-
Dim x2 As Integer
-
Dim y1 As Integer
-
Dim y2 As Integer
-
-
' specify whether moving the mouse should erase
-
Private shouldErase As Boolean = False
-
-
' specify whether moving the mouse should draw
-
Private shouldDraw As Boolean = False
-
-
' set diameter of MouseDown line
-
Private Const DIAMETER As Integer = 8
-
-
' create and initialize Graphics object
-
Private graphicsObject As Graphics = CreateGraphics()
-
-
' handles LineLength's MouseDown event
-
Private Sub LineLengthForm_MouseDown(ByVal sender As Object, _
-
ByVal e As System.Windows.Forms.MouseEventArgs) _
-
Handles Me.MouseDown
-
-
' draw on Form if the left button is held down
-
If e.Button = Windows.Forms.MouseButtons.Left Then
-
shouldDraw = True
-
' erase black lines if right button is held down
-
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
-
shouldErase = True
-
End If
-
End Sub ' MouseDown
-
-
' handles LineLengthForm's MouseMove event
-
Private Sub LineLengthForm_MouseMove(ByVal sender As Object, _
-
ByVal e As System.Windows.Forms.MouseEventArgs) _
-
Handles Me.MouseMove
-
-
' draw line if mouse button is pressed
-
If shouldDraw = True Then
-
graphicsObject.DrawLine(New Pen(Color.Black), _
-
e.X, e.Y, DIAMETER, DIAMETER)
-
' mouse pointer "erases" if right mouse button is pressed
-
ElseIf shouldErase = True Then
-
graphicsObject.DrawLine(New Pen(BackColor), _
-
e.X, e.Y, DIAMETER, DIAMETER)
-
End If
-
End Sub 'LineLength_MouseMove
-
-
' handle LineLength's MouseUp event
-
Private Sub LineLengthForm_MouseUp(ByVal sender As Object, _
-
ByVal e As System.Windows.Forms.MouseEventArgs) _
-
Handles Me.MouseUp
-
-
shouldDraw = False ' do not draw on the form
-
shouldErase = False ' do not erase
-
End Sub 'LineLength_MouseUp
- graphicsObject.DrawLine(New Pen(Color.Black), _
-
e.X, e.Y, DIAMETER, DIAMETER)
here you have to change like -
graphicsObject.DrawLine(New Pen(Color.Black), _
-
X1, Y1, e.X, e.Y)
and in mouse down event -
Private Sub LineLengthForm_MouseDown(ByVal sender As Object, _
-
ByVal e As System.Windows.Forms.MouseEventArgs) _
-
Handles Me.MouseDown
-
-
' draw on Form if the left button is held down
-
If e.Button = Windows.Forms.MouseButtons.Left Then
-
shouldDraw = True
-
' erase black lines if right button is held down
-
ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
-
shouldErase = True
-
End If
-
X1 = e.X
-
Y1 = e.Y
-
End Sub ' MouseDown
and in mouse up X1 and Y1 to 0
and same thing apply to errase logic.
Note : This code will draw line to start and end point of mouse pointer. so it will not be a single line (it will look like shaded line, you don't draw a Straight line).
Thanks for the insight!!!!!!!!!!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: G Kannan |
last post by:
Hey all!
I have written a perl script to retrieve information from a HTML Form
and insert the data into an Oracle database table. I am gettting the
the following error message:
"Use of...
|
by: jamait |
last post by:
Hi all,
I m trying to read in a text file into a datatable...
Not sure on how to split up the information though, regex or substrings...?
sample:
Col1 Col2 ...
|
by: name |
last post by:
Here is a first attempt at a line/word wrapping utility. Seems to work
okay, but lacks some checking stuff, etc.
---------------------------------------------------------
#include <stdio.h>...
|
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...
|
by: News |
last post by:
Hi Everyone,
The attached code creates client connections to websphere queue managers
and then processes an inquiry against them.
The program functions when it gets options from the command...
| |
by: Andrew Robert |
last post by:
Hi Everyone.
I tried the following to get input into optionparser from either a file
or command line.
The code below detects the passed file argument and prints the file
contents but the...
|
by: WStoreyII |
last post by:
the following code is supposed to read a whole line upto a new line
char from a file. however it does not work. it is producing weird
results. please help. I had error checking in there for...
|
by: programming |
last post by:
how do i delete from a text file 1 of the following lines:
jon|scott
adam|smith <--delete
paul|clark
say i would like to delete the middle line of this txt, in member.txt
what php code or...
|
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= |
last post by:
This is an example of the data;
2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511)
RX 74 bytes
2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13
48...
|
by: Vernon Wenberg III |
last post by:
I'm not really sure how readline() works. Is there a way to iterate
through a file with multiple lines and then putting each line in a
variable in a loop?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |