Mouse movement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcco
    New Member
    • Jul 2008
    • 12

    Mouse movement

    Is there any way I can force the windows cursor to stay in one a negative location (so programs like games won't show it), and intercept mouse movements by myself?
    My program doesn't always have a form shown so it should be working in any situation.

    Thanks to anyone who helps.
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    You can just hide the cursor. It doesn't have to be visible.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      I tend to caution against such tight binding of one form to another.
      Beyond subscribing to an event, the two should know nothing of each other.

      Originally posted by OriginalPoster
      How do I get my Form2 to react to something on my Form1?
      How do I make my Form1 control something on my Form2?
      Although you can have Form1 directly access items on Form2 it isn't the recommended way to go. It ties the two forms tightly to each other. If a change is made in Form2 such as removing one of the controls, then code in Form1 breaks.
      It is better to Form1 raise an event, and have Form2 contain its own code for how to react to this. This places responsibility for Form2 within Form2, and Form1 within Form1.
      It keeps Form1 blissfully ignorant of Form2 - and a logging component - and a progress component, and a dozen other little black boxes that can be subscribed to events in Form1, all without Form1 being made responsible for directly affecting controls other than itself.
      Events tutorial (including Form to Form which is the same as class to class)
      This tutorial for a cash register does exactly that: It makes a virtual numeric keyboard.

      Comment

      • mcco
        New Member
        • Jul 2008
        • 12

        #4
        You can just hide the cursor. It doesn't have to be visible.

        http://msdn.microsoft.com/en-us/libr...de.aspx?ppud=4
        That won't help if there is a directx/other fullscreen application in focus - this is why i want to get the cursor somewhere out of the screen, also, I said in my first post that my form isn't always shown which prevents me from using Cursor.hide - as I need to hide it for all the system not only my program.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          Is there any way I can force the windows cursor to stay in one a negative location (so programs like games won't show it), and intercept mouse movements by myself?
          My program doesn't always have a form shown so it should be working in any situation.
          Sorry - didn't realize that you were trying to do this for a program other than your own. Saying that your *form* isn't always shown doesn't indicate that your *program* isn't the one we are working on. There are lots of times when forms are created but not shown.

          I think you are rather out of luck in this case. You want to take total control of the cursor in your application because of some other application. What if that other application wants the cursor? I mean your application can move the cursor out of range - but then what? The other application decides to move it to where *it* needs it, for example.

          Comment

          • mcco
            New Member
            • Jul 2008
            • 12

            #6
            is it possible to take full control of the mouse at all? say for example with a driver or something?

            Comment

            Working...