Hola Silvio, a ver si ahora te entendí bien.
Code: Select all | Expand
// Idea Original by Silvio Falconi. - Version: 2.0
// C:\FWH..\SAMPLES\SILBTNF2.PRG - Modificado en: 27/04/2023 - Joao.
#include 'fivewin.ch'
#include 'xbrowse.ch'
#include "constant.ch"
#Define aPubGrad {| lInvert | If( lInvert, ;
{ { 1 / 3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
{ 2 / 3, nRGB( 255, 215, 84 ), nRGB( 255, 233, 162 ) } ;
}, ;
{ { 1 / 2, nRGB( 219, 230, 244 ), nRGB( 207 - 50, 221 - 25, 255 ) }, ;
{ 1 / 2, nRGB( 201 - 50, 217 - 25, 255 ), nRGB( 231, 242, 255 ) } ;
} ) }
// controle de Botones.
STATIC oFont, lLigaBtn1 := .T., lLigaBtn2 := .T., lLigaBtn3 := .T., ;
lLigaBtn4 := .T., lLigaBtn5 := .T., lLigaBtn6 := .T., ;
lLigaBtn7 := .T., lLigaBtn8 := .T.
STATIC oBar
FUNCTION Main() // Ejemplo original by Silvio Falconi.
LOCAL oDlg, oDbf, cTitle, aBtnBar := ARRAY(8), cSay, oSay, oFont2, oExit, ;
oBtn1, oBtn2
LOCAL nBottom := 27.2
LOCAL nRight := 89
LOCAL nWd := Max( nRight * DLG_CHARPIX_W, 180 ) // 703.10
LOCAL nHt := nBottom * DLG_CHARPIX_H // 410.72
SKinButtons()
cSay := OemToAnsi( "I LOVE FIVEWIN THE BEST!" )
cTitle := OemToAnsi( "Silvio Falconi And The Power of FiveWin " + ;
"Cambiar Botones en Tiempo Real." )
DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, -16 BOLD
DEFINE FONT oFont2 NAME "Segoe UI Light" SIZE 0, -28 BOLD
DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL TITLE cTitle ;
COLORS CLR_BLACK, CLR_WHITE TRANSPARENT FONT oFont
oDlg:lHelpIcon := .F.
@ 200, 150 SAY oSay VAR cSay SIZE 400, 100 PIXEL OF oDlg UPDATE CENTER ;
FONT oFont2 COLOR CLR_CYAN, CLR_BLACK
// 2 Botones
@ 90, 50 BUTTON oBtn1 PROMPT "&Select One" SIZE 120, 40 PIXEL OF oDlg ;
ACTION Btnbar2( 2, oBar, aBtnBar, oDlg )
oBtn1:cTooltip := { "Click-Me Para 2 Botones", ;
"2 Botones en la Barra", 1, CLR_WHITE, CLR_HBLUE }
// 5 Botones o mas...
@ 90, 200 BUTTON oBtn2 PROMPT "&DeSelect One" SIZE 140, 40 PIXEL OF oDlg ;
ACTION Btnbar5( 5, oBar, aBtnBar, oDlg )
oBtn2:cTooltip := { "Click-Me Para 5 Botones", ;
"5 Botones en la Barra", 1, CLR_WHITE, CLR_HBLUE }
@ 90, 450 BUTTON oExit PROMPT "&Exit" SIZE 080, 40 PIXEL OF oDlg ;
ACTION( oDlg:End() ) CANCEL
oExit:cTooltip := { "Click no Botão Para Sair", ;
"Sair do Programa Agora? ", 1, CLR_WHITE, CLR_HBLUE }
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT( BtnBar5( 0, oBar, aBtnBar, oDlg ), xFocus( oExit ) )
oFont:End()
oFont2:End()
RETURN NIL
// 2 Botones o mas o menos...
FUNCTION BtnBar2( nBar, oBar, aBtnBar, oDlg )
DEFINE BUTTONBAR oBar BUTTONSIZE 70, 50 _3DLOOK TOP OF oDlg 2007
WITH OBJECT oBar
oBar:Refresh()
oBar:bClrGrad := aPubGrad
oBar:bRClicked := { || NIL }
oBar:bLClicked := { || NIL }
oBar:SetFont( oFont )
oBar:nClrText := CLR_HRED
oBar:Adjust()
END
// los ultimos son en primero - Left.
DEFINE BUTTON aBtnBar[4] OF oBar PROMPT "Delete " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\open.bmp" WHEN( lLigaBtn4 )
DEFINE BUTTON aBtnBar[5] OF oBar PROMPT "Print " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\printer.bmp" WHEN( lLigaBtn5 )
// Silvio:
// Botones OFF y Hide() in BtnBar5( nBar, oBar, aBtnBar, oDlg )
lLigaBtn1 := .F.
lLigaBtn2 := .F.
lLigaBtn3 := .F.
aBtnBar[1]:Hide()
aBtnBar[2]:Hide()
aBtnBar[3]:Hide()
aBtnBar[1]:Refresh()
aBtnBar[2]:Refresh()
aBtnBar[3]:Refresh()
// in BtnBar5() fin / end
RETURN NIL
// 5 Botones o mas...
FUNCTION BtnBar5( nBar, oBar, aBtnBar, oDlg )
DEFINE BUTTONBAR oBar BUTTONSIZE 70, 50 _3DLOOK TOP OF oDlg 2007
WITH OBJECT oBar
oBar:Refresh()
oBar:bClrGrad := aPubGrad
oBar:bRClicked := { || NIL }
oBar:bLClicked := { || NIL }
oBar:SetFont( oFont )
oBar:nClrText := CLR_HBLUE
oBar:Adjust()
END
DEFINE BUTTON aBtnBar[1] OF oBar PROMPT "New " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\open.bmp" WHEN( lLigaBtn1 )
DEFINE BUTTON aBtnBar[2] OF oBar PROMPT "Modify " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\floppy.bmp" WHEN( lLigaBtn2 )
DEFINE BUTTON aBtnBar[3] OF oBar PROMPT "Duplicate" NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\HelpInd.bmp" WHEN( lLigaBtn3 )
DEFINE BUTTON aBtnBar[4] OF oBar PROMPT "Delete " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\open.bmp" WHEN( lLigaBtn4 )
DEFINE BUTTON aBtnBar[5] OF oBar PROMPT "Print " NOBORDER GROUP ;
FILENAME "..\bitmaps\16x16\printer.bmp" WHEN( lLigaBtn5 )
// Botones OFF ? Ninguno.
lLigaBtn1 := .T.
lLigaBtn2 := .T.
lLigaBtn3 := .T.
aBtnBar[1]:Show()
aBtnBar[2]:Show()
aBtnBar[3]:Show()
aBtnBar[1]:Refresh()
aBtnBar[2]:Refresh()
aBtnBar[3]:Refresh()
// botones ON
lLigaBtn4 := .T.
lLigaBtn5 := .T.
aBtnBar[4]:Show()
aBtnBar[5]:Show()
aBtnBar[4]:Refresh()
aBtnBar[5]:Refresh()
RETURN NIL
FUNCTION xFocus( oObj )
xSetFocus( oObj )
xSetFocus( oObj )
RETURN( .T. )
FUNCTION xSetFocus( oObj )
LOCAL _oWnd := oObj:oWnd, _oTempo := ""
DEFINE TIMER _oTempo INTERVAL 10 OF _oWnd ;
ACTION ( oObj:SetFocus(), _oTempo:End() )
ACTIVATE TIMER _oTempo
RETURN( .T. )
// FIN / END - kapiabafwh@gmail.com
Regards, saludos.