Thread: Message not picked up: ComboBox

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    Message not picked up: ComboBox

    I can't see why control never gets to the lines indicated:

    Code:
    LRESULT CALLBACK CannedFixDlgBox(HWND hDlg, UINT message, WORD wParam, DWORD lParam)
    {
    	static HWND cfe_fix;
    	int    li_result, i;
    	DWORD  dw_index;
    	CANFIXNODE *fixnode;
    
    	switch (message)
    	{
    		/* Use messages to update, etc */
    		case WM_INITDIALOG:
    			CentraliseWindow(hDlg);
    			cfe_fix = GetDlgItem(hDlg, CFE_FIX);			...
    			... code to set up the list, which I know works OK
    			...
    			break;
    		case WM_COMMAND:
    		{
    			switch (LOWORD(wParam))
    			{
    				case CFE_FIX:
    				{
    					switch (HIWORD(wParam))
    					{
    						// Never seems to get here - why?
    						case CBN_SELENDOK:
    						case CBN_SELCHANGE:
    						case CBN_CLOSEUP:
    						case CBN_SELENDCANCEL:
    						...
    						break;
    					}
    					return 0;
    					break;
    				}
    				case ...:
    				...
    				...
    				default:
    					break;
    			}
    			return TRUE;
    		}
    		default:
    			break;
    	}
    	return FALSE;
    }
    The dropdown populates perfectly OK, and I can get it to dropdown and make a selection.

    I'm under the impression from the documentation that the message CBN_SELENDOK will be picked up when a selection is made, but HIWORD(wParam) is consistetly coming through with zero, thus those CBN_ messages are never processed.

    Any ideas as to why? I've searched and found a number of examples, all of which appear to do much the same as me, but there has to be something wrong somewhere.....

    Any ideas? TIA.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Well your code to check for the messages appears correct. I think the problem is in your procedure declaration.

    Code:
    LRESULT CALLBACK CannedFixDlgBox(HWND hDlg, UINT message, WORD wParam, DWORD lParam)
    Here you have wParam declared as a WORD instead of a DWORD. The wParam parameter should be an unsigned int (Im not sure how it even compiled for you). Change the code to the following:

    Code:
    LRESULT CALLBACK CannedFixDlgBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    Hey bithub, you're a star!!

    I was concentrating too closely on the actual code, not the declaration line. Changing it as you suggested has resolved the fault.

    Goes to show that a fresh pair of eyes on something often works wonders.

    Thanks!

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    good to hear

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. Global Variables
    By Taka in forum C Programming
    Replies: 34
    Last Post: 11-02-2007, 03:25 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM