A VFP9 gdiplusX gauge prototype

Published on by Yousfi Benameur


the previous code was javascript overlapped with vfp.
This code draws a pure vfp9 radial gauge with the gdiplusX library.
it uses the imgcanvas of gdiplsuX class and system.app.
gdiplusX stable version is the version 20 can be downloaded at vfp codeplex at this  link :https://vfpx.codeplex.com/downloads/get/69412
-can draws the circular gauge (square width=height)
-the contour can be drawn or removed (can choose the color)
-the graduations and the numeric ticks (can be set or removed).the ticks number can be set with spinner.
-the needle (can be modified by spinners:pointer color,backcolor,tick color,height,..).
-the zoom spinner can modify dynamically the dimensions of the gauge.
-the icon explorer can open the captured images folder.
-can set a picture as clipped background of the gauge.can choose to resize (to have one strecthed texture image) or no.
-can set a lineargradientbrush (2 colors) as background and set a center color or no.Repeat clicking to have many configurations colors.the gradients are randomly used (0,1,2,3 constants).
-can anim the gauge (0-360° or a random animation).i remark this moving is some slow because i used a loop.
-can set the container color for visual user contrast.
-can set web images downloaded and set as gauge background(in this case cut the ticks).image is resized.
-can expand/collapse the container command.

Note : the code is globally the same to build clocks,compass,....
can read also Cesar gauge in: http://weblogs.foxite.com/vfpimaging/2009/04/24/circular-gauge-chart-with-gdiplusx/


Click on code to select [then copy] -click outside to deselect


*1*the code asks to system.app and gdiplusX.vcx(+vct).put them in same folder for making the code working.

do locfile('system.app')
set classlib to locfile("gdiplusX.vcx","vcx") addi

publi yform
yform=newObject("yGauge")
release classlib gdiplusX
yform.show
read events
*
DEFINE CLASS yGauge AS form
BorderStyle = 3
Height = 676
Width = 1029
ShowWindow = 2
ShowTips = .T.
AutoCenter = .T.
Caption = "VFP9 Circular gauge configurable  prototype."
BackColor = RGB(0,0,0)
lnangle = 0
xpict = .F.
ybrush = 0
ypict = .F.
ycl = 0
first = .F.
x0 = .F.
y0 = .F.
uimg = .F.
vimg = .F.

ADD OBJECT ycont AS ycont0 WITH ;
Anchor = 768, ;
Top = 33, ;
Left = 5, ;
Width = 211, ;
Height = 543, ;
Name = "ycont"


ADD OBJECT image1 AS image WITH ;
Anchor = 768, ;
BackStyle = 0, ;
BorderStyle = 1, ;
Height = 32, ;
Left = 24, ;
MousePointer = 15, ;
Top = 0, ;
Width = 32, ;
Name = "Image1"


ADD OBJECT ycnt AS  ycnt0 WITH ;
Anchor = 15, ;
Top = 12, ;
Left = 300, ;
Width = 720, ;
Height = 612, ;
BackStyle = 0, ;
Name = "ycnt"


procedure image1.click
thisform.ycl=iif(thisform.ycl=0,1,0)

do case
case thisform.ycl=1
this.pictureval=strconv(thisform.vimg,14)
thisform.ycont.left=-thisform.ycont.width+5


case thisform.ycl=0
thisform.ycont.left=5
this.pictureVal=strconv(thisform.uimg,14)

endcase

endproc


PROCEDURE my
LPARAMETERS nButton, nShift, nXCoord, nYCoord
*--- aevent create an array laEvents
Aevents( myArray, 0)
*--- reference the calling object
loObject = myArray[1]

thisform.ycont.check4.value=0
loObject.parent.value=int(val(substr(loObject.name,7)))
thisform.ycont.check5.value=0
Local lcDownloadURL,lcDownloadLoc,lnResult
do case
case loObject.parent.value=1
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_185a5c_circulargauge1.jpg"
case loObject.parent.value=2
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_212529_circulargauge2.jpg"
case loObject.parent.value=3
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_8cf642_circulargauge3.jpg"
case loObject.parent.value=4
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_23580b_circulargauge7.jpg"
case loObject.parent.value=5
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_df3d8b_circulargauge9.jpg"
case loObject.parent.value=6
m.lcDownloadURL="http://img.over-blog-kiwi.com/1/43/54/07/20170110/ob_5a54b6_ycolor-picker.png"
endcase
m.lcDownloadLoc = addbs(sys(2023))+"ytemp."+justext(m.lcDownloadURL)

try
erase (lcdest)
catch
endtry

inke(1)

lnResult = DeleteUrlCacheEntry(lcDownloadURL)
lnResult = URLDownloadToFile(0, lcDownloadURL, lcDownloadLoc , 0,0)
If lnResult = 0
Wait Window "Download "+m.lcDownloadLoc+ " Complete" timeout 1
*Else
*!*   Messagebox("Download fails")
Endi

thisform.xpict=m.lcDownloadLoc
if  empty(thisform.xpict)
return .f.
endi

thisform.ybrush=3
thisform.ycnt.imgcanvas1.draw
thisform.ycont.check4.value=1
ENDPROC


PROCEDURE Resize
try
with thisform.ycont.spinner1
.value=.value+1
.interactiveChange()
endwith
catch
endtry
ENDPROC


PROCEDURE Load		
_screen.windowstate=1
set safe off
Declare Integer URLDownloadToFile In urlmon.Dll Integer pCaller, String szURL, String szFileName, Integer dwReserved, Integer lpfnCB
Declare Integer DeleteUrlCacheEntry In wininet String lpszUrlName
ENDPROC


PROCEDURE Init
publi m.yrep
m.yrep=addbs(justpath(sys(16,1)))
set defa to (yrep)
if !directory(m.yrep+"images")
md (m.yrep+"images")
endi

text to thisform.uimg noshow
Qk02DAAAAAAAADYAAAAoAAAAIAAAACAAAAABABgAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/9LIsktPmFxemldYvpiYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+5iJ/yQBkggAa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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqGlpZAAAcw8AjxoA/ygA+RwG+7GoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2MC+mVBTZgAAfwAA/0Mh+8jDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3KytAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
endtext
ENDPROC


PROCEDURE Destroy
erase addbs(sys(2023))+"ytemp*.*"
clea events
ENDPROC

ENDDEFINE
*
*-- EndDefine: yGauge


*
DEFINE CLASS ycont0  AS container
Anchor = 768
Top = 33
Left = 5
Width = 211
Height = 543
Name = "ycont0"

ADD OBJECT spnangle AS spinner WITH ;
Height = 20, ;
KeyboardHighValue = 360, ;
KeyboardLowValue = 0, ;
Left = 104, ;
SpinnerHighValue = 360.00, ;
SpinnerLowValue =   0.00, ;
Top = 9, ;
Width = 84, ;
Name = "spnAngle"

ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
Caption = "Angle (0-360)", ;
Height = 17, ;
Left = 11, ;
Top = 13, ;
Width = 76, ;
Name = "Label1"

ADD OBJECT spnheight AS spinner WITH ;
Height = 20, ;
KeyboardHighValue = 100, ;
KeyboardLowValue = 10, ;
Left = 104, ;
SpinnerHighValue = 100.00, ;
SpinnerLowValue =  10.00, ;
Top = 38, ;
Width = 84, ;
Value = 75, ;
Name = "spnHeight"

ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
Caption = "Pointer Height", ;
Height = 17, ;
Left = 11, ;
Top = 42, ;
Width = 80, ;
Name = "Label2"

ADD OBJECT spntopw AS spinner WITH ;
Height = 20, ;
KeyboardHighValue = 40, ;
KeyboardLowValue = 1, ;
Left = 104, ;
SpinnerHighValue =  40.00, ;
SpinnerLowValue =   1.00, ;
Top = 69, ;
Width = 84, ;
Value = 6, ;
Name = "spnTopW"

ADD OBJECT label3 AS label WITH ;
AutoSize = .T., ;
Caption = "Top Width", ;
Height = 17, ;
Left = 11, ;
Top = 73, ;
Width = 57, ;
Name = "Label3"

ADD OBJECT spnbottomw AS spinner WITH ;
Height = 20, ;
KeyboardHighValue = 40, ;
KeyboardLowValue = 1, ;
Left = 104, ;
SpinnerHighValue =  40.00, ;
SpinnerLowValue =   1.00, ;
Top = 100, ;
Width = 84, ;
Value = 35, ;
Name = "spnBottomW"

ADD OBJECT label4 AS label WITH ;
AutoSize = .T., ;
Caption = "Bottom Width", ;
Height = 17, ;
Left = 11, ;
Top = 104, ;
Width = 75, ;
Name = "Label4"

ADD OBJECT label5 AS label WITH ;
AutoSize = .T., ;
Caption = "%", ;
Height = 17, ;
Left = 195, ;
Top = 44, ;
Width = 13, ;
Name = "Label5"

ADD OBJECT shppointercolor AS shape WITH ;
Top = 223, ;
Left = 129, ;
Height = 20, ;
Width = 48, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(0,0,0), ;
Name = "ShpPointerColor"

ADD OBJECT command1 AS commandbutton WITH ;
Top = 223, ;
Left = 5, ;
Height = 20, ;
Width = 120, ;
Caption = "Pointer Color", ;
Enabled = .F., ;
Name = "Command1"

ADD OBJECT shpbackcolor AS shape WITH ;
Top = 253, ;
Left = 129, ;
Height = 20, ;
Width = 48, ;
BorderStyle = 0, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(128,255,255), ;
Name = "shpBackColor"

ADD OBJECT command2 AS commandbutton WITH ;
Top = 253, ;
Left = 5, ;
Height = 20, ;
Width = 120, ;
Caption = "BackColor", ;
Enabled = .F., ;
Name = "Command2"

ADD OBJECT spnticks AS spinner WITH ;
Height = 24, ;
KeyboardHighValue = 180, ;
KeyboardLowValue = 0, ;
Left = 104, ;
SpinnerHighValue = 180.00, ;
SpinnerLowValue =   0.00, ;
Top = 130, ;
Width = 84, ;
Value = 24, ;
Name = "spnTicks"

ADD OBJECT label6 AS label WITH ;
AutoSize = .T., ;
Caption = "Ticks Count", ;
Height = 17, ;
Left = 11, ;
Top = 134, ;
Width = 67, ;
Name = "Label6"

ADD OBJECT command3 AS commandbutton WITH ;
Top = 282, ;
Left = 5, ;
Height = 20, ;
Width = 120, ;
Caption = "Tick color", ;
Enabled = .F., ;
Name = "Command3"

ADD OBJECT shape1 AS shape WITH ;
Top = 281, ;
Left = 130, ;
Height = 20, ;
Width = 48, ;
BorderStyle = 0, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(255,0,0), ;
Name = "Shape1"

ADD OBJECT command5 AS commandbutton WITH ;
Top = 334, ;
Left = 5, ;
Height = 20, ;
Width = 120, ;
Caption = "Get picture", ;
Name = "Command5"

ADD OBJECT command6 AS commandbutton WITH ;
Top = 438, ;
Left = 12, ;
Height = 20, ;
Width = 82, ;
Caption = "Save", ;
Name = "Command6"

ADD OBJECT command4 AS commandbutton WITH ;
Top = 471, ;
Left = 12, ;
Height = 20, ;
Width = 84, ;
Caption = "anim 360°", ;
Name = "Command4"

ADD OBJECT command7 AS commandbutton WITH ;
Top = 471, ;
Left = 108, ;
Height = 20, ;
Width = 84, ;
Caption = "Random anim", ;
Name = "Command7"

ADD OBJECT image1 AS image WITH ;
Picture =home(1)+ "graphics\icons\win95\explorer.ico", ;
Height = 32, ;
Left = 19, ;
MousePointer = 15, ;
Top = 191, ;
Width = 32, ;
Name = "Image1"

ADD OBJECT command8 AS commandbutton WITH ;
Top = 361, ;
Left = 12, ;
Height = 20, ;
Width = 60, ;
Caption = "Lgrad", ;
DisabledForeColor = RGB(255,0,0), ;
DisabledBackColor = RGB(0,0,255), ;
Name = "Command8"

ADD OBJECT ysh1 AS shape WITH ;
Top = 360, ;
Left = 79, ;
Height = 20, ;
Width = 48, ;
BorderStyle = 0, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(0,255,0), ;
Name = "ySh1"

ADD OBJECT ysh2 AS shape WITH ;
Top = 359, ;
Left = 138, ;
Height = 20, ;
Width = 48, ;
BorderStyle = 0, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(255,128,0), ;
Name = "ySh2"

ADD OBJECT check1 AS checkbox WITH ;
Top = 339, ;
Left = 133, ;
Height = 17, ;
Width = 60, ;
Alignment = 0, ;
Caption = "Resize", ;
Value = 1, ;
Name = "Check1"

ADD OBJECT spinner1 AS spinner WITH ;
Height = 20, ;
Increment =   5.00, ;
InputMask = "", ;
KeyboardHighValue = 800, ;
KeyboardLowValue = 0, ;
Left = 115, ;
SpinnerHighValue = 800.00, ;
SpinnerLowValue =   0.00, ;
Top = 191, ;
Width = 79, ;
Value = 550, ;
Name = "Spinner1"

ADD OBJECT label7 AS label WITH ;
Caption = "Zoom", ;
Height = 20, ;
Left = 73, ;
Top = 194, ;
Width = 37, ;
Name = "Label7"

ADD OBJECT check2 AS checkbox WITH ;
Top = 152, ;
Left = 103, ;
Height = 17, ;
Width = 84, ;
AutoSize = .T., ;
Alignment = 0, ;
Caption = "Ticks Nums", ;
Value = 1, ;
Name = "Check2"

ADD OBJECT label8 AS label WITH ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 32, ;
BackStyle = 0, ;
Caption = "?", ;
Height = 54, ;
Left = 154, ;
MousePointer = 15, ;
Top = 408, ;
Width = 28, ;
ForeColor = RGB(0,255,0), ;
Name = "Label8"

ADD OBJECT check3 AS checkbox WITH ;
Top = 387, ;
Left = 81, ;
Height = 17, ;
Width = 88, ;
AutoSize = .T., ;
Alignment = 0, ;
BackStyle = 0, ;
Caption = "Center Color", ;
Value = 0, ;
Name = "Check3"

ADD OBJECT shape2 AS shape WITH ;
Top = 435, ;
Left = 127, ;
Height = 13, ;
Width = 13, ;
Curvature = 99, ;
MousePointer = 15, ;
BackColor = RGB(255,0,0), ;
Name = "Shape2"

ADD OBJECT optiongroup1 AS optiongroup WITH ;
AutoSize = .T., ;
ButtonCount = 6, ;
Value = 1, ;
Height = 27, ;
Left = 19, ;
Top = 511, ;
Width = 119, ;
Name = "Optiongroup1", ;
Option1.Caption = "", ;
Option1.Value = 1, ;
Option1.Height = 17, ;
Option1.Left = 5, ;
Option1.Style = 0, ;
Option1.Top = 5, ;
Option1.Width = 18, ;
Option1.AutoSize = .T., ;
Option1.Name = "Option1", ;
Option2.Caption = "", ;
Option2.Height = 17, ;
Option2.Left = 24, ;
Option2.Style = 0, ;
Option2.Top = 5, ;
Option2.Width = 18, ;
Option2.AutoSize = .T., ;
Option2.Name = "Option2", ;
Option3.Caption = "", ;
Option3.Height = 17, ;
Option3.Left = 40, ;
Option3.Style = 0, ;
Option3.Top = 5, ;
Option3.Width = 18, ;
Option3.AutoSize = .T., ;
Option3.Name = "Option3", ;
Option4.Caption = "", ;
Option4.Height = 17, ;
Option4.Left = 59, ;
Option4.Style = 0, ;
Option4.Top = 5, ;
Option4.Width = 18, ;
Option4.AutoSize = .T., ;
Option4.Name = "Option4", ;
Option5.Caption = "", ;
Option5.Height = 17, ;
Option5.Left = 78, ;
Option5.Style = 0, ;
Option5.Top = 5, ;
Option5.Width = 18, ;
Option5.AutoSize = .T., ;
Option5.Name = "Option5", ;
Option6.Caption = "", ;
Option6.Height = 17, ;
Option6.Left = 96, ;
Option6.Top = 5, ;
Option6.Width = 18, ;
Option6.AutoSize = .T., ;
Option6.Name = "Option6"

ADD OBJECT check4 AS checkbox WITH ;
Top = 154, ;
Left = 16, ;
Height = 17, ;
Width = 77, ;
AutoSize = .T., ;
Alignment = 0, ;
Caption = "Ticks Grad", ;
Value = 1, ;
Name = "Check4"

ADD OBJECT command9 AS commandbutton WITH ;
Top = 310, ;
Left = 5, ;
Height = 20, ;
Width = 120, ;
Caption = "Out Border", ;
Enabled = .F., ;
Name = "Command9"

ADD OBJECT shape3 AS shape WITH ;
Top = 309, ;
Left = 130, ;
Height = 20, ;
Width = 48, ;
BorderStyle = 0, ;
BorderWidth = 0, ;
Curvature = 15, ;
MousePointer = 15, ;
BackColor = RGB(255,255,79), ;
Name = "Shape3"

ADD OBJECT check5 AS checkbox WITH ;
Top = 313, ;
Left = 184, ;
Height = 17, ;
Width = 18, ;
AutoSize = .T., ;
Alignment = 0, ;
Caption = "", ;
Value = 1, ;
Name = "Check5"


ADD OBJECT label9 AS label WITH ;
AutoSize = .T., ;
BackStyle = 0, ;
Caption = "Web img", ;
Height = 17, ;
Left = 141, ;
Top = 516, ;
Width = 51, ;
Name = "Label9"

PROCEDURE Init
with this
for i=1 to .controlcount
if inlist(lower(.controls(i).class),"label","commanbutton","spinner")
.controls(i).fontsize=8
endi
endfor
.label8.fontsize=32
.setall("backstyle",0,"label")
.setall("backstyle",0,"checkbox")
.setall("mousepointer",15,"commandbutton")
.setall("mousepointer",15,"checkBox")
endwith
ENDPROC

PROCEDURE spnangle.InteractiveChange
thisform.lnAngle=this.value
thisform.ycnt.imgcanvas1.Draw()
ENDPROC

PROCEDURE spnheight.InteractiveChange
thisform.ycnt.imgcanvas1.Draw()
ENDPROC

PROCEDURE spntopw.InteractiveChange
thisform.ycnt.imgcanvas1.Draw()
ENDPROC

PROCEDURE spnbottomw.InteractiveChange
thisform.ycnt.imgcanvas1.Draw()
ENDPROC

PROCEDURE shppointercolor.Click
LOCAL m.xColor
m.xColor = getcolor(this.backcolor)
IF  !m.xColor=-1
This.BackColor =m.xcolor
thisform.ycnt.imgcanvas1.draw
ENDIF
ENDPROC

PROCEDURE command1.Click
with this
.disabledbackcolor=rgb(0,0,255)
.disabledforecolor=255
endwith
ENDPROC

PROCEDURE shpbackcolor.Click
LOCAL m.xColor
m.xColor = getcolor(this.backcolor)
IF  !m.xColor=-1
thisform.ybrush=0
This.BackColor =m.xcolor
thisform.ycnt.imgcanvas1.draw
ENDIF
ENDPROC

PROCEDURE command2.Click
with this
.disabledbackcolor=rgb(0,0,255)
.disabledforecolor=255
endwith
ENDPROC

PROCEDURE spnticks.InteractiveChange
thisform.ycnt.imgcanvas1.Draw()
ENDPROC

PROCEDURE command3.Click
with this
.disabledbackcolor=rgb(0,0,255)
.disabledforecolor=255
endwith
ENDPROC

PROCEDURE shape1.Click
LOCAL m.xColor
m.xColor = getcolor(this.backcolor)
IF  !m.xColor=-1
This.BackColor =m.xcolor
thisform.ycnt.imgcanvas1.draw
ENDIF
ENDPROC

PROCEDURE command5.Click
LOCAL m.x
m.x = GETPict()
if  empty(m.x)
return .f.
endi
thisform.ybrush=1
thisform.xpict=m.x
thisform.ycnt.imgcanvas1.draw
ENDPROC

PROCEDURE command6.Click
local m.lcdest
m.lcdest=m.yrep+"images\y_"+sys(2015)+".png"
thisform.ycnt.imgcanvas1.oBMP.save(m.lcdest,_screen.system.drawing.Imaging.ImageFormat.PNG)
messagebox("Image saved as "+m.lcdest,0+32+4096,'Saved',1100)
ENDPROC


PROCEDURE command4.Click
for thisform.lnAngle=0 to 360 step 10
thisform.ycnt.imgcanvas1.draw()
endfor
ENDPROC

PROCEDURE command7.Click
rand(-1)
thisform.lnAngle=0
thisform.ycnt.imgcanvas1.draw()
inke(0.5)

m.u=0
for j=1 to 3
m.x=INT(360 * RAND( ) + 1)
for thisform.lnAngle=m.u to m.x   step m.x/10
thisform.ycnt.imgcanvas1.draw()
endfor
m.u=m.x
endfor
ENDPROC

PROCEDURE image1.Click
local m.oo
m.oo=m.yrep+"images"
run/n explorer &oo
ENDPROC

PROCEDURE command8.Click
thisform.ybrush=2
thisform.ycnt.imgcanvas1.draw
ENDPROC

PROCEDURE ysh1.Click
local m.xcolor
m.xcolor=getcolor()
if ! m.xcolor=-1
this.backcolor=m.xcolor
thisform.ybrush=2
thisform.ycnt.imgcanvas1.draw
endi
ENDPROC

PROCEDURE ysh2.Click
local m.xcolor
m.xcolor=getcolor()
if ! m.xcolor=-1
this.backcolor=m.xcolor
thisform.ybrush=2
thisform.ycnt.imgcanvas1.draw
endi
ENDPROC

PROCEDURE spinner1.InteractiveChange
with thisform.ycnt.imgcanvas1
.width =this.value
.height=.width
.left=(.parent.width-.width)/2
.top=(.parent.height-.height)/2
.draw
endwith
ENDPROC

PROCEDURE spinner1.Init
try
this.value=thisform.ycnt.imgcanvas1.width
catch
endtry
ENDPROC

PROCEDURE check2.InteractiveChange
thisform.ycnt.imgcanvas1.draw
ENDPROC

PROCEDURE label8.Click
local m.myvar
text to m.myvar pretext 7 noshow
this code draws a pure vfp9 radial gauge with the gdiplusX library.
it uses the imgcanvas of gdiplsuX class and system.app.gdiplusX stable version is the version 20 can be downloaded at vfp codeplex.
-can draws the circular gauge (square width=height)
-the contour can be drawn or removed (can choose the color)
-the graduations and the numeric ticks (can be set or removed).the ticks number can be set with spinner.
-the needle (can be modified by spinners:pointer color,backcolor,tick color,height,..).
-the zoom spinner can modify dynamically the dimensions of the gauge.
-the icon explorer can open the captured images folder.
-can set a picture as clipped background of the gauge.can choose to resize (to have on texture image) or no.
-can set a lineargradientbrush (2 colors) as background and set a center color or no.Repeat clicking to have many configurations colors.
-can anim the gauge (0-360° or a random animation).i remark this moving is some slow because i used a loop.
-can set the container color for visual contrast.
-can set web images downloaded and set as gauge background(in this case cut the ticks).image is resized.
-can expand/collapse the container command.
-rightclick on imgcanvas to save the gauge as png (or click commdbutton save).
endtext
*messagebox(m.myvar,0+32+4096,"summary help")
#define MB_ICONINFORMATION 0x00000040
#define MB_OK 0x00000000
#define MB_APPLMODAL 0x00000000
#define  MB_DEFBUTTON1 0x00000000

DECLARE INTEGER MessageBox IN user32 As MessageBoxA;
INTEGER hwnd,;
STRING  lpText,;
STRING  lpCaption,;
INTEGER wType

*buttons
#define MB_ABORTRETRYIGNORE 0x00000002
#define MB_CANCELTRYCONTINUE 0x00000006
#define MB_HELP 0x00004000

#define MB_OKCANCEL 0x00000001
#define MB_RETRYCANCEL 0x00000005
#define MB_YESNO  0x00000004
#define MB_YESNOCANCEL 0x00000003

*Icons
#define  MB_ICONEXCLAMATION 0x00000030
#define MB_ICONWARNING 0x00000030

#define MB_ICONASTERISK 0x00000040
#define MB_ICONQUESTION 0x00000020
#define MB_ICONSTOP 0x00000010
#define MB_ICONERROR 0x00000010
#define MB_ICONHAND  0x00000010

*To indicate the default button, specify one of the following values.

#define MB_DEFBUTTON2 0x00000100
#define MB_DEFBUTTON3 0x00000200
#define MB_DEFBUTTON4 0x00000300

*To indicate the modality of the dialog box, specify one of the following values.

#define MB_SYSTEMMODAL 0x00001000
#define MB_TASKMODAL 0x00002000

*To specify other options, use one or more of the following values.
#define MB_DEFAULT_DESKTOP_ONLY 0x00020000
#define MB_RIGHT 0x00080000
#define MB_RTLREADING  0x00100000
#define MB_SETFOREGROUND  0x00010000
#define MB_TOPMOST  0x00040000
#define MB_SERVICE_NOTIFICATION 0x00200000

*Return code
#define IDABORT 3
#define IDCANCEL 2
#define IDCONTINUE 11
#define IDIGNORE 5
#define IDNO 7
#define IDOK 1
#define IDRETRY 4
#define IDTRYAGAIN 10
#define IDYES 6
MessageBoxA(_vfp.hwnd,m.myvar,"A vfp9 gdiplusX gauge prototype.",MB_APPLMODAL+MB_OK +MB_ICONINFORMATION +MB_DEFBUTTON1 )
ENDPROC

PROCEDURE check3.InteractiveChange
thisform.ybrush=2
thisform.ycnt.imgcanvas1.draw
ENDPROC

PROCEDURE shape2.Click
*ycont backcolor: for visual contrast only
local m.xcolor
m.xcolor=getcolor()
if ! m.xcolor=-1
this.parent.backcolor=m.xcolor
endi
ENDPROC

PROCEDURE optiongroup1.Init
with this
.setall("caption","","OptionButton")
.setall("mousepointer",15,"OptionButton")
.autosize=.t.
.backstyle=0

for i=1 to .buttonCount
bindevent(.buttons(i),"mousedown",thisform,"my")
endfor

endwith
ENDPROC

PROCEDURE check4.InteractiveChange
thisform.ycnt.imgcanvas1.draw
ENDPROC

PROCEDURE command9.Click
with this
.disabledbackcolor=rgb(0,0,255)
.disabledforecolor=255
endwith
ENDPROC

PROCEDURE shape3.Click
LOCAL m.xColor
m.xColor = getcolor(this.backcolor)
IF  !m.xColor=-1
This.BackColor =m.xcolor
thisform.ycnt.imgcanvas1.draw
ENDIF
ENDPROC

PROCEDURE check5.InteractiveChange
thisform.ycnt.imgcanvas1.draw
ENDPROC


ENDDEFINE
*
*-- EndDefine: ycont


DEFINE CLASS ycnt0 AS container
Anchor = 15
Top = 12
Left = 300
Width = 720
Height = 612
BackStyle = 0
Name = "yCNt0"

ADD OBJECT imgcanvas1 AS imgcanvas  WITH ;
Anchor = 15, ;
Stretch = 2, ;
BackStyle = 0, ;
Height = 536, ;
Left = 4, ;
Top = 4, ;
Visible = .T., ;
Width = 556, ;
drawwheninvisible = .T., ;
Name = "Imgcanvas1"

PROCEDURE imgcanvas1.beforedraw
try
with this
.width=max(.width,.height)
.height=.width
endwith

LOCAL lnAngle,lnBaseW, lnBaseX, lnBaseY, lnTopW, lnHeightPercent, lnTopY
LOCAL lnPointClr, lnBackClr, lnTicks

lnTicks = Thisform.ycont.SpnTicks.Value
lnAngle = thisform.lnAngle     &&Thisform.ycont.SpnAngle.Value
lnBaseW = Thisform.ycont.SpnBottomW.Value
lnTopW  = Thisform.ycont.SpnTopW.Value
lnBaseX = This.Width/2 -lnBaseW/2
lnBaseY = This.Height/2
lnHeightPercent = Thisform.ycont.SpnHeight.Value / 100
lnTopY  = lnBaseY - (lnBaseY * lnHeightPercent) + lnTopW / 2
lnPointClr = Thisform.ycont.ShpPointerColor.BackColor
lnBackClr  = Thisform.ycont.ShpBackColor.BackColor

LOCAL loGfx as xfcGraphics
loGfx = This.oGfx


WITH _Screen.System.Drawing
* Set 2 properties, to ensure to have a better quality of image
loGfx.SmoothingMode = .Drawing2D.SmoothingMode.HighQuality
loGfx.InterpolationMode = .Drawing2D.InterpolationMode.HighQualityBicubic

LOCAL loBrush as xfcSolidBrush
loBrush = .SolidBrush.New(.Color.FromRGB(lnPointClr))

* Create a Shape for the pointer
LOCAL loPath as xfcGraphicsPath
loPath = .Drawing2D.GraphicsPath.New()
loPath.StartFigure()

loGfx.Clear(.Color.FromRGB(Thisform.BackColor))

do case
case thisform.ybrush=0
loGfx.fillEllipse(.SolidBrush.New(.Color.FromRGB(lnBackClr)),this.Rectangle)

case thisform.ybrush=1
if !empty(thisform.xpict)
img = .IMAGE.FromFile(thisform.xpict)
if thisform.ycont.check1.value=1
LOCAL img1 as xfcImage
img1 = img.GetThumbnailImage(this.Width, this.Height)
br = .TextureBrush.New(img1)
else
br=.TextureBrush.New(img)
endi
loGfx.fillEllipse(br,this.Rectangle)
endi

case thisform.ybrush=2
local nmode,color1,color2,br
m.nmode= INT(4 * RAND( ) )  &&random 0-1-2-3
color1=.color.fromRGB(thisform.ycont.ysh1.backcolor)
color2=.color.fromRGB(thisform.ycont.ysh2.backcolor)
*Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode
br = .drawing2d.LinearGradientBrush.New(this.Rectangle,color1,color2,m.nmode)
loGFX.FillEllipse(br,this.Rectangle)
br.Dispose()

if thisform.ycont.check3.value=1
xpath = .Drawing2D.GraphicsPath.New()
r=2*this.width/3
xpath.AddEllipse(this.width/2-r/2, this.height/2-r/2, r,r)
Local pgb As xfcPathGradientBrush
pgb=.Drawing2d.PathGradientBrush.new(xpath)
* Set the center point to a location that is not the centroid of the path.
ypoint=.pointF.new(this.width/2,this.height/2)

pgb.CenterPoint=ypoint   &&bug in gdiplusX
pgb.CenterColor=.color.fromARGB(255*rand(),255*rand(),255*rand(),0.8)
pgb.SurroundColors(1)=.color.fromARGB(255*rand(),255*rand(),255*rand(),0.8)
pgb.SurroundColors(2)=.color.fromARGB(255*rand(),255*rand(),255*rand(),1)
pgb.SurroundColors(3)=.color.fromARGB(255*rand(),255*rand(),255*rand(),0.6)
loGfx.Fillpath(@pgb, xpath)
pgb.Dispose()

endi

case thisform.ybrush=3
try

img= .bitmap.fromfile(thisform.xpict)
LOCAL img1 as xfcImage
img1 = img.GetThumbnailImage(this.Width+10, this.Height+10)
br = .TextureBrush.New(img1)
loGfx.fillEllipse(br,this.Rectangle)
catch
messagebox(thisform.xpict+" dont exist")
endtry


endcase

if thisform.ycont.check5.value=1
local xpen as xfcpen
xpen=.pen.new(.Color.fromRGB(thisform.ycont.shape3.backcolor),8)
yrect=.rectangle.new(4,4,this.width-8,this.height-8)
loGfx.DrawEllipse(xpen,yrect)
xpen.dispose()
endi

*needle
loPath.AddArc(lnBaseX, This.Height/2 -lnBaseW/2, lnBaseW, lnBaseW, 0, 180)
loPath.AddLine(lnBaseX, lnBaseY, This.Width/2 - lnTopW/2, lnTopY)
LOCAL laPoints(3)
laPoints(1) = .Point.New(This.Width/2 - lnTopW/2, lnTopY)
laPoints(2) = .Point.New(This.Width/2 , lnTopY - lnTopW / 2)
laPoints(3) = .Point.New(This.Width/2 + lnTopW/2, lnTopY)
loPath.AddCurve(@laPoints)
loPath.AddLine( This.Width/2 + lnTopW/2, lnTopY, lnBaseX + lnBaseW, lnBaseY)
loPath.CloseFigure()
* Rotate the shape pointer
loGfx.TranslateTransform(This.Width/2, This.Height/2)
loGfx.RotateTransform(lnAngle)
loGfx.TranslateTransform(- This.Width/2, - This.Height/2)
* Draw the pointer
loGfx.FillPath(loBrush, loPath)
ypen=.pen.new(.color.fromRGB(0,255,0),2)
loGfx.drawPath(ypen, loPath)
* Restore the original Gfx rotation state
loGfx.ResetTransform()

LOCAL loFont AS xfcFont
LOCAL loBrush AS xfcLinearGradientBrush
LOCAL loRectangleF As xfcRectangleF
LOCAL loSizeF AS xfcSizeF

if thisform.ycont.check4.value=1 and  lnTicks > 0
FOR lnAngle = 0 TO 360 STEP 360 / lnTicks
* Rotate the Gfx
loGfx.TranslateTransform(This.Width/2, This.Height/2)
loGfx.RotateTransform(lnAngle)
loGfx.TranslateTransform(- This.Width/2, - This.Height/2)

* Draw the ticks
open =.pen.new(.color.fromRGB(thisform.ycont.shape1.backcolor),6)
open1=.pen.new(.color.fromRGB(thisform.ycont.shape1.backcolor),2)

if mod(lnAngle,30)=0
loGfx.DrawLine(open, This.Width/2, 0, This.Width/2, 20)
else
loGfx.DrawLine(open1, This.Width/2, 0, This.Width/2, 10)
endi

*----->write lnANgle here
if thisform.ycont.check2.value=1
if inlist(M.lnAngle,0,45,90,135,180,225,270,315 )
ystring=trans(lnAngle)
loFont = .Font.New("Arial Black", 14,  .FontStyle.BoldItalic)
loSizeF = loGfx.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.New(This.Width/2-20, 20, This.Width/2-20, 20)
loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3)
loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
*loGfx.drawRectangle(.pen.new(.color.red,2),loRectangleF)
endi

endi
* Restore the original Gfx rotation state
loGfx.ResetTransform()
ENDFOR
ENDIF

loRect=.rectangle.new(this.width/2-10,this.height/2-10,20,20)
loGfx.fillEllipse(.SolidBrush.New(.Color.gold),loRect)


if thisform.ycont.check2.value=1
local oRect
ystring=trans(thisform.lnAngle)
loFont = .Font.New("Arial Black", 14,  .FontStyle.BoldItalic)
loSizeF = loGfx.MeasureString(ystring, loFont)
loRectangleF =.RectangleF.New((this.width-loSizeF.width)/2,this.height/2+loSizeF.height+20,loSizeF.Width, loSizeF.Height)
loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.red,.Color.green,3)
loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
loGfx.drawRectangle(.pen.new(.color.red,2),loRectangleF)

endi

ENDWITH
catch
endtry	
ENDPROC


PROCEDURE imgcanvas1.RightClick
thisform.ycont.command6.click()
ENDPROC


PROCEDURE imgcanvas1.afterdraw
with this
.width =this.width
.height=.width
.left=(.parent.width-.width)/2
.top=(.parent.height-.height)/2
endwith
ENDPROC


ENDDEFINE
*
*-- EndDefine: ycnt


screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.
screenshots captured from the code above.

screenshots captured from the code above.

can set gauges background as image with more simplicity and use only the needle for moving.
can set gauges background as image with more simplicity and use only the needle for moving.
can set gauges background as image with more simplicity and use only the needle for moving.
can set gauges background as image with more simplicity and use only the needle for moving.
can set gauges background as image with more simplicity and use only the needle for moving.
can set gauges background as image with more simplicity and use only the needle for moving.

can set gauges background as image with more simplicity and use only the needle for moving.

Click on code to select [then copy] -click outside to deselect

*2*
*posted on Foxite  14 of april 2009 - https://www.foxite.com/archives/foxchart-question-0000225822.htm
*a basic gauge (as posted)

set classlib to locfile("gdiplusX","vcx")
yform=createObject("asup")
yform.show
release classlib gdiplusX
read events
return
*
DEFINE CLASS asup AS form
	Top = 5
	Left = 147
	Height = 580
	Width = 595
	ShowWindow = 2
	DoCreate = .T.
	ShowTips = .T.
	BorderStyle = 2
	Caption = "gdiplusX  drawing a circular gauge"
	MaxButton = .F.
	BackColor = RGB(0,0,0)
	teta = 0
	delta = 10
	Name = "Form1"

	ADD OBJECT imgcanvas1 AS imgcanvas WITH ;
		Anchor = 15, ;
		Stretch = 2, ;
		Height = 540, ;
		Left = 0, ;
		Top = 0, ;
		Width = 600, ;
		Name = "Imgcanvas1"

	ADD OBJECT spinner1 AS spinner WITH ;
		Height = 24, ;
		InputMask = "999", ;
		KeyboardHighValue = 360, ;
		KeyboardLowValue = 0, ;
		Left = 269, ;
		SpinnerHighValue = 360.00, ;
		SpinnerLowValue =   0.00, ;
		ToolTipText = "gauge values", ;
		Top = 549, ;
		Width = 61, ;
		Name = "Spinner1"

	ADD OBJECT spinner2 AS spinner WITH ;
		Height = 24, ;
		KeyboardHighValue = 90, ;
		KeyboardLowValue = 0, ;
		Left = 120, ;
		SpinnerHighValue =  90.00, ;
		SpinnerLowValue =   0.00, ;
		ToolTipText = "Graduations", ;
		Top = 552, ;
		Width = 60, ;
		Value = 12, ;
		Name = "Spinner2"

	ADD OBJECT shape1 AS shape WITH ;
		Top = 550, ;
		Left = 8, ;
		Height = 20, ;
		Width = 20, ;
		MousePointer = 15, ;
		ToolTipText = "Grad color1", ;
		BackColor = RGB(0,255,0), ;
		bordercolor=rgb(255,255,255),;
		Name = "Shape1"

	ADD OBJECT shape2 AS shape WITH ;
		Top = 549, ;
		Left = 33, ;
		Height = 20, ;
		Width = 20, ;
		MousePointer = 15, ;
		ToolTipText = "Grad color2", ;
		BackColor = RGB(255,0,0), ;
				bordercolor=rgb(255,255,255),;
		Name = "Shape2"


	ADD OBJECT shape3 AS shape WITH ;
		Top = 547, ;
		Left = 451, ;
		Height = 20, ;
		Width = 20, ;
		MousePointer = 15, ;
		ToolTipText = "Needle color", ;
		BackColor = RGB(0,0,255), ;
				bordercolor=rgb(255,255,255),;
		Name = "Shape3"

	ADD OBJECT optiongroup1 AS optiongroup WITH ;
		AutoSize = .T., ;
		ButtonCount = 1, ;
		BackStyle = 0, ;
		Value = 1, ;
		Height = 27, ;
		Left = 516, ;
		MousePointer = 15, ;
		SpecialEffect = 0, ;
		Top = 543, ;
		Width = 66, ;
		ToolTipText = "Graduations", ;
		Name = "Optiongroup1", ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Values", ;
		Option1.Value = 1, ;
		Option1.Height = 17, ;
		Option1.Left = 5, ;
		Option1.Top = 5, ;
		Option1.Width = 56, ;
		Option1.AutoSize = .T., ;
		Option1.ForeColor = RGB(255,255,255), ;
		Option1.Name = "Option1"

	PROCEDURE Load
		*--Author Yousfi Benameur El Bayadh Algeria
		*--Time stamp Vendredi 24 avril 2009; 20:15:11
		*--Subject :drawing acircular gauge
	ENDPROC

	PROCEDURE Resize
		this.spinner1.top=this.height-this.spinner1.height-2
		this.spinner2.top=this.spinner1.top
		this.shape1.top=this.spinner1.top
		this.shape2.top=this.spinner1.top
		this.shape3.top=this.spinner1.top
		this.optionGroup1.top=this.spinner1.top
		this.imgcanvas1.height=this.spinner1.top-4
	ENDPROC


	PROCEDURE Destroy
		clea events
	ENDPROC

	PROCEDURE imgcanvas1.setup
		this.height=max(this.width,this.height)
		this.width=this.height
		this.parent.width=this.width
		this.parent.height=this.height+30
		thisform.teta=0
	ENDPROC


	PROCEDURE imgcanvas1.beforedraw
		logfx=this.ogfx
		with _screen.system.drawing
		this.clear(.color.black)
	
		pen=.pen.new(.color.white,5)
		delta=thisform.delta
		loRect=.rectangle.new(delta,delta,this.width-2*delta,this.height-2*delta)
		logfx.drawEllipse(pen,lorect)

		if thisform.spinner2.value>0
		&&graduations
		r=(this.width/2-20)/2
		pen=.pen.new(.color.gold,2)

		r=(this.width-25)/2
		for i=0 to 2*pi() step pi()*thisform.delta/180
		if i>=2*pi()
		exit
		endi
		pp0=.point.new(this.width/2+0.9*r*cos(i),this.height/2+0.9*r*sin(i))
		pp1=.point.new(this.width/2+(r)*cos(i),this.height/2+(r)*sin(i))
		logfx.drawline(pen,pp0,pp1)
		endfor

		lorect1=.rectangle.new(40,40,this.width-2*40,this.height-2*40)
		color1=.color.fromRGB(thisform.shape1.backcolor)
		color2=.color.fromRGB(thisform.shape2.backcolor)
		br = .Drawing2D.LinearGradientBrush.New(loRect1,color1,Color2,90,.t.)
		logfx.fillEllipse(br,loRect1)
		endi

		r=(2*this.width/6)
		p0=.point.new(this.width/2,this.height/2)
		p00=.point.new(this.width/2-(40)*cos(-pi()/2+thisform.teta),this.height/2-40*sin(-pi()/2+thisform.teta))
		p1=.point.new(this.width/2+(r)*cos(-pi()/2+thisform.teta),this.height/2+(r)*sin(-pi()/2+thisform.teta))
		*pen=.pen.new(.color.blue,10)
		pen=.pen.new(.color.fromRGB(thisform.shape3.backcolor),10)
		logfx.drawline(pen,p00,p1)
		orect=.rectangle.new(this.width/2-15,this.height/2-15,30,30)
		logfx.fillellipse(.solidbrush.new(.color.green),orect)
		pen=.pen.new(.color.red,8)
		logfx.drawellipse(pen,orect)
	
		&&graduations numbers
		if thisform.optiongroup1.value=1
		if thisform.spinner2.value>8
		pen=.pen.new(.color.gold,2)
		r=(this.width-80)/2
		for i=0 to 2*pi() step pi()*thisform.delta/180
		if i>=2*pi()
		exit
		endi

		x=this.width/2+(r)*cos(-pi()/2-i)
		y=this.height/2+(r)*sin(-pi()/2-i)

		ygrad=trans( round(( 360-(180/pi())*i),0))
		if ygrad="360"
		ygrad="0"
		endi
		   loFont = .Font.New("tahoma", 7,  .FontStyle.Bold)
			loSizeF = loGfx.MeasureString(ygrad, loFont)
			loRectangleF =_screen.system.Drawing.RectangleF.New(x-losizeF.width/2,y,loSizeF.Width, loSizeF.Height)
			loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.white,.Color.white,3)
			loGfx.DrawString(ygrad, loFont,loBrush, loRectangleF)
		endfor
		endi
		endi

		ystring="wind:" +trans( round(( 180/pi())*thisform.teta,0))+" degree(s)"
		   loFont = .Font.New("tahoma", 20,  .FontStyle.BoldItalic)
			loSizeF = loGfx.MeasureString(ystring, loFont)
			loRectangleF =_screen.system.Drawing.RectangleF.New((this.width-loSizeF.width)/2,loSizeF.height+3*this.height/5,loSizeF.Width, loSizeF.Height)
			loBrush = .Drawing2D.LinearGradientBrush.New(loRectangleF,.Color.cyan,.Color.white,3)
			loGfx.DrawString(ystring, loFont,loBrush, loRectangleF)
			pen=.pen.new(.color.gold,2)
		logfx.drawrectangle(pen,loRectangleF)
		endwith
		retu
	ENDPROC

	PROCEDURE spinner1.InteractiveChange
		thisform.teta=(this.value)*pi()/180
		if this.value>=360
		this.value=0
		endi
		thisform.imgcanvas1.draw
	ENDPROC

	PROCEDURE spinner2.InteractiveChange
		thisform.delta=this.value
		thisform.imgcanvas1.draw
	ENDPROC

	PROCEDURE shape1.Click
		this.backcolor=getcolor()
		if empty(this.backcolor)
		this.backcolor=rgb(0,255,0)
		endi
		thisform.imgcanvas1.draw
	ENDPROC

	PROCEDURE shape2.Click
		this.backcolor=getcolor()
		if empty(this.backcolor)
		this.backcolor=255
		endi
		thisform.imgcanvas1.draw
	ENDPROC

	PROCEDURE shape3.Click
		this.backcolor=getcolor()
		if empty(this.backcolor)
		this.backcolor=rgb(0,0,255)
		endi
		thisform.imgcanvas1.draw
	ENDPROC

	PROCEDURE optiongroup1.InteractiveChange
		thisform.imgcanvas1.draw
	ENDPROC
ENDDEFINE


A VFP9 gdiplusX gauge prototype
A VFP9 gdiplusX gauge prototype

Important:All Codes above are tested on VFP9SP2 & windows 10 pro .

To be informed of the latest articles, subscribe:
Comment on this post