Radiobuttons and listbox problem

This is a discussion on Radiobuttons and listbox problem within the Windows Programming forums, part of the Platform Specific Boards category; On my program, I want it so that when the user clicks something in the listbox, the program will switch ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Radiobuttons and listbox problem

    On my program, I want it so that when the user clicks something in the listbox, the program will switch to another radiobutton. Here's the code i used, but for some reason, it does not work.

    Code:
    	case WM_COMMAND:
    
    		if ((HWND)lParam == GetDlgItem(hwnd,ID_LIST_CHAN) ){
    	      switch(HIWORD(wParam)) {
    			case EN_CHANGE:
    		    cha_len=SendMessage(GetDlgItem(hwnd,ID_LIST_CHAN),LB_GETCOUNT,0,0);
    			if(win_clicked==1)
    			{
    				if(all_channels==1){
    			       //for(i=0;i<cha_len;i++)
    				   //{
    					   //SelectChange=SendMessage(GetDlgItem(hwnd,ID_LIST_CHAN),LB_GETSEL,i,0);
    
    					   //if(SelectChange<=0)
    					   //{
    
    						   SendDlgItemMessage(hwnd, ID_ALL_CHAN, BM_SETCHECK, 0, 0);
                               SendDlgItemMessage(hwnd, ID_ALLMATCH_CHAN, BM_SETCHECK, 0, 0);
    		                   SendDlgItemMessage(hwnd, ID_CHAN, BM_SETCHECK, 1, 0);
    		                   EnableWindow(GetDlgItem(hwnd,ID_CHAN_COMBO),FALSE);
    						   all_channels=0;
    						   match_channels=0;
    					   //}
    
    
    				   //}
    
    				}

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>I want it so that when the user clicks something in the listbox<<

    So why are you checking for EN_CHANGE which is an edit control notification message? You'll find there's a pattern in the naming of window messages (see table on this page, but note that not all prefixes are listed) which should help you decide which ones are relevant to which controls.

    For listboxes the prefixes are LB_ and LBN_ (notification) so clearly what you need to use is the correct listbox notification message to detect when the selection has changed: in this particular situation LBN_SELCHANGE.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    215
    Thanks Ken, that really helped! :-)

Popular pages Recent additions subscribe to a feed

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