Color Fill a GroupBox

Color Fill a GroupBox

Postby Rick Lipkin » Thu May 10, 2012 4:14 pm

To All

I am looking to color fill a groupbox like the screenshot below .. I do want the text to be transparent.

Any help would be appreciated!

Thanks
Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Color Fill a GroupBox

Postby ukoenig » Thu May 10, 2012 5:41 pm

Rick,

it is nor really transparent, just uses the same background-color !

Image

DEFINE DIALOG oDlg1 FROM 30, 30 TO 500, 700 PIXEL ;
FONT oFont TITLE "DIALOG from Code" // TRANSPARENT

D_BACKGRD( oDlg1, nDStyle2, 16642248, 15714367, .F., 0.2, "BluStone.Bmp" , "PICTURE9.jpg" )

Group include
// ------------
//@ <nTop>, <nLeft> GROUP [ <oGroup> ] ;
//[ TO <nBottom>, <nRight> ] ;
//[ <label:LABEL,PROMPT> <cLabel> ] ;
//[ OF <oWnd> ] ;
//[ COLOR <nClrFore> [,<nClrBack>] ] ;
//[ <lPixel: PIXEL> ] ;
//[ <lDesign: DESIGN> ] ;
//[ FONT <oFont> ] ;
//[ <lTransparent: TRANSPARENT> ] ;
//[ SIZE <nWidth>, <nHeight> ] ;

@ 15, 15 GROUP oGrp1 TO 200, 300 PIXEL ;
PROMPT "Group" OF oDlg1
oGrp1:oFont := oFont
oGrp1:SetColor( 128, 16642248 )

@ 100, 50 SAY oSay1 PROMPT "Transparent Text-test" OF oDlg1 PIXEL UPDATE ;
FONT oFont ;
SIZE 100, 12 COLOR 128, 16642248
// oSay1:lTransparent := .T.

// radio and checkbox works the same
@ 135, 50 RADIO oRadio VAR nRadio1 ITEMS "One", "Two", "Three" OF oDlg1 ;
SIZE 50, 13 PIXEL COLOR 128, 16642248

// @ 135, 120 CHECKBOX oChk1 VAR lChk1 PROMPT "Checkbox" OF oDlg1 PIXEL COLOR 128, 16642248

ACTIVATE DIALOG oDlg1 ;
ON INIT ( oDlg1:Move( 60, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) )

RETURN NIL

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Color Fill a GroupBox

Postby Rick Lipkin » Thu May 10, 2012 6:49 pm

Uwe

Thank you for your quick response .. I am using a SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } ) to paint my dialogs ..

I take it

D_BACKGRD( oDlg1, nDStyle2, 16642248, 15714367, .F., 0.2, "BluStone.Bmp" , "PICTURE9.jpg" )

is a user defined function that paints a brush and the color goes over the top of the brush ?

Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Color Fill a GroupBox

Postby ukoenig » Thu May 10, 2012 6:54 pm

Rick,

it is a Dialog-background-function, to change a background at runtime ( works as well on Windows ) :
nStyle defines : 1 = color, 2 = gradient, 3 = BMP-brush and 4 = Image

nStyle := 1 // Color ( can be canged at runtime )
nDColorF := 16642248 // 1. Gradient-color or Color
nDColorB := 15714367 // 2. Gradient-color
lDDirect := .T. // Gradient-direction .T. = Vertical
nDGradPos := 0.2 // Gradient-position
cDBrush := "BluStone.Bmp" // Bmp-brush
cDImage := "Fantasy2.Jpg" // Image


can be used on Dialogs => ON INIT :

ACTIVATE DIALOG oDlg1 ;
ON INIT ( D_BACKGRD( oDlg1, nStyle, nDColorF, nDColorB, ;
lDDirect, nDGradpos, cDBrush, cDImage ),
;
oDlg1:Move( 60, 30, oDlg1:nWidth, oDlg1:nHeight, .f. ) )

c_path defines the Aplication-path :
c_path := GETCURDIR()
// in older FWH-versions => c_path := CURDRIVE() + ":\" + GETCURDIR()

A Sample changing the Background :

@ 200, 8 SELEX oSelect VAR nSelect SIZE 125, 30 OF oDlg1 PIXEL ;
ITEMS "&Color", "&Grad.", "Brush", "&Image";
GRADIENT OUTTRACK { { 0.5, 16443068, 16312263 }, { 0.5, 16312263, 16443068 } } ;
GRADIENT INTRACK { { 1, 5426223, 1071100 }, { 1, 1071100, 5426223 } } ;
THUMBSIZE 20, 20 ROUNDSIZE 5 ;
COLOR THUMB 14853684 ;
COLORTEXT 128, 32768 ;
TITLE "Select Dlg-Background" TOP ;
FONT oBrwFont ;
ACTION( nStyle := oSelect:nOption, ;
D_BACKGRD( oDlg1, nStyle, nDColorF, nDColorB, lDDirect, nDGradPos, cDBrush, cDImage))


Code: Select all  Expand view

// --------  DIALOG - Background ---------------

FUNCTION D_BACKGRD( oDlg, nStyle, nColor1, nColor2, lDirect, nMove, cBrush, cImage)
Local oBrush

IF nStyle = 1
    DEFINE BRUSH oBrush COLOR nColor1
ENDIF
IF nStyle = 2
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    hDC = CreateCompatibleDC( oDlg:GetDC() )
    // Get Width and Height from INIT !!!
    hBmp = CreateCompatibleBitMap( oDlg:hDC, oDlg:nWidth, oDlg:nHeight )
    hBmpOld = SelectObject( hDC, hBmp )
    GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, lDirect )
    DeleteObject( oDlg:oBrush:hBrush )
    oBrush := TBrush():New( ,,,, hBmp )
    oBrush:Cargo  := aGrad
    SelectObject( hDC, hBmpOld )
    ReleaseDC(hDC)
ENDIF
IF nStyle = 3
    DEFINE BRUSH oBrush FILE c_path + "\Images\" + cBrush
ENDIF
IF nStyle = 4
    DEFINE IMAGE oImage FILE c_path + "
\Images\" + cImage
    // Get Width and Height from INIT !!!
    oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, oDlg:nWidth, oDlg:nHeight, .T. ) )
    oImage:End()
ENDIF

oDlg:SetBrush( oBrush )
oBrush:End()

RETURN( NIL )


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 103 guests