Alguien está usando un combobox editable y que soporte búsqueda incremental ?
FWH soporta búsqueda incremental en comboboxes no editables, y estoy buscando la forma de implementarlo, gracias!
Alguien está usando un combobox editable y que soporte búsqueda incremental ?
FWH soporta búsqueda incremental en comboboxes no editables, y estoy buscando la forma de implementarlo, gracias!
Antonio,
estaria bueno implementar un xbrowse enganchado con el combobox, eso le daria una potencia increible al combo.
Salu2, Ariel.
Ariel,
Cierto, pero de momento se trata de resolver lo que explico ![]()
#Include "FiveWin.Ch"
#include "xbrowse.ch"
Function Main()
Local oDlg
Local oGet, oGet1, oCb
local cVar := space( 20 )
local a := {}
USE customer NEW
customer -> ( DBEVAL( {|| AADD( a, field -> street ) } ) )
DEFINE DIALOG oDlg from 0,0 to 400,400 pixel
oGet := tListGet():new(15,15,{ | u | If( PCount()==0, cVar, cVar:= u ) },oDlg,120,12,"@!",,,,,,,.T.)
@ 29,15 get oGet1 var cVar picture "@!" size 120,12 of oDlg pixel
@ 43,15 COMBOBOX oCb ITEMS a OF oDlg pixel SIZE 120,100
oGet:aSource := a
oGet:bSearch := {|i,e| AT( i, UPPER(e) ) > 0 }
oGet:cSource := 'ARRAY'
oGet:lenDisplay := 15
ACTIVATE DIALOG oDlg
USE
return nil
//---------------------------------------------------------------
CLASS tListGet FROM tGet
DATA oBrw, oWin, aData, lenBuffer, bSearch, aSource, cSource, cField, cAlias, lenDisplay
METHOD new() CONSTRUCTOR
METHOD redefine() CONSTRUCTOR
METHOD FillList()
METHOD Initiate()
METHOD keyDown()
METHOD keychar()
ENDCLASS
//---------------------------------------------------------------
METHOD New( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg,;
lUpdate, bWhen, lCenter, lRight, bChanged, lReadOnly,;
lPassword, lNoBorder, nHelpId, lSpinner,;
bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName, cCueText ) CLASS tListGet
//---------------------------------------------------------------
RETURN ::super:new( nRow, nCol, bSetGet, oWnd, nWidth, nHeight, cPict, bValid,;
nClrFore, nClrBack, oFont, lDesign, oCursor, lPixel, cMsg,;
lUpdate, bWhen, lCenter, lRight, bChanged, lReadOnly,;
lPassword, lNoBorder, nHelpId, lSpinner,;
bUp, bDown, bMin, bMax, bAction, cBmpName, cVarName, cCueText )
//---------------------------------------------------------------
METHOD ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid, nClrFore,;
nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bChanged,;
lReadOnly, lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName,;
cVarName, cCueText ) CLASS tListGet
//---------------------------------------------------------------
RETURN ::super:ReDefine( nId, bSetGet, oWnd, nHelpId, cPict, bValid, nClrFore,;
nClrBack, oFont, oCursor, cMsg, lUpdate, bWhen, bChanged,;
lReadOnly, lSpinner, bUp, bDown, bMin, bMax, bAction, cBmpName,;
cVarName, cCueText )
//---------------------------------------------------------------
METHOD Initiate( hDlg ) CLASS TListGet
//---------------------------------------------------------------
LOCAL oSelf := SELF, aRect
::super:Initiate( hDlg )
::lenBuffer := LEN( cValToChar( Eval( ::bSetGet ) ) )
::aData := ARRAY(1)
DEFAULT ::lenDisplay := 5
DEFINE DIALOG ::oWin OF oSelf:oWnd FROM 100, 100 TO 100, 100 + ::nWidth PIXEL STYLE nOR( WS_CHILD, WS_POPUP, WS_VISIBLE )
@ 0, 0 XBROWSE ::oBrw OF oSelf:oWin ARRAY oSelf:aData COLUMNS 1 SIZEs ::nWidth
::oBrw:lHeader := .F.
::oBrw:lRecordSelector := .F.
::oBrw:lFlatStyle := .T.
::oBrw:nStyle -= WS_BORDER
::oWin:oClient := ::oBrw
::oBrw:bChange := {|| ::cText( PADR( ::aData[ ::oBrw:nArrayAt ], ::lenBuffer, ' ' ) ), ::refresh(), ::SetPos( LEN( ALLTRIM( ::aData[ ::oBrw:nArrayAt ] ) ) + 1 ), ::setFocus() }
::oBrw:bLClicked := {|| ::oWin:hide() }
::oBrw:lHScroll := .F.
::oBrw:lVScroll := .F.
::oBrw:createFromCode()
::bPostKey := {|oGet, cBuffer| ;
IF( EMPTY( cBuffer ), ::oWin:hide(), NIL ),;
oGet:aData[1] := cBuffer, ;
oGet:Assign(), ;
::FillList() }
ACTIVATE DIALOG oSelf:oWin NOWAIT ON INIT oSelf:oWin:hide()
::oWnd:bMoved := {|| ::oWin:hide() }
return nil
//---------------------------------------------------------------
METHOD FillList() CLASS TListGet
//---------------------------------------------------------------
LOCAL i := 1, aRect
ASIZE( ::aData, 1 )
DO CASE
CASE ::cSource = 'ARRAY'
DO WHILE LEN( ::aData ) < ::lenDisplay .AND. i <= LEN( ::aSource )
IF EVAL( ::bSearch, ALLTRIM(::aData[1]), ::aSource[i] )
AADD( ::aData, ::aSource[i] )
ENDIF
i++
ENDDO
::oWin:SetSize( ::oWin:nWidth, ( LEN( ::aData ) ) * GetTextHeight( ::hWnd ) + LEN( ::aData ) )
aRect := getWndRect( ::hWnd )
::oWin:move( aRect[1] + ::nHeight + 3, aRect[2] )
::oWin:show()
CASE ::cSource = 'DBF'
(::cAlias) -> ( DBGOTOP() )
DO WHILE LEN( ::aData ) < ::lenDisplay .AND. ! (::cAlias)-> ( EOF() )
IF EVAL( ::bSearch, ALLTRIM(::aData[1]), (::cAlias)-> ( fieldGet( fieldPos( ::cField ) ) ) )
AADD( ::aData, (::cAlias)-> ( fieldGet( fieldPos( ::cField ) ) ) )
ENDIF
i++
ENDDO
ENDCASE
::oBrw:refresh()
RETURN NIL
//---------------------------------------------------------------
METHOD KeyDown( nKey, nFlags ) CLASS TListGet
//---------------------------------------------------------------
IF ::oWin:lVisible
DO CASE
CASE nKey == VK_UP
::oBrw:GoUp()
RETURN 0
CASE nKey == VK_DOWN
::oBrw:GoDown()
RETURN 0
ENDCASE
ENDIF
IF nKey == VK_DELETE .or. nKey == VK_BACK
Super:KeyDown( nKey, nFlags )
::aData[1] := ::cText()
IF( EMPTY( ::aData[1] ), ::oWin:hide(), ::FillList() )
RETURN 0
ENDIF
RETURN Super:KeyDown( nKey, nFlags )
//---------------------------------------------------------------
METHOD keychar( nKey, nFlags ) CLASS TListGet
//---------------------------------------------------------------
IF nKey == VK_RETURN .AND. ::oWin:lVisible
::oWin:hide()
ENDIF
RETURN super:keychar( nkey, nFlags )oCbx:oGet:bKeyChar = { | nKey, nFlags | oCbx:KeyChar( nKey, nFlags ) } oCbx:oGet:bKeyChar = { | nKey, nFlags, nAt | ;
If( ( nAt := AScan( oCbx:aItems, AllTrim( oCbx:oGet:GetText() ) ) ) != 0,;
( oCbx:oGet:SetText( oCbx:aItems[ nAt ] ), 0 ), ) }Joao,
Solucionado ![]()
oCbx:oGet:bKeyChar = { | nKey | oCbx:GetKeyChar( nKey ) }
gracias!
Hola Antonio,
tienes un ejemplo de como funciona ?
gracias
saludos..
#include "FiveWin.ch"
function Main()
local oDlg, oCbx, cDia
DEFINE DIALOG oDlg
@ 1, 3 COMBOBOX oCbx VAR cDia OF oDlg SIZE 100, 300 ;
ITEMS { "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo" } ;
STYLE CBS_DROPDOWN
oCbx:oGet:bKeyChar = { | nKey | oCbx:GetKeyChar( nKey ) }
ACTIVATE DIALOG oDlg CENTERED
return nilApplication
===========
Path and name: C:\funciones\combo.exe (32 bits)
Size: 1,684,992 bytes
Compiler version: Harbour 3.1.0dev (Rev. 17222)
FiveWin Version: FWH 12.03
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 09/26/14, 07:00:28
Error description: Error BASE/1004 Message not found: TCOMBOBOX:GETKEYCHAR
Args:
[ 1] = O TCOMBOBOX
Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TCOMBOBOX:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TCOMBOBOX:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TCOMBOBOX:GETKEYCHAR( 0 )
Called from: combo.prg => (b)MAIN( 13 )
Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR( 1028 )
Called from: => TWINDOW:HANDLEEVENT( 0 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1700 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 579 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3153 )
Called from: => DIALOGBOXINDIRECT( 0 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
Called from: combo.prg => MAIN( 15 )horacio wrote:Antonio, obtengo este error del ejemplo que posteaste
Application =========== Path and name: C:\funciones\combo.exe (32 bits) Size: 1,684,992 bytes Compiler version: Harbour 3.1.0dev (Rev. 17222) FiveWin Version: FWH 12.03 Windows version: 6.1, Build 7601 Service Pack 1 Time from start: 0 hours 0 mins 1 secs Error occurred at: 09/26/14, 07:00:28 Error description: Error BASE/1004 Message not found: TCOMBOBOX:GETKEYCHAR Args: [ 1] = O TCOMBOBOX Stack Calls =========== Called from: => __ERRRT_SBASE( 0 ) Called from: ../../../tobject.prg => TCOMBOBOX:ERROR( 0 ) Called from: ../../../tobject.prg => (b)HBOBJECT( 0 ) Called from: ../../../tobject.prg => TCOMBOBOX:MSGNOTFOUND( 0 ) Called from: ../../../tobject.prg => TCOMBOBOX:GETKEYCHAR( 0 ) Called from: combo.prg => (b)MAIN( 13 ) Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR( 1028 ) Called from: => TWINDOW:HANDLEEVENT( 0 ) Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1700 ) Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 579 ) Called from: .\source\classes\WINDOW.PRG => _FWH( 3153 ) Called from: => DIALOGBOXINDIRECT( 0 ) Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 ) Called from: combo.prg => MAIN( 15 )
Saludos
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 nKeyKarinha, efectivamente ese método no existe. Hay alguna manera de implementar la búsqueda sin este método ?? Gracias
Saludos
horacio wrote:Karinha, efectivamente ese método no existe. Hay alguna manera de implementar la búsqueda sin este método ?? Gracias
Saludos
#include "FiveWin.ch"
FUNCTION Test()
LOCAL oDlg , oCombo1, oExit, oLeft, oRight, oFnt, oFont
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()
SkinButtons() // Show...
DEFINE FONT oFnt NAME "Ms Sans Serif" SIZE 0, 14 BOLD //UnderLine
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -14 BOLD //UnderLine
DEFINE DIALOG oDlg TITLE "Combobox CBS_DROPDOWN Search In..." ;
FROM 0,0 TO 304, 350 PIXEL COLORS CLR_BLACK, CLR_WHITE TRANSPARENT
oDlg:lHelpIcon := .F.
@ 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, 80 ;
STYLE CBS_DROPDOWN UPDATE
oCombo1:oGet:bKeyChar = { | nKey | oCombo1:GetKeyChar( nKey ) } // Wow...
@ 3,2 SAY "Type a letter for search... God save the king." UPDATE ;
COLORS CLR_HRED, CLR_WHITE
@ 4, 8 BUTTON oLeft PROMPT "&Left" OF oDlg ;
ACTION if( testdb->(recno())>1,(testdb->(dbskip(-1) ), ;
oDlg:update()),msginfo("Begin of DB") )
oLeft:cToolTip := "Use Left For Incremental Search"
@ 4, 17 BUTTON oRight PROMPT "&Right" OF oDlg ;
ACTION if( testdb->(recno())<3,(testdb->(dbskip(1)), ;
oDlg:update()),msginfo("End of DB") )
oRight:cToolTip := "Use Right For Incremental Search"
@ 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
@ 7.50, 12 BUTTON oExit PROMPT "&Exit" OF oDlg ;
ACTION ( oDlg:End() ) CANCEL UPDATE
oExit:cToolTip := "Exit"
SET FONT OF oLeft TO oFont
SET FONT OF oRight TO oFont
SET FONT OF oExit TO oFont
ACTIVATE DIALOG oDlg CENTERED
oFnt:End()
oFont:End()
USE
RETURN NIL