Multiple mouse/mice/cursor?

2019-02-26 11:59发布

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条回答
淡お忘
2楼-- · 2019-02-26 12:33

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.

查看更多
Bombasti
3楼-- · 2019-02-26 12:35

It can be simulated its action virtually from the original cursor by doing something seamingly fast

查看更多
一夜七次
4楼-- · 2019-02-26 12:37

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.

查看更多
登录 后发表回答