A problem with GradientBrush()

Re: A problem with GradientBrush()

Postby Enrico Maria Giordano » Thu Feb 04, 2010 8:10 am

Antonio Linares wrote:Enrico,

As far as I understand you, it seems as you want to have dialogs that use the clause TRANSPARENT but have SAYs with colored backgrounds (instead of using "transparent" ones).

Is that what you mean ? thanks

I guess we can easily implement it :-)


Exactly. Actually I need to make non-transparent only one or two controls in a dialog and the rest all transparent. That's why I wrote

Code: Select all  Expand view
AEVAL( oDlg:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oDlg:oBrush ), ) } )


that seems to work for TImage but not for TSay.

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

Re: A problem with GradientBrush()

Postby Enrico Maria Giordano » Thu Feb 04, 2010 9:01 pm

The following sample seems to work at first but if you cover the dialog and then uncover it you will see that the colored background of the SAY is gone:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    DEFINE DIALOG oDlg;
           TRANSPARENT

    @ 1, 1 BUTTON "Test";
           ACTION ( oSay:SetColor( CLR_HGREEN, CLR_HRED ),;
                    oSay:Refresh() )

    @ 3, 1 SAY oSay PROMPT "This is a test"

    oSay:lTransparent = .F.

    oDlg:bStart = { || oSay:SetColor( CLR_HRED, CLR_HGREEN ), oSay:Refresh() }

    ACTIVATE DIALOG oDlg;
             ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
             CENTER

    RETURN NIL


FUNCTION GRADIENTBRUSH( oDlg, aColors )

    LOCAL hDC, hBmp, hBmpOld, oBrush

    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 )

    oBrush = TBrush():New( ,,,, hBmp )

    oDlg:SetBrush( oBrush )

    AEVAL( oDlg:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oDlg:oBrush ), ) } )

    RELEASE BRUSH oBrush

    SELECTOBJECT( hDC, hBmpOld )

    DELETEDC( hDC )

    oDlg:ReleaseDC()

    RETURN NIL


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

Re: A problem with GradientBrush()

Postby James Bott » Thu Feb 04, 2010 10:08 pm

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    DEFINE DIALOG oDlg;
           TRANSPARENT

//    @ 1, 1 BUTTON "Test";
//           ACTION ( oSay:SetColor( CLR_HGREEN, CLR_HRED ),;
//                    oSay:Refresh() )

    @ 1, 1 BUTTON "Test";
           ACTION ( oDlg:bPainted:={|| oSay:SetColor( CLR_HGREEN, CLR_HRED ),;
                    oSay:Refresh() }, oDlg:refresh() )

    @ 3, 1 SAY oSay PROMPT "This is a test"

    oSay:lTransparent = .F.

    //oDlg:bStart = { || oSay:SetColor( CLR_HRED, CLR_HGREEN ), oSay:Refresh() }

    oDlg:bPainted = { || oSay:SetColor( CLR_HRED, CLR_HGREEN ), oSay:Refresh() }

    ACTIVATE DIALOG oDlg;
             ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
             CENTER

    RETURN NIL


FUNCTION GRADIENTBRUSH( oDlg, aColors )

    LOCAL hDC, hBmp, hBmpOld, oBrush

    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 )

    oBrush = TBrush():New( ,,,, hBmp )

    oDlg:SetBrush( oBrush )

    AEVAL( oDlg:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oDlg:oBrush ), ) } )

    RELEASE BRUSH oBrush

    SELECTOBJECT( hDC, hBmpOld )

    DELETEDC( hDC )

    oDlg:ReleaseDC()

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


Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 83 guests