Añadir texto a tProgressBarMod
Publicado: Jue Nov 17, 2022 9:56 am
Buenas Xailer team.
Hasta ahora en las progressbar he usado mucho una sobregarga para pintar un texto dentro que indique por ejemplo el progreso: "Procesando registro 1 de 200"
He intentado aplicar la misma sobrecarga a la Progress bar moderna pero aunque no da error, ni la pinta ni hace nada de nada, no se que puede estar mal.
Una manita por favor, gracias.
//-----------------------------------------------------------------------------------------------------------------
Class TProgressBarMod From XProgressBarMOd
PROPERTY cText INIT "" //Texto a mostrar.
//Si se quiere usar numerador junto con un texto "Procesando registro %1 de %2"
//Si solo se quiere ver el porcentaje indicar como texto "%"
PROPERTY nClrText INIT clWindowText EDITOR PE_Color
METHOD WMPaint()
EndClass
//-----------------------------------------------------------------------------------------------------------------
// Sobrecarga a ProgressBar para que pueda contener un texto y opcionalmente un indice de progreso y un total
METHOD WMPaint( hDC ) CLASS TProgressBarMod
LOCAL cText
hDC := ::BeginPaint( hDC )
PrevWindowProc( ::Handle, WM_PAINT, hDC, 0 )
IF !Empty( ::cText )
If ::cText=="%"
cText:= ToString(Int(::nValue/::nMax*100))+" %"
Else
cText := StrTran( ::cText, "%1", AllTrim( ToString( ::nValue ) ) )
cText := StrTran( cText, "%2", AllTrim( ToString( ::nMax ) ) )
Endif
SetBkMode( hDC, TRANSPARENT )
SetTextColor( hDC, ::nClrText )
DrawText( hDC, cText, GetClientRect( ::Handle ), nOR( DT_CENTER, DT_VCENTER, DT_SINGLELINE ) )
ENDIF
::Super:WmPaint()
RETURN ::EndPaint( hDC )
//==============================================================================
Hasta ahora en las progressbar he usado mucho una sobregarga para pintar un texto dentro que indique por ejemplo el progreso: "Procesando registro 1 de 200"
He intentado aplicar la misma sobrecarga a la Progress bar moderna pero aunque no da error, ni la pinta ni hace nada de nada, no se que puede estar mal.
Una manita por favor, gracias.
//-----------------------------------------------------------------------------------------------------------------
Class TProgressBarMod From XProgressBarMOd
PROPERTY cText INIT "" //Texto a mostrar.
//Si se quiere usar numerador junto con un texto "Procesando registro %1 de %2"
//Si solo se quiere ver el porcentaje indicar como texto "%"
PROPERTY nClrText INIT clWindowText EDITOR PE_Color
METHOD WMPaint()
EndClass
//-----------------------------------------------------------------------------------------------------------------
// Sobrecarga a ProgressBar para que pueda contener un texto y opcionalmente un indice de progreso y un total
METHOD WMPaint( hDC ) CLASS TProgressBarMod
LOCAL cText
hDC := ::BeginPaint( hDC )
PrevWindowProc( ::Handle, WM_PAINT, hDC, 0 )
IF !Empty( ::cText )
If ::cText=="%"
cText:= ToString(Int(::nValue/::nMax*100))+" %"
Else
cText := StrTran( ::cText, "%1", AllTrim( ToString( ::nValue ) ) )
cText := StrTran( cText, "%2", AllTrim( ToString( ::nMax ) ) )
Endif
SetBkMode( hDC, TRANSPARENT )
SetTextColor( hDC, ::nClrText )
DrawText( hDC, cText, GetClientRect( ::Handle ), nOR( DT_CENTER, DT_VCENTER, DT_SINGLELINE ) )
ENDIF
::Super:WmPaint()
RETURN ::EndPaint( hDC )
//==============================================================================