BUG: COMBOBOX with style CBS_DROPDOWN

User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

If using such Combobox and skip on a database, a userdefined field-text from a record are changed to the last selected text from the combobox in another record if the Combobox becomes Focus or clicking on the arrow. Also the colors from SetGetColorFocus() not using.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Rick Lipkin »

Gunther

Hope this thread helps some ..

http://forums.fivetechsupport.com/viewt ... ox#p135522

As far as the appearance .. the answer is in the thread above.

Code: Select all

oCbx:oGet:SetFont( oFont )
 
Rick Lipkin
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Thanks Rick, but not the font becomes different, just the free text (as CBS-DROPDOWN made possible to write free text) in this record becomes (if i open the Combobox) the same value, in another record was selected from the combobox-list and the free-text is erased.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Here is a little test-program to show the Situation.

Code: Select all

function test()

local oDlg , oCombo1

dbcreate("testdb.dbf",{{"feld1","C",10,0}})
USE
USE ("testdb.dbf") ALIAS "testdb" NEW EXCLUSIVE
testdb->(dbappend())
testdb->feld1 := "ABCDEFGHIJ"
testdb->(dbappend())
testdb->feld1 := replicate("B",len(testdb->feld1))
testdb->(dbgotop())

DEFINE DIALOG oDlg TITLE "Combobox CBS_DROPDOWN Test" FROM 0,0 TO 300,300 PIXEL

@ 2, 2 COMBOBOX oCombo1 VAR testdb->feld1 PROMPTS {replicate("A",len(testdb->feld1)),replicate("B",len(testdb->feld1))} OF oDlg SIZE 80,10 STYLE CBS_DROPDOWN UPDATE

@ 4, 1 BUTTON "<" OF oDlg ACTION if(testdb->(recno())>1,(testdb->(dbskip(-1)),oDlg:update()),msginfo("Begin of DB"))
@ 4, 10 BUTTON ">" OF oDlg ACTION if(testdb->(recno())<2,(testdb->(dbskip(1)),oDlg:update()),msginfo("End of DB"))

@ 6,1 SAY "1. Go with > to the second record."+CRLF+"2. Go with < return to the first record"+CRLF+"3. Open the Combobox with the arrow"+CRLF+CRLF+;
    "Now you see, that the first record also is 'BBBBBBBBBB'" SIZE 200,50
ACTIVATE DIALOG oDlg

USE

return nil
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Antonio, this is very important to me. But i found no solution for this.

Antonio, i had sent to you a privat E-Mail for updating my FWH but no answer!?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

I have just seen your example and I am going to test it.

I have not received any emails from you, unless gmail move it to the spam folder... (edited: nothing in the spam folder also)
Please resend it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Thanks!
Antonio, i have sent it to alinares@fivetechsoft.com! I resend it.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

Please resend me your email, as I have not received it.

Your example fails because the first value you place in the field does not match any of the values in the combobox.

Please try your example with some little modifications from me and you will see that it works fine :-)

Code: Select all

#include "FiveWin.ch"

function Main()

   local oDlg , oCombo1

   dbcreate("testdb.dbf",{{"feld1","C",10,0}})
   USE
   USE ("testdb.dbf") ALIAS "testdb" NEW EXCLUSIVE
   testdb->(dbappend())
   testdb->feld1 := replicate( "A", len( testdb->feld1 ) ) // "ABCDEFGHIJ"
   testdb->(dbappend())
   testdb->feld1 := replicate( "B", len( testdb->feld1 ) )
   testdb->(dbgotop())

   DEFINE DIALOG oDlg TITLE "Combobox CBS_DROPDOWN Test" FROM 0,0 TO 300,300 PIXEL

   @ 2, 2 COMBOBOX oCombo1 VAR testdb->feld1 ;
      PROMPTS {replicate("A",len(testdb->feld1)),replicate("B",len(testdb->feld1))} ;
      OF oDlg SIZE 80, 40 STYLE CBS_DROPDOWN UPDATE

   @ 4, 1 BUTTON "<" OF oDlg ;
      ACTION if(testdb->(recno())>1,(testdb->(dbskip(-1)),oDlg:update()),msginfo("Begin of DB"))
   
   @ 4, 10 BUTTON ">" OF oDlg ;
      ACTION if(testdb->(recno())<2,(testdb->(dbskip(1)),oDlg:update()),msginfo("End of DB"))

   @ 6,1 SAY "1. Go with > to the second record." + CRLF + ;
             "2. Go with < return to the first record" + CRLF + ;
             "3. Open the Combobox with the arrow" + CRLF + CRLF + ;
             "Now you see, that the first record also is 'BBBBBBBBBB'" SIZE 200, 50

   ACTIVATE DIALOG oDlg CENTERED

   USE

return nil
regards, saludos

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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

Still haven't received your email. Please resend it to antonio.fivetech@gmail.com thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Antonio, i think, style CBS_DROPDOWN lets me also another text to input (as it have a oGet-object), not only text from the list?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

Yes, good observation :-)

With this little change in combobox.prg, your original example works fine:

METHOD Set( cNewItem ) CLASS TComboBox
...
if ValType( cNewItem ) == "N" .or. nAt != 0 .and. ::oGet == nil
...

Included for next FWH build
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Antonio, this solution is unperfected. Please test this new code with more the 2 records. This shows the problem more exact. And please show that SetGetColorFocus() not functioning on this ::oGet.

Code: Select all

function test()

local oDlg , oCombo1

dbcreate("testdb.dbf",{{"feld1","C",10,0}})
USE
USE ("testdb.dbf") ALIAS "testdb" NEW EXCLUSIVE
testdb->(dbappend())
testdb->feld1 := replicate("A",len(testdb->feld1))
testdb->(dbappend())
testdb->feld1 := "ABCDEFGHIJ"
testdb->(dbappend())
testdb->feld1 := replicate("B",len(testdb->feld1))
testdb->(dbgotop())

SetGetColorFocus()

DEFINE DIALOG oDlg TITLE "Combobox CBS_DROPDOWN Test" FROM 0,0 TO 300,350 PIXEL

@ 1,2 SAY "Recno: "+alltrim(str(testdb->(recno()))) UPDATE

@ 2, 2 COMBOBOX oCombo1 VAR testdb->feld1 PROMPTS {replicate("A",len(testdb->feld1)),replicate("B",len(testdb->feld1))} OF oDlg SIZE 80,10 STYLE CBS_DROPDOWN UPDATE

@ 4, 1 BUTTON "<" OF oDlg ACTION if(testdb->(recno())>1,(testdb->(dbskip(-1)),oDlg:update()),msginfo("Begin of DB"))
@ 4, 10 BUTTON ">" OF oDlg ACTION if(testdb->(recno())<3,(testdb->(dbskip(1)),oDlg:update()),msginfo("End of DB"))

@ 6,1 SAY "1. Go with > to the second record."+CRLF+"2. Go with > to the third record"+CRLF+"3. Go with < return to the second record"+CRLF+"4. Open the Combobox with the arrow"+CRLF+CRLF+;
    "Now you see, that the second record also is 'AAAAAAAAAA'" SIZE 200,50
ACTIVATE DIALOG oDlg

USE

return nil
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

Please try this change:

Code: Select all

METHOD LostFocus( hWndGetFocus ) CLASS TComboBox

   local nAt := ::SendMsg( CB_GETCURSEL )

   ::Super:LostFocus( hWndGetFocus )

   if nAt != CB_ERR
      ::nAt = nAt + 1
      if ValType( Eval( ::bSetGet ) ) == "N"
         Eval( ::bSetGet, nAt + 1 )
      else
         Eval( ::bSetGet, If( ::oGet == nil, ::aItems[ nAt + 1 ], ::oGet:GetText() ) )
      endif
   else
      Eval( ::bSetGet, GetWindowText( ::hWnd ) )
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
byte-one
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by byte-one »

Antonio, now all is OK!!! Thanks. :D
Only a second place in Combobox.prg is also to update:

Code: Select all

METHOD VarGet() CLASS TComboBox

   local cRet, nAt := ::SendMsg( CB_GETCURSEL )

   if nAt != CB_ERR
      ::nAt = nAt + 1
      //cRet :=  ::aItems[ nAt + 1 ]
      cRet := If( ::oGet == nil, ::aItems[ nAt + 1 ], ::oGet:GetText() )
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Post by Antonio Linares »

Günther,

Already included for the next FWH build, many thanks :-)

Great feedback from you, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply