REDEFINE COMBOBOX oCbx2 VAR cItem2 ITEMS { "One", "Two", "Three" } ;
ID ID_DROPDOWN OF oDlg ;
STYLE CBS_DROPDOWN ;
ON CHANGE ( cItem4 := cItem2, oSay:Refresh() ) ;
VALID ( If( ! oCbx2:Find( oCbx2:oGet:GetText() ),;
oCbx2:Add( oCbx2:oGet:GetText() ),), .t. )
oCbx2:oGet:bKeyDown = { | nKey | SearchItem( nKey, oCbx2 ) } // fails to find
// Showing the use of different styles of ComboBoxes controls
#include "FiveWin.ch"
#include "Combos.ch"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oSay
local oCbx1, oCbx2, oCbx3
local cItem1, cItem2 := "One", cItem3, cItem4 := "None"
SET _3DLOOK ON
// SkinButtons()
DEFINE DIALOG oDlg RESOURCE "Combos"
REDEFINE COMBOBOX oCbx1 VAR cItem1 ITEMS { "One", "Two", "Three" } ;
ID ID_SIMPLE OF oDlg ;
ON CHANGE ( cItem4 := cItem1, oSay:Refresh() ) ;
VALID ( cItem4 := cItem1, oSay:Refresh(), .t. )
REDEFINE COMBOBOX oCbx2 VAR cItem2 ITEMS { "One", "Two", "Three" } ;
ID ID_DROPDOWN OF oDlg ;
STYLE CBS_DROPDOWN ;
ON CHANGE ( cItem4 := cItem2, oSay:Refresh() ) ;
// VALID ( If( ! oCbx2:Find( oCbx2:oGet:GetText() ),;
// oCbx2:Add( oCbx2:oGet:GetText() ),), .t. )
oCbx2:oGet:bKeyChar = { | nKey | SearchItem( nKey, oCbx2 ) }
REDEFINE COMBOBOX oCbx3 VAR cItem3 ITEMS { "One", "Two", "Three" } ;
ID ID_DROPDOWNLIST OF oDlg ;
ON CHANGE ( cItem4 := cItem3, oSay:Refresh() ) ;
VALID ( cItem4 := cItem3, oSay:Refresh(), .t. )
REDEFINE SAY oSay PROMPT cItem4 ID ID_SELECTION OF oDlg COLOR "R+/W"
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//
function SearchItem( nKey, oCbx )
local nAt, cText
if ! Empty( oCbx:oGet:GetText() )
oCbx:oGet:oGet:Insert( Chr( nKey ) )
cText = AllTrim( oCbx:oGet:oGet:buffer )
if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
Upper( cText ) } ) ) != 0
MsgBeep()
oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
return 0
endif
endif
return nKey
//----------------------------------------------------------------------------//
function SearchItem( nKey, oCbx )
local nAt, cText
if nKey >= Asc( "a" ) .and. nKey >= Asc( "Z" )
oCbx:oGet:oGet:Insert( Chr( nKey ) )
cText = AllTrim( oCbx:oGet:oGet:buffer )
if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
Upper( cText ) } ) ) != 0
MsgBeep()
oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
return 0
endif
endif
return nKey
function SearchItem( nKey, oCbx )
local nAt, cText
if nKey >= Asc( "a" ) .and. nKey >= Asc( "Z" )
oCbx:oGet:oGet:Insert( Chr( nKey ) )
cText = AllTrim( oCbx:oGet:oGet:buffer )
if ( nAt := AScan( oCbx:aItems, { | c | Upper( Left( c, Len( cText ) ) ) == ;
Upper( cText ) } ) ) != 0
MsgBeep()
oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
oCbx:oGet:SetPos( oCbx:oGet:oGet:pos )
return 0
endif
endif
return nKey
{ "one ", "two ", "three " }
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 nKey
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 33 guests