I want to change the background color of a groupbox and after click on a button return to transparent.
PS.: I have many types of controls inside the groupbox, Say, Browse, Get, Button. And then must be over the background color of the groupbox.
DEFINE BUTTON oButt3 OF oBar FILE c_path + "\project\Switch.BMP" ;
MESSAGE "Switch" ;
ACTION ( oGrp1:lTransparent := .F., ;
oGrp2:lTransparent := .F., ;
oGrp3:lTransparent := .F., ;
oGrp4:lTransparent := .F., ;
oGrp5:lTransparent := .F., ;
oSay1:lTransparent := .F., ;
oCheck1:lTransparent := .F., ;
oGrp1:SetColor( 0, 128 ), ;
oGrp2:SetColor( 0, 128 ), ;
oGrp3:SetColor( 0, 128 ), ;
oGrp4:SetColor( 0, 128 ), ;
oGrp5:SetColor( 0, 128 ), ;
oDlg1:Refresh() ) ;
PROMPT "Switch"
FUNCTION D_RESOURCE()
LOCAL lCheck1 := .T., nRadio1 := 1
LOCAL oDlgFont := TFont():New("Arial",,-12,.F.,.F.,,,,.F.)
DEFINE DIALOG oDlg1 RESOURCE "Group" TITLE "Dialog-test" FONT oDlgFont ;
PIXEL // TRANSPARENT
REDEFINE GROUP oGrp1 ID 100 OF oDlg1 ;
FONT oDlgFont PROMPT "Group" PIXEL
oGrp1:lTransparent := .T.
REDEFINE SAY oSay1 PROMPT "Test SAY" ID 110 OF oDlg1
oSay1:SetColor( 0, 128 )
oSay1:lTransparent := .T.
REDEFINE GROUP oGrp2 ID 200 COLOR 0, 128 OF oDlg1 ;
FONT oDlgFont PROMPT "Group" PIXEL
oGrp2:lTransparent := .T.
REDEFINE RADIO oRadio1 VAR nRadio1 ID 210, 211, 212 OF oDlg1 UPDATE
AEval( oRadio1:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oDlgFont ), ;
oRad:SetColor( 0,128 ) } )
REDEFINE GROUP oGrp3 ID 300 COLOR 0, 128 OF oDlg1 ;
FONT oDlgFont PROMPT "Group" PIXEL
oGrp3:lTransparent := .T.
REDEFINE GROUP oGrp4 ID 400 COLOR 0, 128 OF oDlg1 ;
FONT oDlgFont PROMPT "Group" PIXEL
oGrp4:lTransparent := .T.
REDEFINE GROUP oGrp5 ID 500 COLOR 0, 128 OF oDlg1 ;
FONT oDlgFont PROMPT "Group" PIXEL
oGrp5:lTransparent := .T.
REDEFINE CHECKBOX oCheck1 VAR lCheck1 ID 510 OF oDlg1 UPDATE
oCheck1:SetColor( 0, 128 )
oCheck1:lTransparent := .T.
ACTIVATE DIALOG oDlg1 CENTERED NOWAIT ;
ON INIT ( GradBrush( oDlg1, { { 0.50, 14853684, 16314573 }, ;
{ 0.50, 16314573, 14853684 } }, .T. ) )
oDlgFont:End()
oBar:Show()
RETURN NIL
// -------------------------------
FUNCTION GradBrush( oDlg, aColors, lPos )
local hDC, hBmp, hBmpOld, oBrush
if Empty( oDlg:oBrush:hBitmap )
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aColors, lPos )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
RETURN NIL
oDlg:bPainted := {|| SetColorGrp(1,.T.)) }
oDlg:Refresh()
Function SetColorGrp( i , lAux)
aRect := GetCoors( oGrp[i]:hWnd )
aRect[01]+=6
aRect[03]-=4
If lAux
Gradient( oDlg:hDC, aRect, nRgb(255,200,200), nRgb(200,0,0), .t. )
else
Gradient( oDlg:hDC, aRect, nRgb(255,255,255), nRgb(200,200,200), .t. )
end
Return
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 28 guests