With Stefan's solution (saving the gradient as BMP ), i could solve the problem :
- Code: Select all Expand view
//------------- 1 GRADIENT HOR / VERT -----------
FUNCTION DRAW_GRAD( hDC,oBitmap,nDirection,nVColor, nBColor, nMove )
LOCAL nGRADIENT, oDlg_temp
aGrad := { { nMove, nVColor, nBColor }, ;
{ nMove, nBColor, nVColor } }
aRect := GETCLIENTRECT( oBitmap:hWnd )
IF nDirection = 1
DEFINE DIALOG oDlg_temp FROM 0,0 TO aRect [3], aRect[4] PIXEL STYLE nOr(WS_POPUP,4)
ACTIVATE DIALOG oDlg_temp ;
ON PAINT ( GradientFill( oDlg_temp:hDC, 0, 0, 130, 180, aGrad, .T. ),;
oDlg_temp:SaveToBmp("Temp.bmp"), oDlg_temp:end())
ENDIF
IF nDirection = 2
DEFINE DIALOG oDlg_temp FROM 0,0 TO aRect [3], aRect[4] PIXEL STYLE nOr(WS_POPUP,4)
ACTIVATE DIALOG oDlg_temp ;
ON PAINT ( GradientFill( oDlg_temp:hDC, 0, 0, 130, 180, aGrad, .F. ),;
oDlg_temp:SaveToBmp("Temp.bmp"), oDlg_temp:end())
ENDIF
DEFINE BRUSH oNewbrush FILE "Temp.bmp"
FillRect( oBitmap:hDC, aRect, oNewbrush:hBrush )
RELEASE BRUSH oNewbrush
FERASE( "Temp.bmp" )
RETURN NIL
To show project-settings, I use a Image-Browser to show all kinds
of backgrounds. For gradient-preview I used before :
- Code: Select all Expand view
aRect := GETCLIENTRECT( oBitmap:hWnd )
IF nDirection = 1
// Horizont.
nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. )
ELSE
// Vertical
nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .F. )
ENDIF
DEFINE BRUSH oNewbrush COLOR nGRADIENT
FillRect( oBitmap:hDC, aRect, oNewbrush:hBrush )
RELEASE BRUSH oNewbrush
It works but doesn't support color-adjustment.
Because the gradient-colors must shown centered and
the 3. value < nMOVE > is not supported, I want to change from
<Gradient> to <Gradientfill> using :
- Code: Select all Expand view
aGrad := { { nMove, nVColor, nBColor }, ;
{ nMove, nBColor, nVColor } }
aRect := GETCLIENTRECT( oBitmap:hWnd )
IF nDirection = 1
// Horizont.
nGRADIENT := GradientFill( hDC, aRect, aGrad, .T. )
ELSE
// Vertical
nGRADIENT := GradientFill( hDC, aRect, aGrad, .F. )
ENDIF
DEFINE BRUSH oNewbrush COLOR nGRADIENT
FillRect( oBitmap:hDC, aRect, oNewbrush:hBrush )
RELEASE BRUSH oNewbrush
It doesn't work.
The exact preview ( windows and dialog ) looks like :
All other combinations are working :
Clear color
Predefined Brush
Tiled
Image
Is it possible to change from <Gradient> to <GradientFill> for BMP's,
to use the < move-color > option ?
( solved, if saving as BMP )
Regards
Uwe