Page 1 of 1

Posted: 25 Aug 2009, 17:50
by Gizzeta
Hi,

Is there a way to always get the control, alt and shift state in a module, not only when the mouse is on the module panel?

thanks

Posted: 25 Aug 2009, 22:47
by senso
yes when the procedure MouseMove (void* pModule, TShiftState Shift, int X, int Y) is called Usine fill the ShiftState in the 'Shift' parameter.

But there is an error in the Userdefinitions.h file

Code: Select all

//----------------------------------------------------------------------------
// keys state modifiers
// used in MouseMove, MouseUp and MouseDown functions declaration (see end of file)
 typedef enum TShiftState { 
	  ssShift, 
	  ssAlt, 
	  ssCtrl, 
	  ssLeft, 
	  ssRight, 
	  ssMiddle, 
	  ssDouble 
  };
must be replaced by

Code: Select all

//----------------------------------------------------------------------------
// keys state modifiers
// used in MouseMove, MouseUp and MouseDown functions declaration (see end of file)
typedef DWORD TShiftState ;

static DWORD const ssShift = 0x1
static DWORD const ssAlt = 0x2
static DWORD const ssCtrl = 0x4
static DWORD const ssLeft = 0x8
static DWORD const ssRight = 0x10
static DWORD const ssMiddle = 0x20
static DWORD const ssDouble = 0x40
so you can check if 'Shift' contains one or several values above.

Code: Select all

if ((Shift & ssCtrl) !=0) {..} //means that the Ctrl key is pressed
This error will be 'officially' corrected in the next SDK release.

Posted: 25 Aug 2009, 23:03
by Gizzeta
yes, i found the error, but in this way I get the shift state only if I move the mouse (on the window?).
I would like to get the shift state even if I don't move the mouse...

Posted: 26 Aug 2009, 10:19
by senso
for that you have to query directly the keyboard state like:

Code: Select all

  BYTE state[256];

    #define KEY_PRESSED(key) (state[key] & 0x80)

    GetKeyboardState(state);
    if (KEY_PRESSED(VK_CONTROL) && KEY_PRESSED('C')) {
        // CTRL-C pressed
    }

Posted: 26 Aug 2009, 16:40
by Gizzeta
Thanks!

Posted: 26 Aug 2009, 16:54
by martignasse
senso wrote:for that you have to query directly the keyboard state like:

Code: Select all

  BYTE state[256];

    #define KEY_PRESSED(key) (state[key] & 0x80)

    GetKeyboardState(state);
    if (KEY_PRESSED(VK_CONTROL) && KEY_PRESSED('C')) {
        // CTRL-C pressed
    }
useful infos, have to put this on the wiki


thanks senso