Radio background

Radio background

Postby Gary Woodley » Fri Jul 17, 2009 12:45 pm

Hi,

I have created a dialog box with customer selectable gradient colors. When radio buttons are being used the backround color refuses to go transparent so displays a white square surrounding the button. I have tried AEval( oMyRadio:aItems, { | oRad | oRad:lTransparent := .T. } ) but this seems to have no effect.

Have read through loads of posts but am rather confused on exactly what i need to use to fix the problem.

Any ideas?

Regards

Gary
Gary Woodley
 
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Re: Radio background

Postby nageswaragunupudi » Fri Jul 17, 2009 1:54 pm

Please see gradbrus.prg in fwh\samples folder.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Radio background

Postby ukoenig » Fri Jul 17, 2009 2:13 pm

A Test with all Controls :
( Buttonbar, Alpha-Blended Logo, Say, Radio and Checkbox )

Image

Code: Select all  Expand view

FUNCTION DLGTEST(oDlg,oFont)
LOCAL nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION )
LOCAL oSay, oRadio, oCheck
LOCAL nRadio := 1, lCheck := .F.
LOCAL aGrad := { { 0.50, 8388608, 16777215 }, { 0.50, 16777215, 8388608 } }
LOCAL oSayFont := TFont():New("Arial", ,-18,.F.,.T. , , , ,.F. )
LOCAL oRadioFont := TFont():New("Arial", ,-16,.F.,.T. , , , ,.F. )

DEFINE DIALOG oDlg RESOURCE "Test_Dlg" STYLE nSTYLE TRANSPARENT ;
TITLE  "Testing Dialog-Backgrounds" FONT oFont

REDEFINE SAY oSay prompt "This is a Transparent-Test" ID 110  of oDlg ;
COLOR 128 PIXEL TRANSPARENT ADJUST
oSay:SetFont(oSayFont)

REDEFINE RADIO oRadio VAR nRadio ID 120,121 OF oDlg
AEval( oRadio:aItems, { | oRad | oRad:lTransparent := .T. } )
oRadio:SetFont( oRadioFont )

REDEFINE CHECKBOX oCheck VAR lCheck ID 210 OF oDlg
oCheck:lTransparent := .T.
oCheck:oFont := oRadioFont

ACTIVATE DIALOG oDlg CENTERED  ;
ON INIT ( DLG_BAR( oDlg ), ;
   GradBrush( oDlg, aGrad, .T. ) ) ;  
ON PAINT D_ALPHA( hDC )

oSayFont:End()
oRadioFont:End()

RETURN ( NIL )

// -------------------------------------------------------

FUNCTION DLG_BAR( oDlg )
LOCAL oBar, oBtn50, oBtn51, oBtn52, oBtn53, oBtn54, oBtn55, oBtn56, oBtn57, oBtn58

DEFINE BUTTONBAR oBar OF oDlg  SIZE 80, 80 2007 TOP

oBar:bClrGrad :=  { | lInvert | If( ! lInvert, ;
        { { 0.90,11892819,16777215 },{ 0.90,16777215,11892819 } },;
        { { 0.50,128,16777215 }, { 0.50,16777215,128 } } ) }

oBar:nClrText := 0

DEFINE BUTTON oBtn50 OF oBar ACTION  MsgAlert( "Test", "Test" )  ;
FILE  c_path + "\images\Info.bmp"  TOOLTIP  "Test"

DEFINE BUTTON oBtn51 OF oBar ACTION  MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Tools.bmp"  TOOLTIP  "Test"

DEFINE BUTTON oBtn52 OF oBar ACTION  MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Word.bmp"  TOOLTIP  "Test"

DEFINE BUTTON oBtn53 OF oBar ACTION MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Excel.bmp" TOOLTIP  "Test"

DEFINE BUTTON oBtn54 OF oBar ACTION MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\View.bmp" TOOLTIP  "Test"

DEFINE BUTTON oBtn55 OF oBar ACTION MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Image.bmp" TOOLTIP  "Test"

DEFINE BUTTON oBtn56 OF oBar ACTION MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Zip.bmp" TOOLTIP  "Test"

DEFINE BUTTON oBtn57 OF oBar ACTION MsgAlert( "Test", "Test" ) ;
FILE  c_path + "\images\Email.bmp" TOOLTIP  "Test"

DEFINE BUTTON oBtn58 OF oBar ACTION oDlg5:End() ;
FILE  c_path + "\images\Quit.bmp" TOOLTIP  "Exit Dialog-Test"

RETURN( NIL )

// - Gradient-Brush (posted in the Forum) lDir added for Horiz./Vert.-Direction --

FUNCTION GradBrush( oDlg, aColors , lDir)
local hDC, hBmp, hBmpOld , nWidth , nHeight

DEFAULT lDir := .T.

if Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
      hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aColors,lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
endif

RETURN NIL

// --------- ALPHA-BMP  --------------------------------------

STATIC FUNCTION D_ALPHA( hDC )
LOCAL oBmp1

DEFINE BITMAP oBmp1 FILENAME c_path + "\images\A_LOGO.BMP"
ABPaint( hDC, 60, 70, oBmp1:hBitmap, 220 )

RETURN NIL
 


Best regards
Uwe :lol:
Last edited by ukoenig on Sat Jul 18, 2009 11:23 am, edited 4 times in total.
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: Radio background

Postby nageswaragunupudi » Fri Jul 17, 2009 9:48 pm

Mr Uwe

Either you should write

REDEFINE RADIO oRadio VAR nVar ID 120,121 OF oDlg
OR
REDEFINE RADIO nVar ID 120,121 OF oDlg

Because your code is "REDEFINE RADIO oRadio ID 120,121 OF oDlg", oRadio is considered as a numeric variable and not as radio object.

If you correct your code, there will be no error.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Radio background

Postby ukoenig » Fri Jul 17, 2009 10:08 pm

Thank You very much,

I added the missing Var's ( for Radio and Checkbox ).
My sample from above works fine now.
I deleted the Errormessage and corrected the Radio- and Checkbox-Lines in the sample above.
Font defines also included now ( Radio is different to Checkbox ) :
oRADIO:SetFont( oRadioFont )
oCheck:oFont := oRadioFont
I still have to look for the Font-Color-defines on Gradient, to make the sample complete.

Before I didn't use :

AEval( oRadio:aItems, { | oRad | oRad:lTransparent := .T. } )
and
oCheck:lTransparent := .T.

Radio and Checkbox without these lines, are shown transparent as well,
like You can see from the screenshot. Maybe because using VISTA, not needed ?
I didn't test with XP.
A few month ago, we have been talking about different results, working with VISTA.

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: Radio background

Postby nageswaragunupudi » Sat Jul 18, 2009 1:51 am

If the dialog is transparent, there is no need to say :lTansparent := .t. for checkboxes and radio buttons. You can remove that code. It works on XP also.

Even the gradbrus.prg in the samples can be modified.

1. Add TRANSPARENT clause to DEFINE DIALOG statement
and
2. Remove all code assigning object:lTransparent := .t.

If this modification is made in the sample, it will be a good guidance to the users.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10313
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Radio background

Postby anserkk » Sat Jul 18, 2009 5:39 am

I agree with Mr.Rao on his opinion,

I was wondering why too much of complications. If we specify the Dialog itself as transparent, then all the controls of the dialog should have its lTransparent property set to .T.

Regards
Anser
User avatar
anserkk
 
Posts: 1331
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Radio background

Postby James Bott » Sun Jul 19, 2009 9:31 pm

>If we specify the Dialog itself as transparent, then all the controls of the dialog should have its lTransparent property set to .T.

Or, I have always wondered why all controls are not transparent by default. I can not think of any situation why I would want them not showing the background of the object that they are on. Maybe someone else can think of a situation?

I am not sure that a dialog should be transparent--this would mean that whatever is behind the dialog would show through. Maybe one would want a percent transparent so a little of the background would show through.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Radio background

Postby ukoenig » Sun Jul 19, 2009 10:29 pm

Hello James,

I started a extended test with a included Folder.
With the Basic-settings of the Dialog, I couldn't define a Color for the Folder.
The Folder shows allways the Gradient from the Dialog.
Maybe all together using Gradients, it is to complex ?.
With different Backgrounds, there is no Problem.
As well it was impossible, to define a Textcolor for Radios and Checkboxes.

Image

After deleting all Transparent-Functions, Dialog and Folder-Gradient is OK.
I could detect, testing step by step, the problem of the Folder-painting.
Using this Function on Dialogs in combination with a Folder ( is needed for transparent SAY ),
the folder is painted transparent and shows the Dialog-Gradient.
It was impossible, to define a Folder-Color.
Maybe it is possible, to exclude the Folder from the Function ?

Code: Select all  Expand view

FUNCTION D_GRAD1( oDlg, aDLG , lDir)
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, aDLG, lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
ENDIF  

RETURN NIL
 


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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests