Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Graphic = 500
%IDC_Button = 501
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Gradient Fill Test",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Push", 10,10,100,20
Control Add Graphic, hDlg, %IDC_Graphic, "", 50,40,75,150
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If Cb.Msg = %WM_Command And Cb.Ctl = %IDC_Button And Cb.CtlMsg = %BN_Clicked Then
CreateGradientColors
End If
End Function
Sub CreateGradientColors
Local hDC As Dword, w,h As Long, gRect As Gradient_Rect
Dim V(1) As TriVertex
Control Get Client hDlg, %IDC_Graphic To w,h
Graphic Attach hDlg, %IDC_Graphic, ReDraw
Graphic Get DC To hDC
V(0).x = 0
V(0).y = 0
V(0).Red = Mak(Word,0,255)
V(0).Green = 0
V(0).Blue = 0
V(1).x = w '<--- not w-1
V(1).y = h '<--- not h-1
V(1).Red = 0
V(1).Green = 0
V(1).Blue = Mak(Word,0,255)
gRect.UpperLeft = 0
gRect.LowerRight = 1
GradientFill hDC, V(0), 2, gRect, 1, %Gradient_Fill_Rect_H
Graphic ReDraw
End Sub
'gbs_00878
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm