Class to rmchart.dll

652 views
Skip to first unread message

JoséQuintas

unread,
May 30, 2016, 1:36:23 PM5/30/16
to Harbour Users
Download rmchart, install DLL, and enjoy.
You can use VB6 samples as reference.

Sample test using GTWVG can be downloaded here:
http://www.jpatecnologia.com.br/arquivos/testrmchart.zip

#require hbct.ch
#include "hbclass.ch"
#include "hbdyn.ch"
#include "rmchart.ch"

CREATE CLASS RmChart

VAR nHandle

METHOD New() INLINE ::nHandle :=
hb_libLoad( "RMChart.dll" ), SELF
METHOD Destroy() INLINE hb_libFree( ::nHandle )
METHOD CreateChart( ... ) INLINE ::CallDllStd(
"RMC_CREATECHART", ... )
METHOD CreateChartOnDc( ... ) INLINE ::CallDllStd(
"RMC_CREATECHARONDC", ... )
METHOD AddBarSeries(a,b,c, ... ) INLINE ::CallDllStd(
"RMC_ADDBARSERIES", a, b, ::ToDouble(c), ... )
METHOD AddRegion( ... ) INLINE ::CallDllStd(
"RMC_ADDREGION", ... )
METHOD AddCaption( ... ) INLINE ::CallDllStd(
"RMC_ADDCAPTION", ... )
METHOD AddDataAxis(a,b,c,d,e, ... ) INLINE ::CallDllStd(
"RMC_ADDDATAAXIS", a, b, c, ::ToDecimal(d), ::ToDecimal(e), ... )
METHOD AddGrid( ... ) INLINE ::CallDllStd(
"RMC_ADDGRID", ... )
METHOD AddGridLessSeries(a,b,c,d,e,...) INLINE ::CallDllStd(
"RMC_ADDGRIDLESSSERIES", a, b, ::ToDouble(c), d, ::ToDouble(e), ... )
METHOD AddLabelAxis( ... ) INLINE ::CallDllStd(
"RMC_ADDLABELAXIS", ... )
METHOD AddLegend( ... ) INLINE ::CallDllStd(
"RMC_ADDLEGEND", ... )
METHOD AddLineSeries( a,b,c, ... ) INLINE ::CallDllStd(
"RMC_ADDLINESERIES", a, b, ::ToDouble(c), ... )
METHOD DeleteChart( ... ) INLINE ::CallDllStd(
"RMC_DELETECHART", ... )
METHOD Draw( ... ) INLINE ::CallDllStd(
"RMC_DRAW", ... )
METHOD Draw2Clipboard( ... ) INLINE ::CallDllStd(
"RMC_DRAW2CLIPBOARD", ... )
METHOD Draw2Printer( ... ) INLINE ::CallDllStd(
"RMC_DRAW2PRINTER", ... )
METHOD Draw2File( ... ) INLINE ::CallDllStd(
"RMC_DRAW2FILE", ... )
METHOD Reset( ... ) INLINE ::CallDllStd(
"RMC_RESET", ... )
METHOD SetWaterMark( ... ) INLINE ::CallDllStd(
"RMC_SETWATERMARK", ... )
METHOD WriteRMCFile( ... ) INLINE ::CallDllStd(
"RMC_WRITERMCFILE", ... )
METHOD CallDllStd( cName, ... ) INLINE hb_DynCall( { cName,
::nHandle, HB_DYN_CALLCONV_STDCALL }, ... )
METHOD ToDecimal( xValue ) INLINE xValue + 1.01 - 1.01
METHOD ToDouble( xValue )

ENDCLASS

METHOD RMChart:ToDouble( xValue )

LOCAL cDouble := "", oElement

IF ValType( xValue ) == "N"
RETURN xValue
ENDIF
FOR EACH oElement IN xValue
cDouble += FToC( oElement )
NEXT

RETURN cDouble

José M. C. Quintas

testrmchart.png

Pritpal Bedi

unread,
May 31, 2016, 3:10:02 PM5/31/16
to Harbour Users
Thanks Jose

Download rmchart, install DLL, and enjoy.  
You can use VB6 samples as reference.

Sample test using GTWVG can be downloaded here:
http://www.jpatecnologia.com.br/arquivos/testrmchart.zip


I am using rmchart through active-x interface which sucks at times.
Your solution, exploiting .dll directly will greatly enhance my productivity.
I plan to exploit it many different ways.

Thanks again.


Pritpal Bedi
a student of software analysis & concepts 

JoséQuintas

unread,
May 31, 2016, 5:03:22 PM5/31/16
to harbou...@googlegroups.com
I think RMChart do not prevents wrong use, or wrong parameters type, then when this occurs, get GPF.
For sure, I do not test all possibilities.
Maybe there are another chart types that need same conversion on any parameter.

GPF occurs too, if try unload RMChart without unload chart/data.

Attention:
VB6 samples uses CreateChartOnDc(). (same on RMDesigner - get source)
CreateChart() need additional parameter 0 before last parameter (for tooltip).
Without this parameter, causes GPF.

José M. C. Quintas
--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

José Quintas

unread,
May 31, 2016, 5:08:53 PM5/31/16
to Harbour Users
"Maybe there are another chart types that need same conversion on any parameter"

This is about integer, long, double, decimal, double array conversion.
Solve this using ::ToDouble() and ::ToDecimal(), but may be there are a better solution.

José M. C. Quintas

JoséQuintas

unread,
Jun 2, 2016, 10:31:10 AM6/2/16
to harbou...@googlegroups.com
Need a change on Color array:
Previous FToc() causes wrong color on pie charts
Changed to L2Bin()

METHOD AddGridLessSeries(a,b,c,d,e,...) INLINE ::CallDllStd(
"RMC_ADDGRIDLESSSERIES", a, b, ::ToDouble(c), d, ::ToSignedLong(e), ... )

METHOD RMChart:ToSignedLong( xValue )

LOCAL cLong := "", oElement

IF ValType( xValue ) == "N"
RETURN xValue
ENDIF
FOR EACH oElement IN xValue
cLong += L2Bin( oElement )
NEXT
RETURN cLong

José M. C. Quintas


Em 31/05/2016 16:10, Pritpal Bedi escreveu:
> Thanks Jose
>

José Quintas

unread,
Jun 2, 2016, 3:00:29 PM6/2/16
to Harbour Users
Em segunda-feira, 30 de maio de 2016 14:36:23 UTC-3, José M. C. Quintas escreveu:
You can use VB6 samples as reference.


My mistake.
To be compatible with VB6 samples, call to DLL may be compatible too.

Example:

Declare Function RMC_AddCaption Lib "RMCHART.DLL" Alias "RMC_ADDCAPTION" ( _
                            ByVal nCtrlId As Long, _
                            ByVal nRegion As Long, _
                            Optional ByVal sCaption As String, _
                            Optional ByVal nTitelBackColor As RMC_Colors, _
                            Optional ByVal nTitelTextColor As RMC_Colors, _
                            Optional ByVal nTitelFontSize As Long, _
                            Optional ByVal nTitelIsBold As Long _
                            ) As RMCError

parameters are optional for VB, not for DLL. VB assume empty values before call dll.

METHOD AddCaption( ... ) INLINE CallDllStd( "RMC_ADDCAPTION", ... )

It is compatible (and more secure) to use:

METHOD AddCaption( nCtrlId, nRegion, sCaption, nTitleBackColor, nTitleTextColor, nTitleFontSize, nTitleIsBold )
   hb_Default( @sCaption, "" )
   hb_Default( @nTitleBackColor, 0 )
   hb_Default( @nTitleTextColor, 0 )
   hb_Default( @nTitleFontSize, 0 )
   hb_Default( @nTitleIsBold, .F. )
   RETURN ::CallDllStd( nCtrlId, nRegion, sCaption, nTitleBackColor, nTitleTextColor, nTitleFontSize, nTitleIsBold )

DLL need all parameters.
On VB samples, optional parameters are not used, but dll declaration uses default.

If do not fill default values on Harbour, and samples do not have them, causes GPF.

José M. C. Quintas


JoséQuintas

unread,
Jun 2, 2016, 3:06:23 PM6/2/16
to Harbour Users

Em 02/06/2016 16:00, José Quintas escreveu:
> RETURN ::CallDllStd( nCtrlId, nRegion, sCaption, nTitleBackColor,
> nTitleTextColor, nTitleFontSize, nTitleIsBold )

Correction:

RETURN ::CallDllStd( "RMC_ADDCAPTION", nCtrlId, nRegion, sCaption,
nTitleBackColor, nTitleTextColor, nTitleFontSize, nTitleIsBold )

José M. C. Quintas

JoséQuintas

unread,
Jun 3, 2016, 4:54:14 PM6/3/16
to harbou...@googlegroups.com
Hi

Em 31/05/2016 16:10, Pritpal Bedi escreveu:
> Thanks Jose
>
> I am using rmchart through active-x interface which sucks at times.
> Your solution, exploiting .dll directly will greatly enhance my
> productivity.
> I plan to exploit it many different ways.
>

My sample do not works on Harbour 3.2.
I do not know what control to use in place of tstRectangle. (my own
control).

I created a second sample of rmchart with more charts, add more
#defines, and more rmchart.dll functions (there are too many functions).
You can download it on http://www.jpatecnologia.com.br/testrmchart.zip
or on folder rmchart here: https://github.com/JoseQuintas/AllInOne

Note:

When I created tstRectangle, a single empty control, I do not think it
would be usefull to anything like this.

Pritpal

GTWVG is great.
Viktor changes, making Windows API call/retrieve compatible with PRG
code expand possibilities.

José M. C. Quintas
Reply all
Reply to author
Forward
0 new messages