// \samples\CORSAY2.PRG - For apprentices. Swap colors.
#Include "FiveWin.ch"
STATIC oSay1, oSay2, oSay3, oSay4, oSay5, oSay6
STATIC oDlg, oFont1
FUNCTION Main()
LOCAL cTitle
cTitle := "Colors - CLICK WITH THE RIGHT MOUSE BUTTON"
DEFINE FONT oFont1 NAME "MS Sans Serif" SIZE 0, - 24
DEFINE DIALOG oDlg TITLE cTitle FROM 0, 0 TO 400, 700 PIXEL ;
COLOR 0, 16777215 TRANSPARENT
oDlg:lHelpIcon := .F.
ACTIVATE DIALOG oDlg ON INIT Inicio() CENTERED
oFont1:End()
RETURN NIL
FUNCTION Inicio()
@ 20, 22 SAY oSay1 VAR "Text Color:" SIZE 152, 24 PIXEL ;
OF oDlg COLOR 0, 16777215 FONT oFont1
@ 20, 209 SAY oSay2 VAR "0" SIZE 142, 28 PIXEL;
OF oDlg COLOR 0, 16777215 FONT oFont1
@ 20, 371 SAY oSay3 VAR RRGB( 0 ) SIZE 200, 28 PIXEL ;
OF oDlg COLOR 0, 16777215 FONT oFont1
@ 80, 20 SAY oSay4 VAR "Window Color:" SIZE 175, 33 PIXEL ;
OF oDlg COLOR 0, 16777215 FONT oFont1
@ 80, 209 SAY oSay5 VAR "0" SIZE 141, 39 PIXEL ;
OF oDlg COLOR 0, 16777215 FONT oFont1
@ 80, 371 SAY oSay6 VAR RRGB( 0 ) SIZE 200, 39 PIXEL ;
OF oDlg COLOR 0, 16777215 FONT oFont1
// Right click
oDlg:bRClicked := {| nRow, nCol | RPopup( nRow, nCol, oDlg, { oSay1, oSAy2, oSay3, oSay4, oSay5, oSay6 } ) }
RETURN NIL
FUNCTION RPopup( nRow, nCol, oDlg, aSays )
LOCAL oMenu
oMenu := MenuPopUp( oDlg, aSays )
ACTIVATE POPUP oMenu WINDOW oDlg AT nRow, nCol
RETURN NIL
FUNCTION MenuPopUp( oDlg, aSays )
LOCAL oMenu
LOCAL nClrTxt := oSay1:nClrText
LOCAL nClrDlg := oDlg:nClrPane
MENU oMenu PopUp
MenuItem "Text Color" ;
Action ( nClrTxt := ChooseColor( nClrTxt ), ;
AplicaCores( oDlg, aSays, nClrTxt, nClrDlg ) )
MenuItem "Window Color" ;
Action( nClrDlg := ChooseColor( nClrDlg ), ;
AplicaCores( oDlg, aSays, nClrTxt, nClrDlg ) )
ENDMENU
RETURN( oMenu )
FUNCTION AplicaCores( oDlg, aSays, nClrTxt, nClrDlg )
LOCAL i, cRgbTxt, cRgbDlg
oDlg:SetColor( nClrTxt, nClrDlg )
oDlg:Refresh()
FOR i := 1 TO 6
SysRefresh()
aSays[ i ]:SetColor( nClrTxt, nClrDlg )
aSays[ i ]:Refresh()
NEXT
cRgbTxt := RRGB( nClrTxt )
cRgbDlg := RRGB( nClrDlg )
aSays[ 2 ]:SetText( nClrTxt )
aSays[ 3 ]:SetText( cRgbTxt )
aSays[ 5 ]:SetText( nClrDlg )
aSays[ 6 ]:SetText( cRgbDlg )
RETURN NIL
FUNCTION RRGB( nCor )
LOCAL cRGB := "{ " + StrZero( nRGBRed( nCor ), 3 ) + ", " + ;
StrZero( nRGBGreen( nCor ), 3 ) + ", " + ;
StrZero( nRGBBlue( nCor ), 3 ) + " }"
RETURN( cRGB)
// FIN / END