FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour BUG: COMBOBOX with style CBS_DROPDOWN
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Tue Apr 02, 2013 12:08 PM

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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Tue Apr 02, 2013 01:12 PM
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 (fw): Select all Collapse
oCbx:oGet:SetFont( oFont )


Rick Lipkin
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Tue Apr 02, 2013 01:37 PM
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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Tue Apr 02, 2013 05:18 PM
Here is a little test-program to show the Situation.

Code (fw): Select all Collapse
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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 06:53 AM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 12:34 PM

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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 12:42 PM

Thanks!
Antonio, i have sent it to alinares@fivetechsoft.com! I resend it.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 12:47 PM
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 (fw): Select all Collapse
#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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 12:50 PM

Günther,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 12:57 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Wed Apr 03, 2013 02:09 PM

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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Thu Apr 04, 2013 10:16 AM
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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Thu Apr 04, 2013 04:33 PM
Günther,

Please try this change:

Code (fw): Select all Collapse
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
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Fri Apr 05, 2013 11:09 AM
Antonio, now all is OK!!! Thanks. :-)
Only a second place in Combobox.prg is also to update:

Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: BUG: COMBOBOX with style CBS_DROPDOWN
Posted: Fri Apr 05, 2013 12:28 PM

Günther,

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

Great feedback from you, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com