Hi, I'm currently trying to learn programming in WinApi C++. Let's say I have a ListBox whose ID is "IDCL_LISTBOX" and I clicked a selection on it. A notification goes to my Message Procedure and I filter it through WM_Command. I look at what the LOWORD and the HIWORD of the wParam are, and based on that I do some operation. Problem is that the window procedure recognizes the LOWORD (window ID) but not the HIWORD (window notification):

For example:

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
  {
  case WM_CREATE:
  // OnCreate sets up the buttons, listboxes, etc.  
  return OnCreate(hwnd,reinterpret_cast<CREATESTRUCT*>(lParam));

  case WM_COMMAND:
        if (LOWORD(wParam) == IDBC_DEFPUSHBUTTON)
        {
          if (HIWORD(wParam) == LBN_SELCHANGE)
          {
            DoOperation();
          }
        }
  case WM_DESTROY:
    PostQuitMessage(0);    //signal end of application
    return 0;
  default:
    //let system deal with msg
    return DefWindowProc(hwnd,uMsg,wParam,lParam);
  }
}

That doesn't do anything. while in the next example:

LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
  {
  case WM_CREATE:
  // OnCreate sets up the buttons, listboxes, etc.  
  return OnCreate(hwnd,reinterpret_cast<CREATESTRUCT*>(lParam));

  case WM_COMMAND:
        if (LOWORD(wParam) == IDBC_DEFPUSHBUTTON)
        {
          DoOperation();
        }
  case WM_DESTROY:
    PostQuitMessage(0);    //signal end of application
    return 0;
  default:
    //let system deal with msg
    return DefWindowProc(hwnd,uMsg,wParam,lParam);
  }
}

Does the function DoOperation().

Can anybody help me out on this one? I've been learning from any tutorial I find on the web and when that isn't enough I resort to trial and error. Thanks a lot in advance.

Found out what I needed to do to catch the LBN_SELCHANGE message. You need to add the LBS_NOTIFY style to the listbox you're working with. I thought this setting was set by default but apparently not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.