vbXorPen DrawMode for drawing lines


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: vbXorPen DrawMode for drawing lines

  1. #1
    Arthur J. Smith Guest

    vbXorPen DrawMode for drawing lines


    In VB6 and previous versions of VB and Basic, you could draw lines with the
    DrawMode set to vbXorPen (and various other settings). I cannot find this
    functionality in the GDI+ graphics.

    I would like to be able to draw a line in the reverse color to the pixel
    underneath and then be able to remove the line without re-painting the entire
    Graphics object. The Pen object does not support this feature as far as
    I can tell.

    Is there some way to set up a delegate to have the pen callback to my code
    before it determines the color of the pixel? That approach might work but
    I cannot see how to do that in VB .NET.

  2. #2
    Larry Serflaten Guest

    Re: vbXorPen DrawMode for drawing lines

    You have two (count them) options for using XOR to draw;

    1. ControlPaint.DrawReversableLine
    2. ControlPaint.DrawReversableFrame

    For an example of the common rubberband frame, checkout:
    http://support.microsoft.com/default...;en-us;Q317479

    LFS


    "Arthur J. Smith" <prof.aj@sympatico.ca> wrote
    >
    > In VB6 and previous versions of VB and Basic, you could draw lines with the
    > DrawMode set to vbXorPen (and various other settings). I cannot find this
    > functionality in the GDI+ graphics.
    >
    > I would like to be able to draw a line in the reverse color to the pixel
    > underneath and then be able to remove the line without re-painting the entire
    > Graphics object. The Pen object does not support this feature as far as
    > I can tell.
    >
    > Is there some way to set up a delegate to have the pen callback to my code
    > before it determines the color of the pixel? That approach might work but
    > I cannot see how to do that in VB .NET.




  3. #3
    Arthur J. Smith Guest

    Re: vbXorPen DrawMode for drawing lines


    Thanks, that works great on the form. To make my cursor class work I have
    created a special type of form that draws the cursor.

    Public MustInherit Class CursorForm
    Inherits System.Windows.Forms.Form
    Dim xCursor As CrossHairs
    Public Sub DrawReversibleLine(ByVal x1 As Single, ByVal y1 As Single,
    ByVal x2 As Single, ByVal y2 As Single, ByVal Color As Color)
    ControlPaint.DrawReversibleLine(PointToScreen(New Point(x1, y1)),
    PointToScreen(New Point(x2, y2)), Color)
    End Sub
    Public Sub New()
    xCursor = New CrossHairs(Me)
    End Sub
    Private Sub CursorForm_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    Handles MyBase.MouseMove
    xCursor.Move(e.X, e.Y)
    End Sub
    Private Sub CursorForm_MouseEnter(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles MyBase.MouseEnter
    xCursor.Paint()
    End Sub
    Private Sub CursorForm_MouseLeave(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles MyBase.MouseLeave
    xCursor.UnPaint()
    End Sub
    End Class

    and have used this new CursorForm class's method DrawReversibleLine. Seems
    to work better than the old VB6 version because of the MouseEnter and MouseLeave.
    Only thing missing is the Width control of the line. I don't like the intense
    coupling of the two classes but I think I can work on that.

    Thanks again for your help.

    "Larry Serflaten" <serflaten@usinternet.com> wrote:
    >You have two (count them) options for using XOR to draw;
    >
    >1. ControlPaint.DrawReversableLine
    >2. ControlPaint.DrawReversableFrame
    >
    >For an example of the common rubberband frame, checkout:
    >http://support.microsoft.com/default...;en-us;Q317479
    >
    >LFS
    >
    >
    >"Arthur J. Smith" <prof.aj@sympatico.ca> wrote
    >>
    >> In VB6 and previous versions of VB and Basic, you could draw lines with

    the
    >> DrawMode set to vbXorPen (and various other settings). I cannot find

    this
    >> functionality in the GDI+ graphics.
    >>
    >> I would like to be able to draw a line in the reverse color to the pixel
    >> underneath and then be able to remove the line without re-painting the

    entire
    >> Graphics object. The Pen object does not support this feature as far

    as
    >> I can tell.
    >>
    >> Is there some way to set up a delegate to have the pen callback to my

    code
    >> before it determines the color of the pixel? That approach might work

    but
    >> I cannot see how to do that in VB .NET.

    >
    >



  4. #4
    Larry Serflaten Guest

    Re: vbXorPen DrawMode for drawing lines

    "Arthur J. Smith" <prof.aj@sympatico.ca> wrote
    >
    > Thanks, that works great on the form. To make my cursor class work I have
    > created a special type of form that draws the cursor.
    >
    > Public MustInherit Class CursorForm
    > Inherits System.Windows.Forms.Form

    ....
    > Public Sub New()
    > xCursor = New CrossHairs(Me)
    > End Sub


    Isn't there supposed to be a MyBase.New as the first call in the form's constructor?

    LFS






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center