Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

How do I stop events from bubbling up?

I have this window procedure running:

static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

   switch (msg) {

      case WM_KEYDOWN:
      case WM_SYSKEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
         processKeyMessage( msg, wParam, lParam );
         break;
   }
   return DefWindowProc(hWnd, msg, wParam, lParam);
}

How do I stop the keyboard messages from bubbling up to the parent application once they're processed?  I tried return true; but they still get sent.
0
GENTP
Asked:
GENTP
1 Solution
 
jkrCommented:
That should be

static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

   switch (msg) {

      case WM_KEYDOWN:
      case WM_SYSKEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
         processKeyMessage( msg, wParam, lParam );
         return 0; // <----------------!
         break;
   }
   return DefWindowProc(hWnd, msg, wParam, lParam);
}

From the docs on these keyboard messages:

"An application should return zero if it processes this message"
0
 
GENTPAuthor Commented:
d'oh.  Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now