unLTVX=1440/liPixelsPerInchX unLTVY=1440/liPixelsPerInchY>This is something Sergey had helped me with - but he must be taking Sunday off! The big thing I learned so far from Sergey was in regards to passing paramenters to UDFs as references (eg so they would return a value - see @iPart below). The demo below needs to return a parameter passed by reference (i think) to MSChart's
TwipstoChartPart
method. I would like to know how to determine if this method is "really" exposed to VFP - and if it is, how to make it work. If anyone knows this will not work, or could help me make it work (Windows API functions - maybe), I would be most appreciative - I would be willing to do a few hours of grunge work in exchange. What follows below are my most recent pleas to Sergey.* Twipper.PRG (terry) >SET EXACT ON >DeclareWindowsAPIFunctions() >PUBLIC myform as Form, unLTVX, unLTVY, iPart As Integer, iseries As Integer,; > idatapoint As Integer,ix1 as integer, ix2 as integer, ix3 As Integer,; > ix4 As Integer,lUseTwipsToPixels >STORE 0 TO iPart,iseries,idatapoint,ix1,ix2,ix3,ix4 >GetDisplayMetrics() >lUseTwipsToPixels=.t. && Use Twips to pixel convertion - else - use pixels (X,Y) >myform=CREATEOBJECT('frmTwipper') >myform.show > >DEFINE CLASS frmTwipper as form >height=600 >width=800 >autocenter=.t. >borderstyle=2 >PROCEDURE release >this.queryunload >ENDPROC >PROCEDURE init >this.cntChart.width=this.Width >this.cntChart.Height=this.height >ENDPROC >PROCEDURE QueryUnload >CLEAR EVENTS >ENDPROC > >PROCEDURE resize >ENDPROC >ADD OBJECT cntChart as cntChartClass >visible=.t. >ENDDEFINE &&frmTwipper > >DEFINE CLASS cntChartClass as Container >top=0 >left=0 >backstyle=1 >backcolor=RGB(255,255,255) >borderwidth=1 >procedure init >with this.ocxChart >.width=thisform.width-2 >.height=thisform.height-2 >.ChartType = 3 && VtChChartType2dLine >.AllowDithering = .f. >.AllowSelections = .f. >.AutoIncrement = .f. >.AllowDynamicRotation = .f. >.AllowSeriesSelection = .f. >.COLUMNCOUNT = 1 >.RowCount = 8 >.Backdrop.Fill.Style= 1 && VtFillStyleBrush > with .Backdrop.Fill.Brush.FillColor > .red=255 > .green=255 > .blue=255 > ENDWITH &&.Backdrop.Fill.Brush.FillColor >*!* Populate the DataGrid Object. >FOR lnCol = 1 TO 1 > FOR lnRow = 1 TO 8 > .COLUMN = lnCol > .ROW = lnRow > .DATA = lnRow * 10 > NEXT ROW >NEXT COLUMN >*!* Use the chart as the backdrop of the legend. >.ShowLegend = .T. >.visible=.t. >ENDWITH &&this.ocxChart >ENDPROC &&Init >PROCEDURE resize >ENDPROC >ADD OBJECT ocxChart as ocxChartClass >visible=.t. >ENDDEFINE &&cntChartClass > >define class ocxChartClass as Olecontrol >OleClass="MSChart20Lib.MSChart.2" >BorderStyle=1 >top=1 >left=1 >PROCEDURE init >ENDPROC >PROCEDURE MouseMove(Button, Shift, X, Y) >*!* LOCAL iPart As Integer, iseries As Integer, idatapoint As Integer,; >*!* ix1 as integer, ix2 as integer, ix3 As Integer, ix4 As Integer >*!* STORE 0 TO iPart,iseries,idatapoint,ix1,ix2,ix3,ix4 >lnX=IIF(lUseTwipsToPixels,x*unLTVX,x) >lnY=IIF(lUseTwipsToPixels,y*unLTVY,x) >*!* this.object.SelectPart(4, 0, 0, 0, 0) >this.object.TwipsToChartPart( lnX, lnY, iPart, ix1, ix2, ix3, ix4) >thisform.caption=PROGRAM(0)+[ - Pixels: ]+TRANSFORM(x)+[, ]+TRANSFORM(y); > +[ - Twips : ]+TRANSFORM(x*unLTVX)+[, ]+TRANSFORM(y*unLTVY); > +[ - TwipsToChartPart : ]+TRANSFORM(iPart) >ENDPROC >ENDDEFINE &&ocxChartClass > >PROCEDURE DeclareWindowsAPIFunctions() >declare integer GetActiveWindow in WIN32API >declare integer GetDC in WIN32API integer iHDC >declare integer GetDeviceCaps in WIN32API integer iHDC,integer iIndex >ENDPROC &&R6_PSA_DeclareWindowsAPIFunctions > >procedure GetDisplayMetrics() >local liHwnd,liHDC,liPixelsPerInchX,liPixelsPerInchY >liHwnd=GetActiveWindow() >liHDC=GetDC(liHwnd) >* Pixels per Inch >liPixelsPerInchX=GetDeviceCaps(liHDC,88) >liPixelsPerInchY=GetDeviceCaps(liHDC,90) >* Twips per pixel and store >unLTVX=1440/liPixelsPerInchX >unLTVY=1440/liPixelsPerInchY >ENDPROC &&GetDisplayMetrics() >* END OF TWIPPER.PRGAnd below is the cleaner script
* RS (RS.PRG) ReSet environment >* When the program breaks on a UDFPARMS error >* Type DO RS in command window to clear beforw >* edit and and re-test. >use >clear all >close all >rele all >on error >* END OF RS.PRG>
TwipstoChartPart
method cannot be properly exposed in VFP. Being Mr. POY (again) is a heavy cross to bare!