FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to change background color of Groupbox?
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
How to change background color of Groupbox?
Posted: Thu Jun 28, 2012 01: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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to change background color of Groupbox?
Posted: Fri Jun 29, 2012 08: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.
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to change background color of Groupbox?
Posted: 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
        [/*:m][/list:u]
        [/*:m][/list:u]

        • Groupbox

          • Browse
            [/*:m][/list:u]
            [/*:m][/list:u]

            • Groupbox

              • Get
                [/*:m]
              • Button
                [/*:m][/list:u]
                [/*:m][/list:u]

                • Groupbox

                  • Say
                    [/*:m]
                  • Button
                    [/*:m][/list:u]
                    [/*:m][/list:u][/*:m][/list:u]
Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to change background color of Groupbox?
Posted: Mon Jul 02, 2012 11:31 AM

Anyone?

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to change background color of Groupbox?
Posted: Mon Jul 02, 2012 05: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





The button
switch between group transparent and red
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 :-)
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.
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to change background color of Groupbox?
Posted: Mon Jul 02, 2012 07: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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to change background color of Groupbox?
Posted: Mon Jul 02, 2012 08: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





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.
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to change background color of Groupbox?
Posted: Tue Jul 03, 2012 12:59 PM
Solved using:
Code (fw): Select all Collapse
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
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to change background color of Groupbox?
Posted: Tue Jul 03, 2012 02:39 PM
Samir,

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



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.
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: How to change background color of Groupbox?
Posted: Tue Jul 03, 2012 03: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

Continue the discussion