Inclomplete Group using Dialog TRANSPARENT Color-Brush ?

Inclomplete Group using Dialog TRANSPARENT Color-Brush ?

Postby ukoenig » Mon Nov 28, 2011 2: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
Image

COLOR-brush with Text, Checkbox and Radio
Image

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

BMP-Brush :
Image

Image-Brush
Image

Using DIALOG without TRANSPARENT a closed frame is shown :

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

Image

A sample for testing :

Code: Select all  Expand view

#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:oBrush: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 ???

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: Inclomplete Group using Dialog TRANSPARENT Color-Brush ?

Postby Antonio Linares » Mon Nov 28, 2011 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Inclomplete Group using Dialog TRANSPARENT Color-Brush ?

Postby ukoenig » Mon Nov 28, 2011 6: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 :

Image

#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

Image

#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.
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 49 guests