FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour v/h gradient
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
v/h gradient
Posted: Tue Dec 01, 2009 08:00 AM

the function GradientFill is a vertical gradient or Horizontal gradient ?
Or exist another function for create a gradient vertical or Horiz ?

Best Regards, Saludos



Falconi Silvio
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: v/h gradient
Posted: Tue Dec 01, 2009 12:03 PM
Hello Silvio,
as far as I know, GradientFill is used for Gradient-painting.
All together :

Code (fw): Select all Collapse
...
...
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON PAINT W_GRAD( oWnd, hDC, .T. )

// ACTIVATE DIALOG oDlg CENTERED ;
// ON PAINT W_GRAD( oDlg, hDC, .T. ) 

RETURN NIL

// --------- GRADIENT  ( Window or Dialog ) ---------------

STATIC FUNCTION WIN_GRAD( oWnd, hDC, lDirect )
local aGrad := { { W_MOVE, W_COLOR1, W_COLOR2 }, ;
                          { W_MOVE, W_COLOR2, W_COLOR1 } }         

// W_MOVE = Color-Position 0 - 1
// W_COLOR1 = 1. Gradient-Color
// W_COLOR2 = 2. Gradient-Color

// lDirect .T. = horizontal, lFDirect .F. = vertical Direction
GradientFill( hDC,  0, 0, oWnd:nHeight, oWnd:nWidth, aGrad, lDirect )

RETURN NIL

// ---- Brush - Function, used for  Folders -------------------
...
---
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( SetImages(oDlg,oFld), ; // Folder-Tab-Bitmaps
      GradBrush( oDlg, { { 0.50, 14853684, 16314573 }, ;
      { 0.50, 16314573, 14853684 } }, .T. ) ; 
ON PAINT SetFoldGrad( oFld, .T. )

RETURN NIL

//-------------------------

STATIC FUNCTION GradBrush( oDlg, aGrad, lDirect )
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, aGrad, lDirect)
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp ) 
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
endif   

RETURN NIL

// --------------------------------------------

STATIC FUNCTION SetFoldGrad( oFld, lDirect ) 
LOCAL n, oDlg 
    
FOR n = 1 to Len( oFld:aDialogs ) 
   oDlg = oFld:aDialogs[ n ]     
   oDlg:bPainted = { | hDC | GradientFill( hDC, 0, 0, oDlg:nHeight, ;
   oDlg:nWidth, { { 0.50, 14853684, 16314573 }, ;
   { 0.50, 16314573, 14853684 } }, lDirect ) } 
NEXT

RETURN NIL    

// -----------------------------------------

function SetImages(oDlg, oFld)
local oImageList
   
DEFINE IMAGELIST oImageList SIZE 16, 16
   
oImageList:AddMasked( TBitmap():Define( "show",,   oDlg ), nRGB( 192, 192, 192 ) )    
oImageList:AddMasked( TBitmap():Define( "show",,   oDlg ), nRGB( 192, 192, 192 ) ) 
// for each Tab

oFld:SetImageList( oImageList )

return nil


Best Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion