Home All Groups Group Topic Archive Search About

Draw line on picture; change width

Author
30 May 2005 7:03 AM
Dennis
Hello, im using the following code the to draw a line on a picture. But i
want to change the width of the line (thicker), how can i do that??

############################################### '*************************************************************************************
' Writes the starting position to x1 and y1. Begins drawing method (line) '*************************************************************************************
Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
    'writes mouse coordinates to x2 and y2
    x1 = z.x
    y1 = z.y
    lbl1 = "X1: " & z.x * scalefactor
    lbl2 = "Y1: " & z.y * scalefactor
     If Button = vbLeftButton Then
    Picture2.DrawMode = 10
    xstart = x
    ystart = y
    xp = x
    yp = y
  End If

End Sub '*************************************************************************************
' Follows the mouse coordinates and draws a line '*************************************************************************************
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, x As
Single, y As Single)
  If Button = vbLeftButton Then
    Picture2.Line (xstart, ystart)-(xp, yp), vbBlue
    xp = x
    yp = y
    Picture2.Line (xstart, ystart)-(x, y), vbBlue
  End If
End Sub '*************************************************************************************
' Writes the end position to x2 and y2. Ends the drawing method (ends line)
' Adds scalefactor to program
' Adds description to every line and writes it to excel '*************************************************************************************
Private Sub Picture2_MouseUp(Button As Integer, Shift As Integer, x As
Single, y As Single)

   'writes mouse coordinates to x2 and y2
   x2 = z.x
   y2 = z.y

   Picture2.DrawMode = 13


End Sub
##############################################

Can someone help me with this?

Thx in advance

Dennis

Author
30 May 2005 7:24 AM
Larry Serflaten
"Dennis" <Den***@discussions.microsoft.com> wrote
> Hello, im using the following code the to draw a line on a picture. But i
> want to change the width of the line (thicker), how can i do that??

Change the DrawWidth property?

Show quoteHide quote
:FS
Author
30 May 2005 9:22 AM
Dennis
I tried that, but the width stays the same...

Show quoteHide quote
"Larry Serflaten" wrote:

>
> "Dennis" <Den***@discussions.microsoft.com> wrote
> > Hello, im using the following code the to draw a line on a picture. But i
> > want to change the width of the line (thicker), how can i do that??
>
> Change the DrawWidth property?
>
> :FS
>
Author
30 May 2005 10:32 AM
Larry Serflaten
"Dennis" <Den***@discussions.microsoft.com> wrote
> I tried that, but the width stays the same...

Try it again?  Are you sure to set it for Picture2?

LFS


Show quoteHide quote
> > > Hello, im using the following code the to draw a line on a picture. But i
> > > want to change the width of the line (thicker), how can i do that??
> >
> > Change the DrawWidth property?
Author
30 May 2005 1:17 PM
J French
On Mon, 30 May 2005 05:32:27 -0500, "Larry Serflaten"
<serfla***@usinternet.com> wrote:

>
>"Dennis" <Den***@discussions.microsoft.com> wrote
>> I tried that, but the width stays the same...
>
>Try it again?  Are you sure to set it for Picture2?

Also set your ScaleMode to vbPixels

Differences in TWIPs are invisible on even a sophisticated screen

TWIPs are the visual version of Unicode
Author
31 May 2005 7:12 AM
Dennis
Thx guys that helped.
But now i've got another problem, is it possible to draw with one stand line
colour. Because now the line depends on the background.

Thx in advance
Dennis

Show quoteHide quote
"J French" wrote:

> On Mon, 30 May 2005 05:32:27 -0500, "Larry Serflaten"
> <serfla***@usinternet.com> wrote:
>
> >
> >"Dennis" <Den***@discussions.microsoft.com> wrote
> >> I tried that, but the width stays the same...
> >
> >Try it again?  Are you sure to set it for Picture2?
>
> Also set your ScaleMode to vbPixels
>
> Differences in TWIPs are invisible on even a sophisticated screen
>
> TWIPs are the visual version of Unicode
>
Author
31 May 2005 8:39 AM
Mike D Sutton
> But now i've got another problem, is it possible to draw with one stand line
> colour. Because now the line depends on the background.

The Line()() function takes a colour parameter, have you read the help?..  You may also find the Basic introduction to graphics
programming in VB article on my site useful which goes through all this.
Hope this helps,

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Author
31 May 2005 9:16 AM
Dennis
I thought i declared a colour parameter: "Picture2.Line (xstart, ystart)-(xp,
yp), vbBlue"
Or do i have to do something else (Pset?)?

Thx
Dennis
Show quoteHide quote
"Mike D Sutton" wrote:

> > But now i've got another problem, is it possible to draw with one stand line
> > colour. Because now the line depends on the background.
>
> The Line()() function takes a colour parameter, have you read the help?..  You may also find the Basic introduction to graphics
> programming in VB article on my site useful which goes through all this.
> Hope this helps,
>
>     Mike
>
>
>  - Microsoft Visual Basic MVP -
> E-Mail: ED***@mvps.org
> WWW: Http://EDais.mvps.org/
>
>
>
Author
31 May 2005 11:48 AM
Mike D Sutton
>I thought i declared a colour parameter: "Picture2.Line (xstart,
>ystart)-(xp, yp), vbBlue"
> Or do i have to do something else (Pset?)?

Read either the help or the article, I think you're confusing yourself.

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/
Author
31 May 2005 12:13 PM
Larry Serflaten
"Dennis" <Den***@discussions.microsoft.com> wrote
> I thought i declared a colour parameter: "Picture2.Line (xstart, ystart)-(xp,
> yp), vbBlue"
> Or do i have to do something else (Pset?)?

Yes, you have to set the DrawMode properly.

LFS
Author
1 Jun 2005 9:31 AM
Dennis
Allright, i changed the Drawmode from the picture (and line) to VBCppyPen;
"13-Copy Pen" but i see no changes. I also tried the other drawmodes but i
still see no changes...

Dennis

Show quoteHide quote
"Larry Serflaten" wrote:

>
> "Dennis" <Den***@discussions.microsoft.com> wrote
> > I thought i declared a colour parameter: "Picture2.Line (xstart, ystart)-(xp,
> > yp), vbBlue"
> > Or do i have to do something else (Pset?)?
>
> Yes, you have to set the DrawMode properly.
>
> LFS
>
Author
1 Jun 2005 10:12 AM
Mike D Sutton
> Allright, i changed the Drawmode from the picture (and line) to VBCppyPen;
> "13-Copy Pen" but i see no changes. I also tried the other drawmodes but i
> still see no changes...

Start a new project, drop a picture box on the form paste this code in (don't touch anything else!) and run:

'***
Private Sub Picture1_Paint()
    Picture1.DrawWidth = 10
    Picture1.Line (0, 0)-(Picture1.ScaleWidth, Picture1.ScaleHeight), vbBlue
End Sub
'***

I still _strongly_ recommend you read up on the literature I've directed you to previously, these issues would be very
easily fixed with a basic understanding of how graphics development works..
Hope this helps,

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/