Again - ListBox selection via Shift key not working. 
Author Message
 Again - ListBox selection via Shift key not working.

Once again - I cannot get the ListBox to correctly state that the list box
items are selected if you use the Extended style and use the Shift key to
select a range of items.  The items graphically appear selected (hilited in
blue), but when I use GetSel() and GetSelItems() it returns only 1 item
selected.  Is this a bug or what?
Here is the code - quite simple and straight forward.

void CDDListBox::OnLButtonDown(UINT nFlags, CPoint point)
{    
    int nItem;  
    int numChar;

    // Let Base class do default message processing    
    CListBox::OnLButtonDown(nFlags, point);

        nItem = GetCount();
        TRACE( "\n\nOnLButtonDown() - num items = %d\n", nItem );
        for ( int i =0; i < nItem; ++i ) {
                // Check selection state - if > 0 then it is selected.
                if ( GetSel( i ) > 0 ) {
                        CString Data;
                        GetText( i, Data );
                        TRACE( "Line %d = %s is SELECTED\n", i, Data );
                }
        }

        int selitems[ 100 ];
        int numselitems = GetSelItems( 100, selitems );
        TRACE( "\n\nNumber of Selected items is %d\n", numselitems );

        return;

Quote:
}

Please help.

Tony Palmer



Sat, 21 Aug 1999 03:00:00 GMT  
 Again - ListBox selection via Shift key not working.

if you have this as a DDX_Control you have to call UpdateData() before
the local control reflects what is on the screen.

Darrell

Quote:

> Once again - I cannot get the ListBox to correctly state that the list box
> items are selected if you use the Extended style and use the Shift key to
> select a range of items.  The items graphically appear selected (hilited in
> blue), but when I use GetSel() and GetSelItems() it returns only 1 item
> selected.  Is this a bug or what?
> Here is the code - quite simple and straight forward.

> void CDDListBox::OnLButtonDown(UINT nFlags, CPoint point)
> {
>     int nItem;
>     int numChar;

>     // Let Base class do default message processing
>     CListBox::OnLButtonDown(nFlags, point);

>         nItem = GetCount();
>         TRACE( "\n\nOnLButtonDown() - num items = %d\n", nItem );
>         for ( int i =0; i < nItem; ++i ) {
>                 // Check selection state - if > 0 then it is selected.
>                 if ( GetSel( i ) > 0 ) {
>                         CString Data;
>                         GetText( i, Data );
>                         TRACE( "Line %d = %s is SELECTED\n", i, Data );
>                 }
>         }

>         int selitems[ 100 ];
>         int numselitems = GetSelItems( 100, selitems );
>         TRACE( "\n\nNumber of Selected items is %d\n", numselitems );

>         return;
> }

> Please help.

> Tony Palmer



Sun, 22 Aug 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Left Shift Key OR Right Shift key is pressed

2. CListBox Extended selection not working correctly for Shift key.

3. Listbox: Sometimes allowing multiple selection and sometimes not ?

4. Q: Changing Focus via TAB key not possible in Dialog situated in DLL

5. CEditView Font Selection Not Working in Win2000

6. Copy/Paste via keyboard not working in FormView

7. Double clicking in OwnerDrawn Listboxes not working

8. Tab key to tab between controls does not work properly

9. F1-Help key does not work any more

10. Accelerator keys not working

11. The Tab Key Do Not Works In MFC Generated Active-X Control Please Help

12. :-)Why Does Accelerator Keys Do Not Work in Dialog Based Applications

 

 
Powered by phpBB® Forum Software