FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour A problem with GradientBrush()
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: A problem with GradientBrush()

Posted: Thu Feb 04, 2010 08: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 (fw): Select all Collapse
AEVAL( oDlg:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oDlg:oBrush ), ) } )


that seems to work for TImage but not for TSay.

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: A problem with GradientBrush()

Posted: Thu Feb 04, 2010 09: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 (fw): Select all Collapse
#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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM

Re: A problem with GradientBrush()

Posted: Thu Feb 04, 2010 10:08 PM
Code (fw): Select all Collapse
#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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: A problem with GradientBrush()

Posted: Thu Feb 04, 2010 10:14 PM

Thank you, James.

EMG

Continue the discussion