Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CBN_SELCHANGE triggered by MouseWheel, PgUp/PgDwn, Home, End
#1
Hi,

I have selections from a ComboBox filling a ListBox:


Code:
Copy      Help
,case CBN_SELCHANGE<<16|23
,,str SelectedCustomTag
,,if(CB_SelectedItem(id(23 hDlg) SelectedCustomTag) >= 0)
,,,LB_Add id(6 hDlg) SelectedCustomTag

The problem is that mousewheel Up and Down and PgUp andPgDown and Home and End also cause CBN_SelChange to be triggered.

The only thing I want triggered a selection from the ComboBox to the ListBox is:

a) Selecting a CB item by the pulldown list: (as above) OR

b) Hitting OK with what is typed in the CB field (or autocompleted with CB_AutoComplete). This works with

Code:
Copy      Help
sel wParam
,case IDOK
,,ifa(id(1001 hDlg));;if cursor is in CustomTag Pulldown
,,,str GetCustomTagField.getwintext(id(23 hDlg))
,,,LB_Add id(6 hDlg) GetCustomTagField
,,,ret
,,ret;;prevents the dialog being closed on Return/Enter

I tried changing some of the styles on the CB but no success in blocking those otherways of triggering CBN_SELCHANGE.

For reference for others who might be confused about the different CBN styles available in the dialog editor, I found this reference:


http://articles.techrepublic.com.com/510...76690.html

Quote:Doing it with style
By default, a ComboBox control's Style property is set to vbComboDropDown (value = 0). This is the default style because it results in a ComboBox that works the way programmers usually want it to work. The control displays as a single-line text box with a down arrow at the right side. The user can type directly into the control or, by clicking the arrow, can select from the predefined items that have been loaded into the control. This style saves screen real estate because the list of items is hidden until the user clicks the arrow.

Setting the Style property to vbComboSimple (value = 1) results in a control that looks like a text box above a list box. As with the default style, the user can type in the text box or select from the list. The advantage is that the list always makes the available choices visible to the user. The disadvantage is that the control takes up more room on the screen.

The third ComboBox style is vbComboDrop-DownList (value = 2). When you select this style, theComboBox displays the same way as with the default style (i.e., a single-line text box with a down arrow at the right side). The variation is in the behavior; the user cannot type data into the control--he or she must select from the list. In other words, a ComboBox with the Style property set to vbComboDrop-DownList looks like a ComboBox but acts like a ListBox.

Thanks, Stuart
#2
CBN_SELCHANGE
->
CBN_SELENDOK
#3
Thanks for quick response.
It doesn't seem to make any change in behavior.
I think what I will do is simply get rid of the

Code:
Copy      Help
,case CBN_SELENDOK<<16|23
,,str SelectedCustomTag
,,if(CB_SelectedItem(id(23 hDlg) SelectedCustomTag) >= 0)
,,,LB_Add id(6 hDlg) SelectedCustomTag

and simply have it fill in by hitting enter if the field is selected. Once I added an automatic deselect line so it doesn't stay "triggerable", it becomes very workable, especially with the CB-AutoComplete.

Code:
Copy      Help
,case IDOK
,,ifa(id(1001 hDlg));;if cursor is in CustomTag Pulldown
,,,str GetCustomTagField.getwintext(id(23 hDlg))
,,,LB_Add id(6 hDlg) GetCustomTagField
,,,CB_SelectItem(id(23 hDlg) -1)    
,,,ret

Thanks again for such quick responses!

Stuart


Forum Jump:


Users browsing this thread: 1 Guest(s)