Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Gradient colors
Message
De
01/07/2005 01:13:09
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Titre:
Versions des environnements
Visual FoxPro:
VFP 8
Divers
Thread ID:
01027128
Message ID:
01028035
Vues:
9
Bo this is so cool! I'm sure I can make a class of it and use it. Thanks.

>Malcolm,
>
>Here you go...
>
>I would put this in a visual class, but this sample works beter for posting to the message board.
>
>Bo Durban
>
>
>
>
>#DEFINE ARGB_RED  0xFFFF0000
>#DEFINE ARGB_BLUE 0xFF0000FF
>
>PUBLIC o
>o=CREATEOBJECT("MyForm")
>o.Show()
>
>*********************************************************
>*********************************************************
>*********************************************************
>DEFINE CLASS MyForm AS Form
>AutoCenter = .T.
>Width = 240
>Height = 240
>cTempFile = ""
>nColor1 = ARGB_RED
>nColor2 = ARGB_BLUE
>
>ADD OBJECT cntFill AS Container WITH ;
>   Top = 20, Left = 20, ;
>   Height = 200, Width = 200, ;
>   Anchor = 15
>
>ADD OBJECT btnOne AS COmmandButton WITH ;
>   Top = 100, Left = 100, ;
>   Height = 25, Width = 100, ;
>   Caption = "Push Me!"
>
>*********************************************************
>FUNCTION Init()
>   This.cTempFile = ADDBS(SYS(2023))+SYS(2015)+".bmp"
>   This.cntFill.Resize()
>ENDFUNC
>
>*********************************************************
>FUNCTION Destroy()
>   DELETE FILE (This.cTempFile)
>ENDFUNC
>
>*********************************************************
>FUNCTION cntFill.Resize()
>   CLEAR RESOURCES (ThisForm.cTempFile)
>   MakeGradientPicture(ThisForm.cTempFile, This.Height, ;
>         ThisForm.nColor1, ThisForm.nColor2)
>   This.Picture = ThisForm.cTempFile
>ENDFUNC
>
>*********************************************************
>FUNCTION btnOne.Click()
>   ThisForm.nColor1 = 0xFF000000 + RAND()*0xFFFFFF
>   ThisForm.nColor2 = 0xFF000000 + RAND()*0xFFFFFF
>   ThisForm.cntFill.Resize()
>ENDFUNC
>
>ENDDEFINE
>
>
>*********************************************************
>FUNCTION MakeGradientPicture(cFileName, nHeight, nColor1, nColor2)
>
>DECLARE Long GdipCreateLineBrushI IN GDIPLUS ;
>   String point1, String point2, ;
>   Long color1, Long color2, ;
>   Long wrapMode, Long @lineGradient
>
>SET CLASSLIB TO HOME()+"ffc\_gdiplus" ADDITIVE
>
>** Get screen Graphics context
>oGfxS = CREATEOBJECT("gpGraphics")
>oGfxS.CreateFromHWND(0)
>
>** Create a bitmap
>oBmp = CREATEOBJECT("gpBitmap")
>oBmp.CreateFromGraphics(oGfxS,1,nHeight)
>
>** Get a bitmab graphics object
>oGfx = CREATEOBJECT("gpGraphics")
>oGfx.CreateFromImage(oBmp)
>
>** Get a gradient brush
>hBrush = 0
>GdipCreateLineBrushI(BINTOC(0,"4rs")+BINTOC(0,"4rs"), ;
>      BINTOC(0,"4rs")+BINTOC(nHeight,"4rs"), ;
>      nColor1, nColor2, 0, @hBrush)
>oBrush = CREATEOBJECT("gpBrush")
>oBrush.SetHandle(hBrush)
>
>** Fill the bitmap with our gradient
>oGfx.FillRectangle(oBrush,0,0,1,nHeight)
>oBmp.SaveToFile(cFileName,"image/bmp")
>
>oGfx = NULL
>oBrush = NULL
>oBmp = NULL
>oGfxS = NULL
>
>RETURN
>
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform