5 Replies - 934 Views - Last Post: 10 February 2012 - 12:29 PM Rate Topic: -----

#1 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 10:24 AM

Hello.
I am making a program in Visual Basic 2010 Express, and i was wondering if there was a way if the form (form1/me) can be maximized by dragging form1 to the top of the screen. So far I have this code:
If Cursor.Position.Y = Screen.PrimaryScreen.WorkingArea.Height Then
            Me.WindowState = FormWindowState.Maximized
        End If


Thanks in advance.
Is This A Good Question/Topic? 0
  • +

Replies To: VB.NET Cursor at Top of Screen

#2 Robin19  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 272
  • View blog
  • Posts: 552
  • Joined: 07-July 10

Re: VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 10:34 AM

The top left of the screen is Point(0,0). The Cursor.Position.Y will not equal WorkingArea.Height until you reach near the bottom of the screen. Change it to the following (I have not tried this code out).
If Cursor.Position.Y = 0 Then
   Me.WindowState = FormWindowState.Maximized
End If

Was This Post Helpful? 0
  • +
  • -

#3 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 10:39 AM

No, that didn't work. Thanks for trying.
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1606
  • View blog
  • Posts: 5,163
  • Joined: 25-September 09

Re: VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 11:34 AM

What about .Top instead of .Height in your original?

Nevermind, I mis-read your code

Try
   Private Sub Form1_Move(sender As Object, e As System.EventArgs) Handles Me.Move
        If Me.Top = Screen.PrimaryScreen.Bounds.Top Then
            Me.WindowState = FormWindowState.Maximized
        End If
    End Sub

I can't test it as Windows 7 has this feature built in.

Actually, I just tested it by displaying a message when my form reached the top and it worked.

This post has been edited by CharlieMay: 10 February 2012 - 11:38 AM

Was This Post Helpful? 0
  • +
  • -

#5 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 11:37 AM

No. That didn't work either.
Was This Post Helpful? 0
  • +
  • -

#6 curlyfries1999  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 111
  • Joined: 22-December 11

Re: VB.NET Cursor at Top of Screen

Posted 10 February 2012 - 12:29 PM

For some reason that compressed everything into one corner. In my program the Windows 7 feature doesn't work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1