Re: A problem with GradientBrush()
Posted: Sun Jan 31, 2010 9:19 am
You da man!!! Many many thanks!
EMG
EMG
www.FiveTechSoft.com
https://fivetechsupport.com/forums/
Code: Select all | Expand
oDlg:oBrush = TBrush():New()
Code: Select all | Expand
#include "Fivewin.ch"
#include "Image.ch"
FUNCTION MAIN()
LOCAL oDlg
DEFINE DIALOG oDlg;
TRANSPARENT
@ 0, 0 SAY "This is a test"
@ 1, 1 IMAGE;
SIZE 50, 50;
FILE "e:\fwharbour\bitmaps\select.bmp";
NOBORDER ADJUST
oDlg:SetBrush( TBrush():New() )
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
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 )
DELETEOBJECT( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CREATEPATTERNBRUSH( hBmp )
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oDlg:ReleaseDC()
RETURN NIL
Code: Select all | Expand
oDlg:SetBrush( TBrush():New() )
Code: Select all | Expand
oDlg:oBrush = TBrush():New()
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, oBrush
LOCAL cPath := 'c:\fwh\bitmaps\' // change to your path
DEFINE BRUSH oBrush
DEFINE DIALOG oDlg SIZE 240,200 PIXEL BRUSH oBrush TRANSPARENT
@ 10, 10 SAY 'Say on Transparent Dialog' SIZE 100,10 PIXEL OF oDlg
@ 25, 25 IMAGE FILE cPath + "select.bmp" SIZE 20,20 PIXEL NOBORDER ADJUST
@ 50, 25 IMAGE FILE cPath + "AlphaBmp\ichat.bmp" SIZE 50,50 PIXEL NOBORDER ADJUST
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RELEASE BRUSH oBrush
RETURN NIL
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL lVar := .F.
DEFINE DIALOG oDlg;
TRANSPARENT
@ 1, 1 BUTTON "Test";
ACTION TEST()
@ 3, 1 CHECKBOX lVar
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
oDlg:oBrush:End()
MsgInfo( oDlg:oBrush:nCount )
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg;
TRANSPARENT
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
oDlg:oBrush:End()
MsgInfo( oDlg:oBrush:nCount )
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
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 )
oDlg:oBrush:End()
oDlg:SetBrush( TBrush():New( ,,,, hBmp ) )
AEval( oDlg:aControls, { | o | o:SetBrush( oDlg:oBrush ) } )
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oDlg:ReleaseDC()
RETURN NIL
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL lVar := .F.
DEFINE DIALOG oDlg;
TRANSPARENT
@ 1, 1 BUTTON "Test";
ACTION TEST( oDlg:oBrush )
@ 3, 1 CHECKBOX lVar
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
oDlg:oBrush:End()
MsgInfo( oDlg:oBrush:nCount )
RETURN NIL
FUNCTION TEST( oBrush )
LOCAL oDlg
MsgInfo( oBrush:nCount )
DEFINE DIALOG oDlg;
TRANSPARENT BRUSH oBrush
ACTIVATE DIALOG oDlg;
CENTER
MsgInfo( oDlg:oBrush:nCount )
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
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 )
oDlg:oBrush:End()
oDlg:SetBrush( TBrush():New( ,,,, hBmp ) )
AEval( oDlg:aControls, { | o | o:SetBrush( oDlg:oBrush ) } )
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oDlg:ReleaseDC()
RETURN NIL
Antonio Linares wrote:Code: Select all | Expand
oDlg:oBrush:End()
oDlg:SetBrush( TBrush():New( ,,,, hBmp ) )
Code: Select all | Expand
METHOD SetBrush( oBrush ) INLINE If( ::oBrush != nil, ::oBrush:End(),),;