I'd like to align an object in X and Y by eye using the mouse to move it into position. I can roll a solution by using various spin controls (or buttons) but it's messy and I got to wondering whether there is a control - like a joystick - that provides 2-axis control using the mouse and fires events at rates which vary depending on its position?
A:
I Googled for "joystick dll" and found countless. You can probably throw one of these into your project and then access its C API from Delphi by simply writing a TLIB header (or whatever it's called, haven't done this in a while) for it.
Carl Smotricz
2010-01-06 09:58:29
TLB is for COM, not plain procedural winapi.
Marco van de Voort
2010-01-06 12:57:49
Right you are, I'm sure. I remember there are Pascal header files that one uses to declare procedures in C code, but I've forgotten the correct name for them.
Carl Smotricz
2010-01-06 13:28:33
A:
You may use a DelphiX components. They are wrappers for DirectX and one of them wraps around DirectX joystick interface as far as I remember. It wraps in a Delphi-style so it is easy to use.
Wodzu
2010-01-06 10:25:02
+2
A:
Afaik Jedi (jedi apilib?) had a joystick header too. It is winapi, not COM, so no TLB involved
Marco van de Voort
2010-01-06 12:56:55
+1
A:
Maybe you can make something like that yourself.
- Take a panel, and register on Mouse up, down and move events
- On MouseDown, set a boolean (fButtonDown) so you know that the mousebutton is pressed and save the X and Y coordinates of the mousepointer.
- On MouseMove, check if a button is down (fButtonDown) and move your object. The more your mousecursor is moved from its saved position, the faster you move.
- On MouseUp, set fButtonDown to false
The above is very primitive, but should work.
The_Fox
2010-01-06 15:18:26