LBN_SELCHANGE not working

This is a discussion on LBN_SELCHANGE not working within the Windows Programming forums, part of the Platform Specific Boards category; I have a listbox that I just made, and I enumerated it with some values just to test it out. ...

  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    13

    LBN_SELCHANGE not working

    I have a listbox that I just made, and I enumerated it with some values just to test it out. When the WM_COMMAND message occurs, I check if the listbox sent it, and then check if the LBN_SELCHANGE message has occured. Through testing, I have found that it does get whether the listbox sent the message, but it isn't detecting the LBN_SELCHANGE message has occured. Here is the portion of code that isn't working properly from within the WndProc.
    Code:
    case WM_CREATE:
    		{
    			HWND list = CreateWindowEx(0, "Listbox", "", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL,
    								0, 0, 50, 100, hwnd, (HMENU)EXTENSION_LIST,
    								GetModuleHandle(NULL), NULL);
    			SendMessage(list,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
    			for (int i=0;i<20;i++)
    			{
    				char buf[100];
    				itoa(i, buf, 10);
    				SendMessage(list,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)buf);
    			}
    		}
    		break;
    		
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case UPDATE_REGISTRY:
    					updateRegistry();
    				break;
    				case EXTENSION_LIST:
    					switch(HIWORD(wParam))
    					{
    						case LBN_SELCHANGE:
    							MessageBox(NULL, "A Selection Was Chosen", "Chosen", MB_OK | MB_ICONEXCLAMATION);
    						break;
    					}
    				break;
    			}
    		break;
    Any ideas why I'm not catching the LBN_SELCHANGE message??? Thanks in advance.

  2. #2
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    307
    1) According to MSDN, to process WM_COMMAND must return cero
    2) LBN_SELCHANGE, happens if This notification message applies only to a list box that has the LBS_NOTIFY style.
    3) Curly bracets are you friends:
    Code:
    case WM_COMMAND:
    {
    	switch(LOWORD(wParam))
    	{
    		case UPDATE_REGISTRY:
    		{
    			updateRegistry();
    			break;
    		}
    		case EXTENSION_LIST:
    		{
    			switch(HIWORD(wParam))
    			{
    				case LBN_SELCHANGE:
    				{
    					// Your code here
    					break;
    				}
    			}
    			break;
    		}	
    	}
    	return 0;
    }
    Last edited by Joelito; 06-29-2007 at 09:21 PM. Reason: Add more info
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  3. #3
    Registered User
    Join Date
    Jun 2007
    Posts
    13
    Thanks for the help, but I still get nothing even with everything braced and returning zero... Any other ideas?? Might it be in the creation of the list??

  4. #4
    Registered User Joelito's Avatar
    Join Date
    Mar 2005
    Location
    Tijuana, BC, México
    Posts
    307
    See my updated post
    * PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with xfce4.
    * Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with xfce4.

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    13
    Never mind, I missed the second line of your post. That fixed it. I can't believe I left that out. Thanks for your help!!!!!!

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    13
    Oh, that wasn't in the original post?? That might be why I missed it.. Thank you very much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 07:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 07:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21