Welcome to %s forums

BrainModular Users Forum

Login Register

Get control-alt-shift state

Create your own modules in C++
Post Reply
Gizzeta
Member
Posts: 42
Location: Paris
Contact:

Unread post by Gizzeta » 25 Aug 2009, 17:50

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

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 25 Aug 2009, 22:47

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.

Gizzeta
Member
Posts: 42
Location: Paris
Contact:

Unread post by Gizzeta » 25 Aug 2009, 23:03

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...

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 26 Aug 2009, 10:19

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
    }

Gizzeta
Member
Posts: 42
Location: Paris
Contact:

Unread post by Gizzeta » 26 Aug 2009, 16:40

Thanks!

martignasse
Site Admin
Posts: 611
Location: Lyon, FRANCE
Contact:

Unread post by martignasse » 26 Aug 2009, 16:54

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
Martin FLEURENT - Usine Developer - SDK maintainer

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 78 guests