#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
DEFINE DIALOG oDlg
@ 1, 1 BUTTON "Test";
ACTION TEST()
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
IF EMPTY( oDlg:oBrush:hBitmap )
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()
ENDIF
RETURN NIL
So the problem is at least under XP.
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
DEFINE DIALOG oDlg
@ 1, 1 BUTTON "Test";
ACTION TEST()
oDlg:aControls[ 1 ]:bLostFocus = { || oDlg:Refresh() }
ACTIVATE DIALOG oDlg;
ON INIT oDlg:SendMsg( WM_PAINT );
ON PAINT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
IF EMPTY( oDlg:oBrush:hBitmap )
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()
ENDIF
RETURN NIL
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
DEFINE DIALOG oDlg
@ 1, 1 BUTTON "Test";
ACTION TEST()
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg;
ON INIT oDlg:SendMsg( WM_PAINT );
ON PAINT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
IF EMPTY( oDlg:oBrush:hBitmap )
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()
ENDIF
RETURN NIL
#include "FiveWin.ch"
FUNCTION MAIN()
LOCAL oDlg1
DEFINE DIALOG oDlg1
@ 1, 1 BUTTON "Test";
ACTION TEST()
ACTIVATE DIALOG oDlg1 CENTER ;
ON INIT ( GRADBRUSH( oDlg1, { { 1, 14198567, 16117445 } }, .T. ), ;
oDlg1:Move( 110, 460, 430, 215, .f. ) )
RETURN NIL
// -----------------------
FUNCTION TEST()
LOCAL oDlg2
DEFINE DIALOG oDlg2
ACTIVATE DIALOG oDlg2 CENTER ;
ON INIT ( GRADBRUSH( oDlg2, { { 1, 128, 16117445 } }, .T. ), ;
oDlg2:Move( 200, 500, 430, 215, .f. ) )
*ON INIT oDlg2:SendMsg( WM_PAINT )
RETURN NIL
// -------------------------------
FUNCTION GradBrush( oDlg, aColors, lPos )
local hDC, hBmp, hBmpOld, oBrush
if Empty( oDlg:oBrush:hBitmap )
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, lPos )
DeleteObject( oDlg:oBrush:hBrush )
oDlg:oBrush:hBitmap = hBmp
oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
SelectObject( hDC, hBmpOld )
oDlg:ReleaseDC()
endif
RETURN NIL
#include "FiveWin.ch"
Static hDC
FUNCTION MAIN()
LOCAL oDlg1
DEFINE DIALOG oDlg1
@ 1, 1 BUTTON "Test";
ACTION TEST()
ACTIVATE DIALOG oDlg1 ;
ON PAINT DLG_GRAD( hDC, oDlg1, { { 1, 14198567, 16117445 } }, .T. ) ;
ON INIT oDlg1:Move( 110, 460, 430, 215, .f. )
RETURN NIL
// -----------------
FUNCTION TEST()
LOCAL oDlg2
DEFINE DIALOG oDlg2
ACTIVATE DIALOG oDlg2 CENTER ;
ON PAINT DLG_GRAD( hDC, oDlg2, { { 1, 128, 16117445 } }, .T. ) ;
ON INIT oDlg2:Move( 200, 500, 430, 215, .f. )
RETURN NIL
// -------------- GRADIENT --------------------
STATIC FUNCTION DLG_GRAD( hDC, oDlg, aGrad, lPos )
GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aGrad, lPos )
RELEASEDC( hDC )
RETURN NIL
#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 oDlg:oBrush := GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg;
TRANSPARENT
ACTIVATE DIALOG oDlg;
ON INIT oDlg:oBrush := 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 )
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oDlg:ReleaseDC()
RETURN oBrush
ukoenig wrote:to solve this problem, I used only the checkbox-square and a extra text.
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL lVar := .F.
DEFINE DIALOG oDlg;
TRANSPARENT
@ 1, 1 BUTTON "Test";
ACTION TEST()
@ 3, 1 CHECKBOX lVar
oDlg:oBrush = TBrush():New()
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RETURN NIL
FUNCTION TEST()
LOCAL oDlg
DEFINE DIALOG oDlg;
TRANSPARENT
oDlg:oBrush = 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
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg, oBrush // added oBrush
DEFINE BRUSH oBrush // inserted
DEFINE DIALOG oDlg BRUSH oBrush
@ 1, 1 BUTTON "Test";
ACTION TEST()
ACTIVATE DIALOG oDlg;
ON INIT GRADIENTBRUSH( oDlg, { { 1, RGB( 216, 230, 238 ), RGB( 103, 154, 194 ) } } );
CENTER
RELEASE BRUSH oBrush // inserted
RETURN NIL
FUNCTION TEST()
LOCAL oDlg, oBrush
// gradient brush for this dialog also
DEFINE BRUSH oBrush
DEFINE DIALOG oDlg BRUSH oBrush
ACTIVATE DIALOG oDlg;
CENTER ;
ON INIT GRADIENTBRUSH( oDlg, { { 1, CLR_RED, CLR_WHITE } } );
RELEASE BRUSH oBrush
RETURN NIL
FUNCTION GRADIENTBRUSH( oDlg, aColors )
LOCAL hDC, hBmp, hBmpOld
IF EMPTY( oDlg:oBrush:hBitmap )
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 )
oDlg:oBrush:cBmpfile = LTrim( Str( hBmp ) ) // inserted to trick the aBrushes behavior
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oDlg:ReleaseDC()
ENDIF
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 64 guests