No announcement yet.

Mouse Operations

  • Filter
  • Time
  • Show
Clear All
new posts

  • Mouse Operations

    I would like to restrict the mouse to the inside area of a form
    in one of my programs, and was wondering if anyone has done
    something like this, or can give me some direction.
    I am writing this program using PB/dll60 and EZGUI 1.01.


    [email protected]


  • #2
    Use the SetCapture API call.
    $NAG = "ON"
    Personally, I'd consider this bad behavior. I have seen programs that do this crash and the cursor remain trapped - this makes it very difficult for the user to operate and generates tech support calls.
    $NAG = "OFF"

    Best Regards,

    Don Dickinson


    • #3
      Thanks Don, for the help and the warning. I will keep your
      warning in mind.

      [email protected]



      • #4

        Set capture does not restrict the mouse. It only forces the window
        to get all the mouse messages. If the mouse goes outside the window
        it can have a negative coordinate (if to the left or above the window).

        SetCapture is not an unsave method, since it is required for all
        apps that draw on a window (ie. Windows paint). SetCapture is used when
        the mouse button goes down and it turned off when the mouse button
        comes up. That is the proper way to use it. I think Dons comments about
        SetCapture would apply to using it outside of the mouse button down
        event as is done in drawing programs. SetCapture is normally used with mouse
        button events. As an example the ComboBoxes drop down list uses SetCapture,
        Popup Menus use SetCapture as well.

        There is another API function that restricts the mouse as you want
        but I don't remember it off hand.

        Chris Boss
        Computer Workshop
        Developer of "EZGUI"


        • #5
          I thank both of you gentlemen for your help.

          Did a little snooping around on the internet and came up with
          this great site

          It appears that the "ClipCursor" Function is what I need,
          as it "confines the mouse cursor to a rectangular area of
          the screen." (Got this info from this site.)

          I could also use the "mouse_event" Function to get the cursor
          position, and could confine the cursor using the "SetCursorPos"

          Now I just have to figure out how to use them (VB vs PB syntax,

          BTW, Paul Kuliniewicz, the originator of this site has made
          it known that he can no longer maintain this site.
          It looks like a great reference site for an amateur like me,
          but maybe there is a "GURU" out there that might be able
          to pick up the baton.


          [email protected]