FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Inclomplete Group using Dialog TRANSPARENT Color-Brush ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Inclomplete Group using Dialog TRANSPARENT Color-Brush ?
Posted: Mon Nov 28, 2011 02:02 PM
Hello,

I noticed a painting Problem using Groups on Dialog COLOR - brush.
Gradient, Bmp-Brush and Image works fine.

COLOR-brush only using Text


COLOR-brush with Text, Checkbox and Radio


GRADIENT-brush ( Color 1 and 2 are the same )
with Text, Checkbox and Radio


BMP-Brush :


Image-Brush


Using DIALOG without TRANSPARENT a closed frame is shown :

DEFINE DIALOG oDlg TITLE "TRANSPARENT Grouptest" ;
FROM 0,0 TO 350, 500 PIXEL // TRANSPARENT



A sample for testing :

Code (fw): Select all Collapse
#INCLUDE "FIVEWIN.CH"

FUNCTION MAIN()
local oDlg, oGrp, oFont, oGroup, Brush, hDC
local oCheck, lCheck := .T., oRadio, nOption := 1, oSay
local c_path := CURDRIVE() + ":\" + GETCURDIR() 
local cDBrush := "Granite.Bmp"
local cDImage := "Fantasy2.Jpg"

DEFINE FONT oFont NAME "Arial" SIZE 0, -16

DEFINE DIALOG oDlg TITLE "TRANSPARENT Grouptest" ;
FROM 0,0 TO 350, 500 PIXEL TRANSPARENT

// COLOR shows a incomplete Group !!!
// --------------------------------------------
//DEFINE BRUSH oBrush COLOR 8404992

// GRADIENT-Brush
// -------------------
aGrad := { { 1, 8404992, 8404992 }, { 1, 8404992, 8404992 } }
hDC = CreateCompatibleDC( oDlg:GetDC() )
hBmp = CreateCompatibleBitMap( oDlg:hDC, 878, 692 ) // Get Width and Height from INIT !!!
hBmpOld = SelectObject( hDC, hBmp )
GradientFill( hDC, 0, 0, 692, 878, aGrad )
DeleteObject( oDlg:hBrush )
oBrush := TBrush():New( ,,,, hBmp )
oBrush:Cargo  := aGrad
SelectObject( hDC, hBmpOld )
ReleaseDC(hDC)

// BMP-BRUSH
// --------------
//DEFINE BRUSH oBrush FILE c_path + "\Images\" + cDBrush

// Image-Brush ADJUSTED
// ----------------------------
//DEFINE IMAGE oImage FILE c_path + "\Images\" + cDImage
//oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, 500, 350, .T. ) ) 
//oImage:End()

oDlg:Setbrush( oBrush )

@ 30, 40 GROUP oGroup TO 130, 210;
PROMPT "Transparent Group" ;
OF oDlg FONT oFont PIXEL
oGroup:SetColor( 65535, )

@ 50, 50 CHECKBOX oCheck VAR lCheck ;
PROMPT "&Check" SIZE 50, 12 OF oDlg PIXEL 
oCheck:SetColor( 65535, )
oCheck:SetFont( oFont )

@ 70, 50 RADIO oRadio VAR nOption OF oDlg ;
ITEMS "&One", "&Two", "T&hree" _3D SIZE 50, 12 PIXEL ;
HELPID 100, 101, 102 ;
ON CHANGE MsgBeep()
AEval( oRadio:aItems, { | oRad | oRad:SetFont ( oFont ), ;
                                 oRad:nClrText := 65535 } )

@ 50, 100 SAY oSay PROMPT "Transparent Text"  OF oDlg PIXEL ;
FONT oFont ;
SIZE 100, 12 COLOR 65535

ACTIVATE DIALOG oDlg CENTERED

oFont:End()
oBrush:End()

RETURN NIL


I did some Changes on my Code / Resource - Test-tool
Now each Folder-page shows a different Brush.
The unused Space could be used, to include some more Tests / Controls.
Any useful Extensions ???



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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Inclomplete Group using Dialog TRANSPARENT Color-Brush ?
Posted: Mon Nov 28, 2011 04:36 PM

Uwe,

This line is wrong:

DeleteObject( oDlg:oBrush:hBrush )

as brushes are shared GDI objects in FWH, and we can be destroying a brush that still is used from other controls.

The right way is:

oDlg:oBrush:End()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Inclomplete Group using Dialog TRANSPARENT Color-Brush ?
Posted: Mon Nov 28, 2011 06:07 PM
Antonio,

thank You very much for the Info.

I found the Reason of the Group-painting-problem.
( Again the Group-position inside the code but only using Colors.
For Gradient, BMP-brush and Image, the Group must be placed before the other Controls.
( The Reason is not Dialog transparent or the embedded Controls )

This little sample shows the Problem :



#INCLUDE "FIVEWIN.CH"

FUNCTION MAIN()
local oDlg, oGrp, oFont, oGroup, Brush
local oCheck, lCheck := .T., oRadio, nOption := 1, oSay

DEFINE FONT oFont NAME "Arial" SIZE 0, -16

DEFINE DIALOG oDlg TITLE "TRANSPARENT Grouptest" ;
FROM 0,0 TO 350, 500 PIXEL TRANSPARENT

DEFINE BRUSH oBrush COLOR 8404992

// Position WRONG using Color !!!

@ 30, 40 GROUP oGroup TO 130, 210 ;
PROMPT "Transparent Group" ;
OF oDlg FONT oFont PIXEL
oGroup:SetColor( 65535, )


@ 50, 50 CHECKBOX oCheck VAR lCheck ;
PROMPT "&Check" SIZE 50, 12 OF oDlg PIXEL
oCheck:SetColor( 65535, )
oCheck:SetFont( oFont )

@ 70, 50 RADIO oRadio VAR nOption OF oDlg ;
ITEMS "&One", "&Two", "T&hree" _3D SIZE 50, 12 PIXEL ;
HELPID 100, 101, 102 ;
ON CHANGE MsgBeep()
AEval( oRadio:aItems, { | oRad | oRad:SetFont ( oFont ), ;
oRad:nClrText := 65535 } )

@ 50, 110 SAY oSay PROMPT "Transparent Text" OF oDlg PIXEL ;
FONT oFont ;
SIZE 90, 12 COLOR 65535

oDlg:Setbrush( oBrush )

ACTIVATE DIALOG oDlg CENTERED

oFont:End()
oBrush:End()

RETURN NIL



#INCLUDE "FIVEWIN.CH"

FUNCTION MAIN()
local oDlg, oGrp, oFont, oGroup, Brush
local oCheck, lCheck := .T., oRadio, nOption := 1, oSay

DEFINE FONT oFont NAME "Arial" SIZE 0, -16

DEFINE DIALOG oDlg TITLE "TRANSPARENT Grouptest" ;
FROM 0,0 TO 350, 500 PIXEL TRANSPARENT

DEFINE BRUSH oBrush COLOR 8404992

@ 50, 50 CHECKBOX oCheck VAR lCheck ;
PROMPT "&Check" SIZE 50, 12 OF oDlg PIXEL
oCheck:SetColor( 65535, )
oCheck:SetFont( oFont )

@ 70, 50 RADIO oRadio VAR nOption OF oDlg ;
ITEMS "&One", "&Two", "T&hree" _3D SIZE 50, 12 PIXEL ;
HELPID 100, 101, 102 ;
ON CHANGE MsgBeep()
AEval( oRadio:aItems, { | oRad | oRad:SetFont ( oFont ), ;
oRad:nClrText := 65535 } )

@ 50, 110 SAY oSay PROMPT "Transparent Text" OF oDlg PIXEL ;
FONT oFont ;
SIZE 90, 12 COLOR 65535

// Position OK using Color !!!

@ 30, 40 GROUP oGroup TO 130, 210 ;
PROMPT "Transparent Group" ;
OF oDlg FONT oFont PIXEL
oGroup:SetColor( 65535, )


oDlg:Setbrush( oBrush )

ACTIVATE DIALOG oDlg CENTERED

oFont:End()
oBrush:End()

RETURN NIL
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.

Continue the discussion