views:

301

answers:

2

How can I show another cursor for multiple mice? I have two TMemos, two keyboards which can type into their respective TMemo, 2 mice and I need 2 cursors those.

If hypothetically, I can already detect which mouse is which. How can I make my own cursor to go along with it. (using Delphi) Possibly along the lines of Multipoint

as an alternative, is there any software which can render more that one cursor. Like CPNMouse?

EDIT: I found that I can use the mouse_event Function in windows, but I still don't have the visual representation of the cursor.

+3  A: 

Cursors are just resources. Here is a good list of the standard cursors that can be used. TControl Defines a cursor property that can be set to the cursor that should be used when over a given control. You can also use Screen.Cursor to control the entire application cursor.

To define a custom cursor you use the following code.

{$R MyCustomCursors.RES}

const
 crCustom1 = 1;
 crCustom2 = 2; 

...

  Screen.Cursors[crCustom1] := LoadCursor(hInstance, 'CUSTOM1');
  Screen.Cursors[crCustom2] := LoadCursor(hInstance, 'CUSTOM2');

...

Delphi was not designed by default to deal with multiple mouse pointers, but the I suspect most environments are not. The SDK you mention is the only source of information I have seen on using multiple mice at the same time in a single application. It however is .NET only, so using it would require Delphi Prism.

If you want to roll your own support for multiple mice the same trick of using WM_INPUT can can be used. Windows will treat both mice as the same. You will have to do custom painting of the mouse cursor by hand for the second mouse.

Robert Love
Thanks for answering. I didn't know you can define a custom cursor using Screen. I'll have to look into that.I guess I can try and use the WM_INPUT and experiment with other stuff.
Dian
Follow up question, what you you recommend that I use for 'showing' the 2nd mouse cursor? Perhaps something I can control with coordinates.
Dian
A: 

Windows doesn't support multiple mouse or keyboards. Since each process have only 1 input queue, Windows treats all similar input devices as the same single device. This can't be changed. End of story. Period.

But even if you can't do this on system wide scale - you still can do this in one particular application. You need to write a special driver and install it for the second mouse only. This driver should not pass mouse movements to usual consumer (input queue), but rather redirect input directly to your application.

You can use a already written drivers - for example, this one or the one, that you've already mentioned.

Alexander