Estimado Marcelo,
Son GET ... ACTION ... ?
Por favor muestra esas lÃneas de código, gracias
Estimado Marcelo,
Son GET ... ACTION ... ?
Por favor muestra esas lÃneas de código, gracias
Estimado Antonio le comparto parte del codigo
//-----------------------------------------------------------------------------------------------------------------------------
// BARRA DE BUSQUEDA EN LA CABECERA DEL BROWSE (Multiples columnas de busquedas)
:lGetBar := .T. // Para usar la barra de busqueda se debe poner en TRUE
:nGetBarHeight := 35 // Altura en pixel de la barra de Busqueda
:bClrEdits := { || { CLR_BLACK,rgb(255,250,240) } } // Color de fondo en la barra de busqueda cuando toma el foco
//----------------------------------------------------------------------------
WITH OBJECT :Codigo
:cSortOrder := "articulos.codigoarticulo"
:Cargo := "articulos.codigoarticulo"
:cBarGetPic := "@ 99999999999"
:uBarGetVal := 0
:cBarGetBmp := "BRW_CLEAR"
:bBarGetAction := <||
::oBrw:Codigo:uBarGetVal:=0
::SetFilterRegistro(::oBrw,"Limpiar")
Return Nil
> // Busqueda pulsando el boton que le pongamos
:bBarGetValid := <|x|
::SetFilterRegistro(::oBrw,"Filtrar")
Return .T.
> // Busqueda pulsando el ENTER
///:bClrStd := {|| {CLR_BLACK, RGB(223,197,255)} }
:bClrStd := {|| {CLR_BLACK, VAL(::oApp:colorFondoCelda["ArtSis"]) }} //RGB(223,197,255)}
ENDWITH
//----------------------------------------------------------------------------Saludos
Estimado Marcelo,
Lo estamos revisando y te contestamos lo antes posible
Arreglado:
diff --git a/source/classes/xbrowse.prg b/source/classes/xbrowse.prg
index 089a6d6a6..e3a6e0ec9 100644
--- a/source/classes/xbrowse.prg
+++ b/source/classes/xbrowse.prg
@@ -13475,6 +13475,7 @@ CLASS TXBrwColumn
METHOD CreateBarGet()
METHOD ShowSeek( lOn )
METHOD CheckBarGet( lOn )
+ METHOD PlaceBarGetBtn()
METHOD PostEdit( xValue, lButton, lDirectAssign, nLbxAt )
METHOD SetCheck( aBmps, uEdit, aPrompts )
@@ -16342,12 +16343,34 @@ METHOD CreateBarGet() CLASS TXBrwColumn
@ 0,0 CHECKBOX ::oBarGet VAR ::uBarGetVal PROMPT "" SIZE 16,16 PIXEL OF ::oBrw
else
lRight := ( ValType( ::uBarGetVal ) $ 'NDT' )
+ // Create the GET WITHOUT a button (pass nil for bAction and cBmpName).
+ // If the button were created here, TGet:New() builds it while the GET is
+ // still 10x10 (a tiny, top-left, transparent custom-paint button that the
+ // GET draws itself). Resizing the GET later in CheckBarGet() cannot undo
+ // that initial paint, so the button stays small at the top-left corner.
+ // Instead we create a single, normal (non-transparent) button afterwards
+ // and let CheckBarGet() size/position it square on the right of the GET.
::oBarGet := TGet():New( 0, 0, { |x| If( x == nil, ::uBarGetVal, ::uBarGetVal := x ) }, ;
::oBrw, 10, 10, ::cBarGetPic, ::bBarGetValid, aColors[ 1 ], aColors[ 2 ], ;
::HeaderFont, nil, nil, .t., nil, .t., nil, nil, lRight, ;
nil, .f., .f., nil, nil, .f.,;
- nil, nil, nil, nil, ::bBarGetAction, ::cBarGetBmp, nil,;
+ nil, nil, nil, nil, nil, nil, nil,;
nil, nil, ::oBrw:lLimitChars )
+ if ::bBarGetAction != nil
+ ::oBarGet:bAction := ::bBarGetAction
+ ::oBarGet:cBmpName := ::cBarGetBmp
+ ::oBarGet:lAdjustBtn := .f.
+ ::oBarGet:lBtnTransparent := .t.
+ ::oBarGet:CreateButton()
+ if ::oBarGet:oBtn != nil
+ // TBtnBmp:Display() calls CalcSize() on every paint, which restores the
+ // button to its design rect (its bitmap-derived size, top-left of the GET).
+ // That silently undoes the square/right-side placement done in CheckBarGet
+ // on the next repaint. Clearing aSizeRect disables that auto-resize so the
+ // explicit geometry sticks.
+ ::oBarGet:oBtn:aSizeRect := nil
+ endif
+ endif
::oBarGet:bKeyChar := { |k,f,o| ( f ), If( k == VK_TAB .or. k == VK_RETURN, ;
( If( o:lValid(), ::oBrw:SetFocus(), o:SetFocus() ), 0 ), nil ) } //FWH17.07
endif
@@ -16387,12 +16410,17 @@ METHOD CheckBarGet( lOn ) CLASS TXBrwColumn
if :IsKindOf( "TCHECKBOX" )
nCol := ::nDisplayCol + Int( ( ::nWidth - 16 ) / 2 )
:Move( nRow, nCol, 16, 16, .t. )
- elseif :nTop != nRow .or. :nLeft != nCol .or. :nWidth != ( ::nWidth - 8 )
+ else
+ if :nTop != nRow .or. :nLeft != nCol .or. :nWidth != ( ::nWidth - 8 )
:Move( nRow, nCol, ::nWidth - 4 - 4, ::oBrw:nGetBarHeight - 4, .t. )
:Refresh()
- if :IsKindOf( "TGET" ) .and. :oBtn != nil
- :oBtn:Move( 1, :nWidth - :nHeight, Max( :oBtn:nWidth, :nHeight ), :nHeight - 2, .t. )
endif
+ // Reposition the button on every check (not only when the GET itself is
+ // re-moved): some events reset the GET's button back to its creation size
+ // at the top-left corner after CheckBarGet() ran, and the GET-move guard
+ // above would otherwise skip restoring it. Geometry is derived from the
+ // column width and bar height, not the GET's (unreliable) ivars.
+ ::PlaceBarGetBtn()
if :IsKindOf( "TCOMBOBOX" )
// :SendMsg( CB_SETITEMHEIGHT, -1, ::oBrw:nGetBarHeight - 4 )
endif
@@ -16413,14 +16441,7 @@ METHOD CheckBarGet( lOn ) CLASS TXBrwColumn
:Show()
:Enable()
:Refresh()
- if :IsKindOf( "TGET" ) .and. :oBtn != nil
- if IsAppThemed() // 2020-04-26
- // http://forums.fivetechsupport.com/viewtopic.php?f=3&t=38828
- :oBtn:Move( -1, :nWidth - :nHeight - 4, Max( :oBtn:nWidth, :nHeight ), :nHeight - 2, .f. )
- else
- :oBtn:Move( 1, :nWidth - :nHeight, Max( :oBtn:nWidth, :nHeight ), :nHeight - 2, .f. )
- endif
- endif
+ ::PlaceBarGetBtn()
if :IsKindOf( "TCOMBOBOX" )
// :SendMsg( CB_SETITEMHEIGHT, -1, ::oBrw:nGetBarHeight - 4 )
endif
@@ -16438,6 +16459,22 @@ return nil
//----------------------------------------------------------------------------//
+METHOD PlaceBarGetBtn() CLASS TXBrwColumn
+
+ local nSide
+
+ if ::oBarGet != nil .and. ::oBarGet:IsKindOf( "TGET" ) .and. ;
+ ::oBarGet:oBtn != nil
+ // Square button, full GET height, flush on the right side of the GET.
+ nSide := ::oBrw:nGetBarHeight - 4
+ ::oBarGet:oBtn:Move( 0, ( ::nWidth - 8 ) - nSide, nSide, nSide, .f. )
+ ::oBarGet:oBtn:Show()
+ endif
+
+return nil
+
+//----------------------------------------------------------------------------//
+
METHOD ShowSeek( lOn ) CLASS TXBrwColumn
local nRow, nCol, nBottom, nRight#include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
SET DATE ITALIAN
SET CENTURY ON
SET DELETED ON
RDDSETDEFAULT( "DBFCDX" )
SetGetColorFocus()
Sample1()
return nil
//----------------------------------------------------------------------------//
static function Sample1()
local oDlg, oBrw, oFont, oBold
local n, oTmpGet
USE CUSTOMER NEW SHARED
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE 800,550 PIXEL TRUEPIXEL ;
FONT oFont TITLE FWVERSION + " : Bar Get with ACTION Buttons"
@ 110,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "CUSTOMER" AUTOCOLS CELL LINES NOBORDER
// --- Relevant Code: Bar GETs with ACTION buttons ---
for n := 1 to Len( oBrw:aCols )
WITH OBJECT oBrw:aCols[ n ]
if FieldType( n ) != 'L'
:uBarGetVal := uValBlank( fieldGet( n ) )
if FieldType( n ) == 'N'
:cBarGetPic := NumPict( FieldLen( n ), FieldDec( n ) )
endif
// Clear button on every column GET
:cBarGetBmp := "..\..\..\bitmaps\16back.bmp"
:bBarGetAction := {|oGet| ;
( oTmpGet := oGet,;
n := AScan( oBrw:aCols, {|c| c:oBarGet == oTmpGet } ),;
oBrw:aCols[ n ]:uBarGetVal := uValBlank( fieldGet( n ) ),;
oGet:Refresh(),;
oBrw:SetFocus() ) }
endif
END
next
oBrw:lGetBar := .t.
// --- End of Relevant Code ---
WITH OBJECT oBrw
:nHeaderHeight := 40
:oHeaderFonts := oBold
:bClrEdits := { || { CLR_BLACK, RGB( 255, 250, 240 ) } }
:AutoFit()
//
:CreateFromCode()
END
@ 10,20 SAY "Bar GETs with ACTION buttons (bitmap on the right side of each GET)." + CRLF + ;
"Click the arrow button to clear the GET value. Then use Set Filter." + CRLF + ;
CRLF + ;
"Usage: :cBarGetBmp := '16BACK'" + CRLF + ;
" :bBarGetAction := { || ... }" ;
SIZE oDlg:nWidth - 40,60 PIXEL OF oDlg CENTER
@ 70, 20 BTNBMP PROMPT { || If( oBrw:lGetBar, "Hide GetBar", "Show GetBar" ) } ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:lGetBar := ! oBrw:lGetBar, oBrw:Refresh() )
@ 70,140 BTNBMP PROMPT "Set Filter" ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:cAlias )->( SetFilter( oBrw ) )
@ 70,250 BTNBMP PROMPT "Clear Filter" ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:cAlias )->( DBCLEARFILTER(), oBrw:Refresh(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oBold
return nil
//----------------------------------------------------------------------------//
static function SetFilter( oBrw )
local cFilter := ""
local n, oCol, uVal, cType
for n := 1 to Len( oBrw:aCols )
oCol := oBrw:aCols[ n ]
if ! Empty( uVal := oCol:uBarGetVal )
if !Empty( cFilter )
cFilter += " .AND. "
endif
cType := ValType( uVal )
do case
case cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
otherwise
cFilter += FieldName( n ) + " == " + cValToChar( uVal )
endcase
endif
next
if Empty( cFilter )
if ! Empty( DBFILTER() )
DBCLEARFILTER()
oBrw:Refresh()
endif
else
if !( DBFILTER() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrw:Refresh()
endif
endif
oBrw:SetFocus()
return nil
//----------------------------------------------------------------------------//