Page 1 of 4

BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Tue Apr 02, 2013 12:08 pm
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.

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Tue Apr 02, 2013 1:12 pm
by Rick Lipkin
Gunther

Hope this thread helps some ..

viewtopic.php?f=3&t=24915&p=135522&hilit=combobox#p135522

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

Code: Select all  Expand view

oCbx:oGet:SetFont( oFont )
 


Rick Lipkin

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Tue Apr 02, 2013 1:37 pm
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.

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Tue Apr 02, 2013 5:18 pm
by byte-one
Here is a little test-program to show the Situation.

Code: Select all  Expand view
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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 6:53 am
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!?

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 12:34 pm
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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 12:42 pm
by byte-one
Thanks!
Antonio, i have sent it to alinares@fivetechsoft.com! I resend it.

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 12:47 pm
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  Expand view
#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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 12:50 pm
by Antonio Linares
Günther,

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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 12:57 pm
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?

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Wed Apr 03, 2013 2:09 pm
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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Thu Apr 04, 2013 10:16 am
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  Expand view
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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Thu Apr 04, 2013 4:33 pm
by Antonio Linares
Günther,

Please try this change:

Code: Select all  Expand view
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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Fri Apr 05, 2013 11:09 am
by byte-one
Antonio, now all is OK!!! Thanks. :D
Only a second place in Combobox.prg is also to update:

Code: Select all  Expand view
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() )

Re: BUG: COMBOBOX with style CBS_DROPDOWN

PostPosted: Fri Apr 05, 2013 12:28 pm
by Antonio Linares
Günther,

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

Great feedback from you, thanks