Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need A Gradiant Background
Message
From
03/11/2005 17:01:58
Mike Sue-Ping
Cambridge, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01064822
Message ID:
01065250
Views:
18
Hi Kevin,

Here's some cool code to make a form background's into a gradient. Try resizing the form. I think I had found this code here on the UT. All credit belongs to the original author whose name I cannot remember. It could be Craig Boyd's since it has something to do with GDI+ :)
#DEFINE ARGB_RED  0xFF00FFFF
#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 
Hope this helps,

Mike



>I'm looking for a gradiant style background.
>
>I want something akin to the gradiant image found on VS 2005's
>Start Page. Something like that would work.
>
>Anyone know where I can get one?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform