is it possible create a brush gradient on a Panel (Tpanel)
aGrad := { .... your gradient array }
DEFINE BRUSH oBrush GRADIENT aGrad
oPanel:SetBrush( oBrush )
aGrad :={ { 1, CLR_BLUE, CLR_WHITE } }
DEFINE BRUSH oBrush GRADIENT aGrad
DEFINE WINDOW oWnd
oPanel:=TPanel(5,215,155,305,oWnd)
oPanel:SetBrush( oBrush )
oBrush:Resize( oPanel )
ACTIVATE WINDOW oWnd CENTERED
// at startup
// ------------
IF cBrush = "C" // color
oPanel1:SetColor( "W/R" )
oPanel2:SetColor( "W/G" )
oPanel3:SetColor( "W/B" )
ELSE // gradient, brush, image
PANELBRUSH( oPanel1, 1, cBrush )
PANELBRUSH( oPanel2, 2, cBrush )
PANELBRUSH( oPanel3, 3, cBrush )
ENDIF
// ---- on button-action
@ 110, nBtnleft button "Gradient" size 130, 40 pixel ;
ACTION ( cBrush := "G", ;
PANELBRUSH( oPanel1, 1, cBrush, , oPanel1:nHeight ), ;
PANELBRUSH( oPanel2, 2, cBrush, , oPanel2:nHeight ), ;
PANELBRUSH( oPanel3, 3, cBrush, , oPanel3:nHeight ) ) ;
OF oWnd
// ------------
FUNCTION PANELBRUSH( oPanel, nPanel, cBrush, cImage, nHeight )
LOCAL hDC, hBmp, hBmpOld, oBrush
LOCAL aRect := GETCLIENTRECT( oPanel:hWnd )
LOCAL aColors
IF cBrush = "C" .or. cBrush = "G" // colors used for defined color- and gradient-background
IF nPanel = 1
aColors := { { 1, 16777215, 255 } }
ELSEIF nPanel = 2
aColors := { { 1, 16777215, 32768 } }
ELSEIF nPanel = 3
aColors := { { 1, 16777215, 16711680 } }
ENDIF
ENDIF
IF cBrush = "G"
// MsgAlert( nHeight, "Panel-height" )
hDC = CREATECOMPATIBLEDC( oPanel:GetDC() )
hBmp = CREATECOMPATIBLEBITMAP( oPanel:hDC, oPanel:nWidth, nHeight )
hBmpOld = SELECTOBJECT( hDC, hBmp )
GRADIENTFILL( hDC, 0, 0, oPanel:nHeight, oPanel:nWidth, aColors )
oBrush = TBrush():New( ,,,, hBmp )
oPanel:SetBrush( oBrush )
AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )
RELEASE BRUSH oBrush
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oPanel:ReleaseDC()
ENDIF
IF cBrush = "B"
DEFINE BRUSH oBrush FILE cImage
oPanel:SetBrush( oBrush )
AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )
RELEASE BRUSH oBrush
ENDIF
IF cBrush = "I"
DEFINE IMAGE oImage FILE cImage
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) )
oImage:End()
oPanel:SetBrush( oBrush )
AEVAL( oPanel:aControls, { | oCtl | If( oCtl:lTransparent, oCtl:SetBrush( oPanel:oBrush ), ) } )
RELEASE BRUSH oBrush
ENDIF
RETURN NIL
else
FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
endif
else
::PaintBack( ::hDC )
//FillRect( ::hDC, GetClientRect( ::hWnd ), ::oBrush:hBrush )
endif
#include "fivewin.ch"
#include "splitter.ch"
function Main()
local oWnd, oPanel1, oPanel2, oBrush1, oBrush2, oSplit
DEFINE BRUSH oBrush1 FILE "c:\fwh\bitmaps\sea.bmp" STRETCH
DEFINE BRUSH oBrush2 FILE "c:\fwh\bitmaps\hires\office.bmp" STRETCH
DEFINE WINDOW oWnd
oPanel1 := TPanel():New( 0,0,200,900, oWnd )
oPanel2 := TPanel():New( 204,0,500,900, oWnd )
oPanel1:SetBrush( oBrush1 )
oPanel2:SetBrush( oBrush2 )
@ 200,0 SPLITTER oSplit ;
HORIZONTAL ;
PREVIOUS CONTROLS oPanel1 ;
HINDS CONTROLS oPanel2 ;
TOP MARGIN 80 ;
BOTTOM MARGIN 80 ;
SIZE 500, 4 PIXEL ;
OF oWnd ;
_3DLOOK
oWnd:nWidth := 500
oWnd:nHeight := 600
ACTIVATE WINDOW oWnd CENTERED ON RESIZE oSplit:AdjClient()
return nil
Function test()
local oDlg,oFont aGrad
Local oPanel
Local nLevel:= 1
Local cFrtipo:= 1
Local nFrcolore:= 1
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8
DEFINE DIALOG oDlg FROM 100, 100 TO 454,714;
STYLE DS_MODALFRAME + WS_POPUPWINDOW + WS_VISIBLE + WS_DLGFRAME + 4;
TITLE cTitle PIXEL FONT oFont
aGrad := { { 0.5, 10899511, 16443068 }, { 0.5, 16443068, 10899511 } }
DEFINE BRUSH oBrush GRADIENT aGrad
oPanel:=TPanel(5,215,155,305,oDlg)
oPanel:SetBrush( oBrush )
oBrush:Resize( oPanel )
ACTIVATE DIALOG oDlg;
ON INIT (Show_Raccoglitore(oPanel,nLevel,cFrtipo,nFrcolore))
return nil
//-------------------------------------------------------------------------------------------------//
Function Function Show_Raccoglitore(oPanel,nLevel,cFrtipo,nFrcolore)
Local oBmp
local aBmpFaldoni:= { ".\bitmaps\png\imgFolderArancione.png" ,;
".\bitmaps\png\imgFolderBlu.png" ,;
".\bitmaps\png\imgFolderCiano.png" ,;
".\bitmaps\png\imgFolderGiallo.png" ,;
".\bitmaps\png\imgFolderGrigio.png" ,;
".\bitmaps\png\imgFolderMarrone.png" ,;
".\bitmaps\png\imgFolderNero.png" ,;
".\bitmaps\png\imgFolderRosa.png" ,;
".\bitmaps\png\imgFolderRosso.png" ,;
".\bitmaps\png\imgFolderVerde.png" ,;
".\bitmaps\png\imgFolderViola.png" }
@ 2,10 BTNBMP oBmp OF oPanel ;
SIZE (nLarghezzaRaccoglitori),(nAltezzaRaccoglitori) PIXEL TRANSPARENT ;
Prompt str2lines(alltrim(cFrtipo)," ") ;
NOBORDER ;
Filename aBmpFaldoni[nFrcolore] ;
CENTER ACTION NIL
return nil
Silvio.Falconi wrote:Sorry ,
I have another Tpanel.prg because I have another paint method
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 93 guests