By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

RubberBanding Drawing in VB.NET on Win8/10

DTeCH
P: 23
Hey dudes :)

Ok, First thing first... I have not tried this on Win8, so just an assumption at the moment.

The Following code works on XP(SP3), Vista, & Win7 so far, but after giving my app to a friend who was suckered into Win10 because of the "Free" deal, says it's no longer working. The Applicatiuon runs, but doesnt work, & throws No Errors whatsoever.

RubberBanding Code:
Expand|Select|Wrap|Line Numbers
  1.     Private _RubberBandingOn As Boolean = False
  2.     Private _Start As New Point
  3.     Private _Stop As New Point
  4.     Private _Now As New Point
  5.     Private _rRectangle As New Rectangle
  6.  
  7.     Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  8.         PictureBox2.Visible = False
  9.  
  10.         Me._RubberBandingOn = Not _RubberBandingOn
  11.  
  12.         If Me._RubberBandingOn Then
  13.  
  14.             If _Start = Nothing Then _Start = New Point
  15.  
  16.             _Start.X = e.X
  17.             _Start.Y = e.Y
  18.             _Now.X = e.X
  19.             _Now.Y = e.Y
  20.  
  21.         End If
  22.  
  23.         Me.Invalidate()
  24.     End Sub
  25.  
  26.     Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
  27.         If Me._RubberBandingOn Then
  28.             If _Now = Nothing Then _Now = New Point
  29.  
  30.             Me._Now.X = e.X
  31.             Me._Now.Y = e.Y
  32.             Me.Invalidate()
  33.         End If
  34.         Me.Cursor = Cursors.Cross
  35.         Me.ToolTip1.SetToolTip(Me, e.X.ToString & ", " & e.Y.ToString)
  36.     End Sub
  37.  
  38.     Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
  39.  
  40.         Me._RubberBandingOn = Not Me._RubberBandingOn
  41.  
  42.         If Not Me._RubberBandingOn Then
  43.  
  44.             If _Stop = Nothing Then _Stop = New Point
  45.  
  46.             _Stop.X = e.X
  47.             _Stop.Y = e.Y
  48.  
  49.             Me.Invalidate()
  50.  
  51.             If _rRectangle.Width > 20 AndAlso _rRectangle.Height > 20 Then
  52.  
  53.                 PictureBox2.Location = _rRectangle.Location
  54.                 PictureBox2.Size = _rRectangle.Size
  55.                 PictureBox2.Visible = True
  56.  
  57.             Else
  58.                 GC.Collect()
  59.             End If
  60.         End If
  61.     End Sub
Can someone here shed some light on what could be wrong, or about any removals, or deprecation of code from Microsoft, or GDI+/GDI changes, or whatever that could have caused this? Maybe Win8/10 has a brand new way of drawing that I'm not aware of?

Any help is awesome as usual.
Thanks.

DTeCH
Oct 23 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.