BUG: COMBOBOX with style CBS_DROPDOWN

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Mon Apr 15, 2013 10:10 am

When the Method Initiate() is invoked, the control already exists and ::hWnd should be valid too :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » Mon Apr 15, 2013 3:53 pm

Antonio, i had sent to your private email the Combobox.prg with all my changes. Additional please note this points:
1.) SetFocusColor() is not activ
2.) Picture-clausula should also represented on the Combobox, not only while editing.
Last edited by byte-one on Mon Apr 15, 2013 9:20 pm, edited 1 time in total.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Rick Lipkin » Mon Apr 15, 2013 4:25 pm

Antonio

I have been watching this thread with interest .. One behavior that I have not seen discussed with CBS_DROPDOWN is the incremental search.

I like the fact that you can enter any text into the CBS_DROPDOWN and and the field accepts that text .. however ( as in my screenshot ) the incremental search does not activate like CBS_DROPDOWNLIST. ( fwh1203 )

Image

I was hoping while you were looking at the Combobox code you might have a look at making the CBS_DROPDOWN behavior match the CBS_DROPDOWNLIST when you begin typing activating the incremental search.... I did not see that addressed in this thread and that feature may have been fixed since FWH1203 ?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 16, 2013 3:59 pm

Rick,

If we take FWH/samples/combos.prg as a reference, there are three combos. Which combo behavior is the right for you ? thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Rick Lipkin » Tue Apr 16, 2013 4:48 pm

Antonio

Combobox 2 ( cbs_dropdown ) does not search the array when you type in a value. In the screenshot .. I typed in the letter "T" into the CBS_Dropdown and T in the third combobox ( cbs_DropdownList) .. as you can see .. the behavior is quite different.

If the second combobox can incrementally seek the typed value .. I would be most pleased. It appears this code fails in my example.

Thanks
Rick Lipkin

Code: Select all  Expand view

REDEFINE COMBOBOX oCbx2 VAR cItem2 ITEMS { "One", "Two", "Three" } ;
      ID ID_DROPDOWN OF oDlg ;
      STYLE CBS_DROPDOWN ;
      ON CHANGE ( cItem4 := cItem2, oSay:Refresh() ) ;
      VALID ( If( ! oCbx2:Find( oCbx2:oGet:GetText() ),;
                  oCbx2:Add( oCbx2:oGet:GetText() ),), .t. )
                 
   oCbx2:oGet:bKeyDown = { | nKey | SearchItem( nKey, oCbx2 ) } // fails to find
 


Image
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Rick Lipkin » Tue Apr 23, 2013 12:50 pm

Antonio ..

Just wanted to see if you had a chance to look at my results from the previous post?

Many Thanks!
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 3:17 pm

Rick,

I missed your previous post, don't know why, sorry :-(

I am going to review your comments, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 4:34 pm

Rick,

I have been doing some quick tests on combos.prg to see whats going on. I have not finished it yet, but this example helps to trace whats going on:

modified combos.prg
Code: Select all  Expand view
// Showing the use of different styles of ComboBoxes controls

#include "FiveWin.ch"
#include "Combos.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg, oSay
   local oCbx1, oCbx2, oCbx3
   local cItem1, cItem2 := "One", cItem3, cItem4 := "None"

   SET _3DLOOK ON

   // SkinButtons()

   DEFINE DIALOG oDlg RESOURCE "Combos"

   REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS { "One", "Two", "Three" } ;
      ID ID_SIMPLE OF oDlg ;
      ON CHANGE ( cItem4 := cItem1, oSay:Refresh() ) ;
      VALID ( cItem4 := cItem1, oSay:Refresh(), .t. )
     
   REDEFINE COMBOBOX oCbx2 VAR cItem2 ITEMS { "One", "Two", "Three" } ;
      ID ID_DROPDOWN OF oDlg ;
      STYLE CBS_DROPDOWN ;
      ON CHANGE ( cItem4 := cItem2, oSay:Refresh() ) ;
      // VALID ( If( ! oCbx2:Find( oCbx2:oGet:GetText() ),;
      //             oCbx2:Add( oCbx2:oGet:GetText() ),), .t. )
                 
   oCbx2:oGet:bKeyChar = { | nKey | SearchItem( nKey, oCbx2 ) }
                 
   REDEFINE COMBOBOX oCbx3 VAR cItem3 ITEMS { "One", "Two", "Three" } ;
      ID ID_DROPDOWNLIST OF oDlg ;
      ON CHANGE ( cItem4 := cItem3, oSay:Refresh() ) ;
      VALID ( cItem4 := cItem3, oSay:Refresh(), .t. )

   REDEFINE SAY oSay PROMPT cItem4 ID ID_SELECTION OF oDlg COLOR "R+/W"

   ACTIVATE DIALOG oDlg CENTERED

return nil

//----------------------------------------------------------------------------//

function SearchItem( nKey, oCbx )

   local nAt, cText

   if ! Empty( oCbx:oGet:GetText() )
      oCbx:oGet:oGet:Insert( Chr( nKey ) )
      cText = AllTrim( oCbx:oGet:oGet:buffer )
      if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
                                              Upper( cText ) } ) ) != 0
         MsgBeep()
         oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
         return 0
      endif
   endif
   
return nKey          

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 4:39 pm

This version behaves better:

Code: Select all  Expand view
function SearchItem( nKey, oCbx )

   local nAt, cText

   if nKey >= Asc( "a" ) .and. nKey >= Asc( "Z" )
      oCbx:oGet:oGet:Insert( Chr( nKey ) )
      cText = AllTrim( oCbx:oGet:oGet:buffer )
      if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
                                           Upper( cText ) } ) ) != 0
         MsgBeep()
         oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
         return 0
      endif
   endif
   
return nKey          
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 4:44 pm

An enhanced version:

Code: Select all  Expand view
function SearchItem( nKey, oCbx )

   local nAt, cText

   if nKey >= Asc( "a" ) .and. nKey >= Asc( "Z" )
      oCbx:oGet:oGet:Insert( Chr( nKey ) )
      cText = AllTrim( oCbx:oGet:oGet:buffer )
      if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
                                           Upper( cText ) } ) ) != 0
         MsgBeep()
         oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
         oCbx:oGet:SetPos( oCbx:oGet:oGet:pos )
         return 0
      endif
   endif
   
return nKey
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Rick Lipkin » Tue Apr 23, 2013 5:02 pm

Antonio

It appears to be working .. however, now that it incrementally finds "One", "Two" or "Three" .. if the search finds a match, it does not allow you to keep adding letters for a user defined entry.

I think you are VERY CLOSE!! :D

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 5:59 pm

If we find a way to increase the size (of the internal buffer) of a Clipper's GET then we may be able to have it too... :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Tue Apr 23, 2013 6:25 pm

A quick workaround would be to use wider items:

Code: Select all  Expand view
{ "one        ", "two         ", "three         " }


I am trying to change the size of the Clipper GET without success yet...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Rick Lipkin » Tue Apr 23, 2013 7:04 pm

Antonio

Thats fine .. generally I build my arrays on the length of the field anyway .. Do I need to include the SearchItem function in my code or is that something that can be added to your FWH Libs?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Wed Apr 24, 2013 7:48 am

Rick,

We should place it inside Class TComboBox so there is no need to modify your sources

::oGet:bKeyChar is already used from the Class, so we need to implement a new method:

Code: Select all  Expand view
METHOD GetKeyChar( nKey ) CLASS TComboBox

   local nAt, cText

   if ( nKey == VK_TAB .and. ! GetKeyState( VK_SHIFT ) ) .or. nKey == VK_RETURN
      ::oWnd:GoNextCtrl( ::hWnd )
      return 0
   else  
      if nKey == VK_TAB .and. GetKeyState( VK_SHIFT )
         ::oWnd:GoPrevCtrl( ::hWnd )
         return 0
      endif
   endif
   
   if nKey >= Asc( "a" ) .and. nKey >= Asc( "Z" )
      ::oGet:oGet:Insert( Chr( nKey ) )
      cText = AllTrim( ::oGet:oGet:buffer )
      if ( nAt := AScan( ::aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
                                           Upper( cText ) } ) ) != 0
         MsgBeep()
         ::oGet:SetText( ::aItems[ nAt ] )
         ::oGet:SetPos( ::oGet:oGet:pos )
         return 0
      endif
   endif
   
return nKey         
 


and in the two places where bKeyChar is used in the class, change them to this:

::oGet:bKeyChar = { | nKey | ::GetKeyChar( nKey ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42063
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests