How to change background color of Groupbox?

How to change background color of Groupbox?

Postby sambomb » Thu Jun 28, 2012 1:08 pm

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.
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to change background color of Groupbox?

Postby ukoenig » Fri Jun 29, 2012 8:02 am

I just finished another problem and will have a look, to create a sample from my archive for You.
Do You want both tests, from code and resource also showing a groupbox inside a folder or
using dialog nowait ?

Best Regards
Uwe :?:
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: How to change background color of Groupbox?

Postby sambomb » Fri Jun 29, 2012 11:50 am

Ukoenig, I use resource, don't use folder. So if you want just show a sample with Resource without folder it'll be faster.
Here is what I use:
  • Dialog
    • Groupbox
      • Say
    • Groupbox
      • Browse
    • Groupbox
      • Get
      • Button
    • Groupbox
      • Say
      • Button
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to change background color of Groupbox?

Postby sambomb » Mon Jul 02, 2012 11:31 am

Anyone?
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to change background color of Groupbox?

Postby ukoenig » Mon Jul 02, 2012 5:47 pm

I did some tests,

it could work, but there is a lot to change.
I will place a screenshot of the result and explain the problems.

Results of my first tests :

You can switch between transparent and color.
But filling a group with a color just fills the space around a resource.
like You can see with the text and checkbox, the space between the text
and defined resource-area is not filled.
The radios, I didtn't work on with this test.

But maybe it helps, for the basics.
the problems are the text, radios and checkboxes

Image

Image

The button
switch between group transparent and red
Code: Select all  Expand view

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"
 


The resource
Code: Select all  Expand view

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
 


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: How to change background color of Groupbox?

Postby sambomb » Mon Jul 02, 2012 7:51 pm

Uwe, thanks for reply, but in 10.6 it didn't work, what is your version?

PS.: In my dialog the groups start with the default color and at a point in my program I change the color and after press a button I revert to the default
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to change background color of Groupbox?

Postby ukoenig » Mon Jul 02, 2012 8:10 pm

Samir,

I think You just want to show the user, some values have been used for a process ?
Why not just painting a box around and changing the color of the box ( just a idea )
As well I can zip the groupfiles for download. Just up to You.

The Box-solution.
very easy to use
switch between box on / off
works on resources
no transparent problem
any color and pensize

Download 800 KB ( Group- and Box-test ) Exe and Prg
http://www.pflegeplus.com/fw_download/grouptest.zip

Image

Image

Best Regards
Uwe :?:




Best Regards
Uwe :?:
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: How to change background color of Groupbox?

Postby sambomb » Tue Jul 03, 2012 12:59 pm

Solved using:
Code: Select all  Expand view


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
 
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil

Re: How to change background color of Groupbox?

Postby ukoenig » Tue Jul 03, 2012 2:39 pm

Samir,

filling the dialog-area of the group works, but there is a transparent-painting-problem,
does it work with Your tests ?

Image

Best Regards
Uwe :?:
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: How to change background color of Groupbox?

Postby sambomb » Tue Jul 03, 2012 3:11 pm

Uwe i'm trying an workaround right now... I want to change the back color of the Say in runtime, i'll not use gradient color so the Dialog and the Say will be the same color and will do what I need
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
User avatar
sambomb
 
Posts: 388
Joined: Mon Oct 13, 2008 11:26 am
Location: Itaocara - RJ - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 108 guests