BUG: COMBOBOX with style CBS_DROPDOWN

BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » 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
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 » Tue Apr 02, 2013 1: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: Select all  Expand view

oCbx:oGet:SetFont( oFont )
 


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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » Tue Apr 02, 2013 1: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » Tue Apr 02, 2013 5:18 pm

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
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 byte-one » Wed Apr 03, 2013 6: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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » 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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » 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: 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
regards, saludos

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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » 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
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby Antonio Linares » Wed Apr 03, 2013 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » 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: 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
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 Antonio Linares » Thu Apr 04, 2013 4:33 pm

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
regards, saludos

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

Re: BUG: COMBOBOX with style CBS_DROPDOWN

Postby byte-one » Fri Apr 05, 2013 11:09 am

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() )
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 Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42098
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests