Determining Mouse Possition

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Smoke

    Determining Mouse Possition

    What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just determine
    if the mouse is over my form.
    I need to do two differents things on that event, based on if the mouse is over the form or not..

    Any help?

    Thanks.


  • Ken Tucker [MVP]

    #2
    Re: Determining Mouse Possition

    Hi,

    Dim pt As Point = Cursor.Position

    will return the postion in screen coordinates.



    Ken

    ------------------

    "Smoke" <smoke@netgate. com.uy> wrote in message
    news:umE6vwazDH A.1740@TK2MSFTN GP09.phx.gbl...[color=blue]
    > What i want to do, is, in the Activate Event of my form, determine which
    > is the mouse possition, or, maybe even easy, just determine
    > if the mouse is over my form.
    > I need to do two differents things on that event, based on if the mouse is
    > over the form or not..
    >
    > Any help?
    >
    > Thanks.
    >
    >[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: Determining Mouse Possition

      Smoke,
      Have you looked at Control.MousePo sition, Control.MouseBu ttons &
      Control.Modifie rKeys all shared properties.

      Remember that Control.MousePo sition is in Screen Coordinates, so you need to
      use Control.PointTo Client to convert into client coordinates, then you can
      use Control.ClientR ectangle.Contai ns to see if the point is on the
      ClientArea.

      You can use Control.Bounds if you want to include the Non-client area of the
      form.

      Remember that Form inherits from Control, so the above properties are valid
      for Forms also.

      Hope this helps
      Jay

      "Smoke" <smoke@netgate. com.uy> wrote in message
      news:umE6vwazDH A.1740@TK2MSFTN GP09.phx.gbl...[color=blue]
      > What i want to do, is, in the Activate Event of my form, determine which[/color]
      is the mouse possition, or, maybe even easy, just determine[color=blue]
      > if the mouse is over my form.
      > I need to do two differents things on that event, based on if the mouse is[/color]
      over the form or not..[color=blue]
      >
      > Any help?
      >
      > Thanks.
      >
      >[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Determining Mouse Possition

        * "Smoke" <smoke@netgate. com.uy> scripsit:[color=blue]
        > What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just determine
        > if the mouse is over my form.[/color]

        \\\
        If Me.Bounds.Conta ins(Cursor.Posi tion) Then
        ...
        End If
        ///

        --
        Herfried K. Wagner [MVP]
        <http://www.mvps.org/dotnet>

        Comment

        • Smoke

          #5
          Re: Determining Mouse Possition

          Perfect, i got it working! :) thanks alot

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:Oc#vbBbzDH A.2408@tk2msftn gp13.phx.gbl...[color=blue]
          > * "Smoke" <smoke@netgate. com.uy> scripsit:[color=green]
          > > What i want to do, is, in the Activate Event of my form, determine which is the mouse possition, or, maybe even easy, just[/color][/color]
          determine[color=blue][color=green]
          > > if the mouse is over my form.[/color]
          >
          > \\\
          > If Me.Bounds.Conta ins(Cursor.Posi tion) Then
          > ...
          > End If
          > ///
          >
          > --
          > Herfried K. Wagner [MVP]
          > <http://www.mvps.org/dotnet>[/color]


          Comment

          • Smoke

            #6
            Re: Determining Mouse Possition

            Thanks, your explanation was very usefull

            "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message news:u0OSr3azDH A.2460@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Smoke,
            > Have you looked at Control.MousePo sition, Control.MouseBu ttons &
            > Control.Modifie rKeys all shared properties.
            >
            > Remember that Control.MousePo sition is in Screen Coordinates, so you need to
            > use Control.PointTo Client to convert into client coordinates, then you can
            > use Control.ClientR ectangle.Contai ns to see if the point is on the
            > ClientArea.
            >
            > You can use Control.Bounds if you want to include the Non-client area of the
            > form.
            >
            > Remember that Form inherits from Control, so the above properties are valid
            > for Forms also.
            >
            > Hope this helps
            > Jay
            >
            > "Smoke" <smoke@netgate. com.uy> wrote in message
            > news:umE6vwazDH A.1740@TK2MSFTN GP09.phx.gbl...[color=green]
            > > What i want to do, is, in the Activate Event of my form, determine which[/color]
            > is the mouse possition, or, maybe even easy, just determine[color=green]
            > > if the mouse is over my form.
            > > I need to do two differents things on that event, based on if the mouse is[/color]
            > over the form or not..[color=green]
            > >
            > > Any help?
            > >
            > > Thanks.
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...