Breaking up a LPARAM variable & looking at groups of bits

前端 未结 4 1956
死守一世寂寞
死守一世寂寞 2021-01-16 23:52

I know that a LPARAM variable has certain bits set(inside it) that identify information such as long key presses & etc. when I receive a WM_KEYDOWN event.

So I a

4条回答
  •  遥遥无期
    2021-01-17 00:38

    A much easier way is to declare your own structure.

    // information about key
    union KeyInfo
    {
      // LPARAM
      LPARAM lParam;
    
      // bit-field
      struct Bits {
        WORD nRepeatCount: 16;
        BYTE nScanCode : 8;
        BYTE nExtended : 1;
        BYTE nReserved : 4;
        BYTE nContext : 1;
        BYTE nPrevious : 1;
        BYTE nTransition : 1;
      };
    };
    

    That said, it's still a good idea to learn bit-arithmetic & as someone in the thread said there is a wealth of resources for this on the internet that can be found via Google.

    EDIT: See this link which basically shows how to do what I just did.

提交回复
热议问题