我在收到WM_KEYDOWN事件時正在檢查LPARAM的值。但我不確定是否正確檢查了第一個16位然後是接下來的8位&等。這是MSDN如何解釋一個LPARAM是一個WM_KEYDOWN味精組織:http://msdn.microsoft.com/en-us/library/ms646280(v=vs.85).aspx此LPARAM現在是否正確分隔?
是我的位(分割?)正確?:
void outputLParam(LPARAM lParam)
{
printf("Repeat Count : %d\n", (lParam) & ((1L<<16)-1)); // print the value of the 1st 16 bits
printf("Scan Code : %d\n", (lParam >> 0x16) & ((1L<<8)-1)); // print the value of the next 8 bits
printf("Extended Key : %d\n", lParam & 0x24); // print the value of the next bit
printf("Reserved : %d\n", (lParam >> 0x25) & ((1L<<4)-1)); // print the value of the next 4 bits
printf("Context : %d\n", lParam & 0x29); // print the value of the next bit
printf("Prev Key State : %d\n", lParam & 0x30); // print the value of the next bit
printf("Transition Key State: %d\n", lParam & 0x31); // print the value of the next bit
}
這真的應該是你的[上一個問題]的後續/延續(http://stackoverflow.com/questions/6993957/inspecting-the-lparam-on-wm-keydown-incorrect-values)。 – Deanna