Esto funciona OK
- Code: Select all Expand view
- #include "fivewin.ch"
Function Main()
local oDlg, cCombo := "2", cGet:=Space(10)
local aItems := { "1", "2", "3" }
DEFINE DIALOG oDlg FROM 2, 2 TO 18, 60 TITLE "Combo" STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, 4 )
@ 1, 2 GET cGet
@ 2, 2 COMBOBOX cCombo ITEMS aItems SIZE 200, 100 VALID (MsgInfo("Hola"),.t.)
ACTIVATE DIALOG oDlg CENTERED
Return (nil)
Este ejemplo (combos.prg del samples) no funciona correctamente
- Code: Select all Expand view
- // 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 { "Uno", "Dos", "Tres" } ;
ID ID_SIMPLE OF oDlg ;
ON CHANGE ( cItem4 := cItem1, oSay:Refresh() );
VALID (MsgInfo("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:bKeyDown = { | 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
if Len( AllTrim( oCbx:oGet:GetText() ) ) == 1
if ( nAt := AScan( oCbx:aItems, { | c | Left( c, 1 ) == AllTrim( oCbx:oGet:GetText() ) } ) ) != 0
oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
return 0
endif
endif
return nKey
//----------------------------------------------------------------------------//
procedure AppSys
return
//----------------------------------------------------------------------------//
Lo que ocurre es que ejecuta el valid al recibir el foco y no al salir como debería ser.
¿Alguna pista?