Bug in brush gradient?

Bug in brush gradient?

Postby Enrico Maria Giordano » Wed Jul 06, 2011 6:42 am

Another erratic problem: sometimes the dialog with the gradient suddenly becomes transparent (never saw under XP, only under Vista and Win7). Any ideas?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in brush gradient?

Postby nageswaragunupudi » Wed Jul 06, 2011 7:44 am

Can you make it more clear please? Does the dialog suddenly behave like a transparent dialog? Or the entire dialog becomes transparent showing the background behind the dialog like when using null brush?

Can you post a sample code?
Regards

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

Re: Bug in brush gradient?

Postby Enrico Maria Giordano » Wed Jul 06, 2011 9:43 am

nageswaragunupudi wrote:Can you make it more clear please? Does the dialog suddenly behave like a transparent dialog? Or the entire dialog becomes transparent showing the background behind the dialog like when using null brush?


Yes, like null brush.

nageswaragunupudi wrote:Can you post a sample code?


Sorry, no. The problem is erratic. I can't reproduce it consistently in a sample.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in brush gradient?

Postby ukoenig » Wed Jul 06, 2011 10:10 am

Enrico,

I'm using VISTA.
I changed my Background-function and it works on Windows and Dialogs without Problem.
As well it works perfect together with TFolderex-tabs.

Maybe have a look at it ( extra Gradient-function ).

Code: Select all  Expand view

//--------- Backgrounds ------------------------

// c_path := CURDRIVE() + ":\" + GETCURDIR()

// Samples :

// ACTIVATE WINDOW oWnd MAXIMIZED ;
// ON INIT WND_BRUSH( oWnd, ; // Object to fill
// nWStyle, ; // 1=Color, 2=Gradient, 3=Brush, 4=Image, 5-7= Pred.-styles
// lWGrad, ; // .T. = vertical, .F. = horizontal
// nWColorF, ; // 1.Gradient- or plain Color with Style = 1
// nWColorB, ; // 2. Gradient-color
// nWGradPos, ; // Color-position 0 - 1
// cWBrush, ; // Brush
// cWImage ) // Image

// Embedded inside the Dialog, can be changed at Runtime
//
// DEFINE DIALOG oDlg SIZE 950, 600 OF oWnd PIXEL TRANSPARENT ;
// FONT oFont1 TITLE 'Title / xBrowse and Border'
//
// for Brush and Image only Filename, no Path
// WND_BRUSH( oDlg, nDStyle, lDGrad, nDColorF, nDColorB, nDPos, cDBrush, cDImage )
//
// ACTIVATE DIALOG oDlg CENTERED NOWAIT ;

FUNCTION WND_BRUSH( cControl, nStyle, lDirect, nVColor, nBColor, nMove, cBrush, cImage )
LOCAL hDC, oBrush, oTmp
LOCAL aRect := GETCLIENTRECT( cControl )
LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }

IF nStyle = 1 // Color
    DEFINE BRUSH oBrush COLOR nVColor
    SET BRUSH OF cControl TO oBrush
    RELEASE BRUSH oBrush
ENDIF
IF nStyle = 2 // Gradient
    hDC = CreateCompatibleDC( cControl:GetDC() )
    hBmp = CreateCompatibleBitMap( cControl:hDC, cControl:nWidth, cControl:nHeight )
    hBmpOld = SelectObject( hDC, hBmp )
    GradientFill( hDC, 0, 0, cControl:nHeight, cControl:nWidth, aGrad, lDirect )
    DeleteObject( cControl:oBrush:hBrush )
    oBrush := TBrush():New( ,,,, hBmp )
    oBrush:Cargo  := aGrad
    SelectObject( hDC, hBmpOld )
    cControl:ReleaseDC()
    cControl:SetBrush( oBrush )
    RELEASE BRUSH oBrush
ENDIF
IF nStyle = 3 // BMP-Brush
    IF File( c_path + "\bitmaps\" + cBrush )
        DEFINE BRUSH oBrush FILE c_path + "
\Bitmaps\" + cBrush
        SET BRUSH OF cControl TO oBrush
        RELEASE BRUSH oBrush
    ELSE
        MsgAlert( "
Cannot load : " + CRLF + ;
                 c_path + "
\bitmaps\" + cDBrush, "Error" )  
    ENDIF
ENDIF
IF nStyle = 4 // Image
    IF File( c_path + "
\bitmaps\" + cImage )
        DEFINE BRUSH oBrush FILE c_path + "
\Bitmaps\" + cImage
        SET BRUSH OF cControl TO oBrush
        RELEASE BRUSH oBrush
    ELSE
        MsgAlert( "
Cannot load : " + CRLF + ;
                 c_path + "
\bitmaps\" + cDImage, "Error" )  
    ENDIF
ENDIF
IF nStyle = 5   // Style 1
    DEFINE BRUSH oBrush STYLE BORLAND
    SET BRUSH OF cControl TO oBrush
        RELEASE BRUSH oBrush
ENDIF
IF nStyle = 6   // Style 2
    DEFINE BRUSH oBrush STYLE BRICKS
    SET BRUSH OF cControl TO oBrush
        RELEASE BRUSH oBrush
ENDIF
IF nStyle = 7   // Style 3
    DEFINE BRUSH oBrush STYLE TILED
    SET BRUSH OF cControl TO oBrush
        RELEASE BRUSH oBrush
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bug in brush gradient?

Postby Enrico Maria Giordano » Wed Jul 06, 2011 11:10 am

ukoenig wrote:Enrico,

I'm using VISTA.
I changed my Background-function and it works on Windows and Dialogs without Problem.


Yes, I know. I'm unable to reproduce the problem too. But my clients do and they sent me a screenshot of the problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in brush gradient?

Postby Antonio Linares » Wed Jul 06, 2011 7:11 pm

Enrico,

Please post the screenshot if possible, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42085
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Re: Bug in brush gradient?

Postby nageswaragunupudi » Thu Jul 07, 2011 3:50 pm

Mr. EMG

Can we also know the FWH version used to build the application?
I expect that the brush was created in the ON INIT clause using the logic that was popular till gradient brushes were introduced.

I have a feeling that the way the gradient brushes were created in the init clause and the way the TBrush class compares a new brush with earlier brushes sometimes could result in destruction of the previous gradient brush.

Can we also see a sample that shows your usual way of creating the gradient brush in the init clause?

I *think* the present implementation of gradient/image brushes would not have such a problem.
Regards

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

Re: Bug in brush gradient?

Postby Enrico Maria Giordano » Thu Jul 07, 2011 4:28 pm

No, I'm using the present implementation as available in latest FWH release.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in brush gradient?

Postby nageswaragunupudi » Thu Jul 07, 2011 4:36 pm

Enrico Maria Giordano wrote:No, I'm using the present implementation as available in latest FWH release.

EMG

Then we need to do more extensive tests with a number of gradient dialogs in one application. I suggest let us give ourselves some time for this.
Regards

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


Re: Bug in brush gradient?

Postby stefano » Thu Jul 07, 2011 8:04 pm

I do not know if you need to help
I use a gradient (first attempts), and sometimes I was going ...
Then I removed the "IF" and now all ok

STATIC FUNCTION GradBrush( oDlgK,difc,colfinA,colfinB,tgr )
local hDC, hBmp, hBmpOld,obrush

* if Empty( oDlgK:oBrush:hBitmap )
hDC = CreateCompatibleDC( oDlgK:GetDC() )
hBmp = CreateCompatibleBitMap( oDlgK:hDC, oDlgK:nWidth, oDlgK:nHeight )
hBmpOld = SelectObject( hDC, hBmp )
GradColor( hDC, {0, 0, oDlgK:nHeight, oDlgK:nWidth-difc }, colfinA, colfinB,tgr ) // da TSBUTTON
* Gradient( hDC, {0, 0, oDlgK:nHeight, oDlgK:nWidth }, rgb(250, 255, 255),colfinB ,.T. )
DeleteObject( oDlgK:oBrush:hBrush )
oDlgK:oBrush:hBitmap = hBmp
oDlgK:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlgK:ReleaseDC()

* endif

RETURN NIL

Saluti
Stefano
FWH 14.11 + xHarbour + bcc582
stefano
 
Posts: 80
Joined: Tue Mar 25, 2008 9:03 pm
Location: ITALIA



Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 101 guests