Jump to content

RMChart in AutoIt


gcriaco
 Share

Recommended Posts

RMChart is a freeware tool to create a various range of charts.

You may either use the DLL-Version or the ActiveX-Version.

I'd like to use the ActiveX one (more simpler) but:

there is no VersionIndependentProgID info for instantiating the object in AutoIt.

Any experience/suggestion in the matter?

Below there is an example code (not working):

$oShell = ObjCreate("RMChart.RMChartX")
If @error = 1 and $oShell = 0 Then
    MsgBox(16,"Error Message",'ObjCreate("RMChart.RMChartX")')
    Exit
Else
    MsgBox(0,"RMChart",$oShell)
EndIf

if Not Isobj($oShell) then
    MsgBox(16,"Error Message",'No Object created')
    Exit
EndIf

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler

; COM Error Handler example
; ------------------------- 

With $oShell
;~      '************** Design the chart **********************
    .Reset
    .Font = "Comic Sans MS"
    .RMCBackColor = "AliceBlue"
    .RMCStyle = "RMC_CTRLSTYLEFLAT"
    .RMCWidth = 600
    .RMCHeight = 450
    
;~  '************** Add Region 1 *****************************
    .AddRegion
    $oShell.AddRegion.Region(1).Left = 5
    $oShell.AddRegion.Region(1).Top = 5
    $oShell.AddRegion.Region(1).Width = -5
    $oShell.AddRegion.Region(1).Height = -5
    $oShell.AddRegion.Region(1).Footer = ""
;~      
;~      '************** Add caption to region 1 *******************
    .AddCaption
    $oShell.AddCaption.Caption.Titel = "This is the chart's caption"
    $oShell.AddCaption.Caption.BackColor = "Blue"
    $oShell.AddCaption.Caption.TextColor = "Yellow"
    $oShell.AddCaption.Caption.FontSize = 11
    $oShell.AddCaption.Caption.Bold = True
;~          
;~      '************** Add grid to region 1 *****************************
    .AddGrid
    $oShell.AddGrid.Grid.BackColor = "Beige"
    $oShell.AddGrid.Grid.AsGradient = False
    $oShell.AddGrid.Grid.BicolorMode = "RMC_BICOLOR_LABELAXIS"
    $oShell.AddGrid.Grid.Left = 0
    $oShell.AddGrid.Grid.Top = 0
    $oShell.AddGrid.Grid.Width = 0
    $oShell.AddGrid.Grid.Height = 0
;~      
;~      '************** Add data axis to region 1 *****************************
;~      .AddDataAxis
;~      With $oShell.AddDataAxis.DataAxis(1)
;~          .Alignment = "RMC_DATAAXISLEFT"
;~          .MinValue = 0
;~          .MaxValue = 100
;~          .TickCount = 11
;~          .FontSize = 8
;~          .TextColor = "Black"
;~          .LineColor = "Black"
;~          .LineStyle = "RMC_LINESTYLEDOT"
;~          .DecimalDigits = 0
;~          .AxisUnit = ""
;~          .AxisText = ""
;~      EndWith ;DataAxis(1)
;~      
;~      '************** Add label axis to region 1 *****************************
;~      .AddLabelAxis
;~      With $oShell.AddLabelAxis.LabelAxis
;~          .AxisCount = 1
;~          .TickCount = 5
;~          .Alignment = "RMC_LABELAXISBOTTOM"
;~          .FontSize = 8
;~          .TextColor = "Black"
;~          .TextAlignment = "RMC_TEXTCENTER"
;~          .LineColor = "Black"
;~          .LineStyle = "RMC_LINESTYLENONE"
;~          $sTemp = "Label 1*Label 2*Label 3*Label 4*Label 5"
;~          .LabelString = $sTemp
;~      EndWith ;LabelAxis

;~      '************** Add Series 1 to region 1 *******************************
;~      .AddBarSeries
;~      With $oShell.AddBarSeries.BarSeries(1)
;~          .SeriesType = "RMC_BARSINGLE"
;~          .SeriesStyle = "RMC_BAR_FLAT_GRADIENT2"
;~          .Lucent = False
;~          .Color = "CornflowerBlue"
;~          .Horizontal = False
;~          .WhichDataAxis = 1
;~          .ValueLabelOn = False
;~          .PointsPerColumn = 1
;~          .HatchMode = "RMC_HATCHBRUSH_OFF"
;~          '****** Set data values ******
;~          $sTemp = "50*70*40*60*30"
;~          .DataString = $sTemp
;~          
;~          .SetColorValue 3, "Red"      ; Set the color for the third bar to Red
;~      EndWith ;BarSeries(1)

    $nRetval = .Draw
Endwith


; This is my custom defined error handler
Func MyErrFunc()

  $HexNumber=hex($oMyError.number,8)    ; for displaying purposes
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

Many thanks

Peppe

Link to comment
Share on other sites

RMChart is a freeware tool to create a various range of charts.

You may either use the DLL-Version or the ActiveX-Version.

I'd like to use the ActiveX one (more simpler) but:

there is no VersionIndependentProgID info for instantiating the object in AutoIt.

Any experience/suggestion in the matter?

Below there is an example code (not working):

;AutoIt Code...

Many thanks

Peppe

Peppe,

I am not sure I am grasping what it is you are needing, and I believe that is why you havent recieved any responses.

Where are you needing VersionIndependentProgID? I am not sure if this is a part of RMChart that you cant figure out how to access, or a part of Windows you dont know how to find.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Peppe,

I am not sure I am grasping what it is you are needing, and I believe that is why you havent recieved any responses.

Where are you needing VersionIndependentProgID? I am not sure if this is a part of RMChart that you cant figure out how to access, or a part of Windows you dont know how to find.

JS

The AutoIt Helpfile, "COM Extensions to AutoIt", says:

"Most important is the "VersionIndependentProgID". This is the name to be used in an ObjCreate,...".

So, I used the oleview tool to finf this info, but it seems to me that it doesn't exist, and then likely I use the CreateObj funcion with the wrong classname. BTW, it's the same classname detected by Koda (Obj Inspector), and then the problem could be another one, maybe the ActiveX object is incompatible with AutoIt.

RMChart works very fine with other languages.

IMHO RMChart is a very impressive and useful tool, so I hope that some Autoitter tries it with success.

Here is another sample (not working):

#include <GUIConstants.au3>

$Form1 = GUICreate("AForm1", 470, 367, 193, 115)
$Obj1 = ObjCreate("RMChart.RMChartX")
If @error = 1 and $Obj1 = 0 Then
    MsgBox(16,"Error Message",'ObjCreate("RMChart.RMChartX")')
    Exit
Else
;~  MsgBox(0,"RMChart",$Obj1)
EndIf

if Not Isobj($Obj1) then
    MsgBox(16,"Error Message",'No Object created')
    Exit
EndIf

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")    ; Initialize a COM error handler

$Obj1_ctrl = GUICtrlCreateObj($Obj1, 72, 40, 376, 248)
$btnStart = GUICtrlCreateButton("&Start", 352, 312, 97, 33, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        Case $btnStart
            With $Obj1          ;~      '************** Design the chart **********************
                .Reset
                .Font = "Comic Sans MS"
                .RMCBackColor = "AliceBlue"
                .RMCStyle = "RMC_CTRLSTYLEFLAT"
                .RMCWidth = 600
                .RMCHeight = 450
                
            ;~  '************** Add Region 1 *****************************
                .AddRegion
                $Obj1.AddRegion.Region(1).Left = 5
                $Obj1.AddRegion.Region(1).Top = 5
                $Obj1.AddRegion.Region(1).Width = -5
                $Obj1.AddRegion.Region(1).Height = -5
                $Obj1.AddRegion.Region(1).Footer = ""
            ;~      
            ;~      '************** Add caption to region 1 *******************
                .AddCaption
                $Obj1.AddCaption.Caption.Titel = "This is the chart's caption"
                $Obj1.AddCaption.Caption.BackColor = "Blue"
                $Obj1.AddCaption.Caption.TextColor = "Yellow"
                $Obj1.AddCaption.Caption.FontSize = 11
                $Obj1.AddCaption.Caption.Bold = True
            ;~          
            ;~      '************** Add grid to region 1 *****************************
                .AddGrid
                $Obj1.AddGrid.Grid.BackColor = "Beige"
                $Obj1.AddGrid.Grid.AsGradient = False
                $Obj1.AddGrid.Grid.BicolorMode = "RMC_BICOLOR_LABELAXIS"
                $Obj1.AddGrid.Grid.Left = 0
                $Obj1.AddGrid.Grid.Top = 0
                $Obj1.AddGrid.Grid.Width = 0
                $Obj1.AddGrid.Grid.Height = 0
            ;~      
            ;~      '************** Add data axis to region 1 *****************************
            ;~      .AddDataAxis
            ;~      With $Obj1.AddDataAxis.DataAxis(1)
            ;~          .Alignment = "RMC_DATAAXISLEFT"
            ;~          .MinValue = 0
            ;~          .MaxValue = 100
            ;~          .TickCount = 11
            ;~          .FontSize = 8
            ;~          .TextColor = "Black"
            ;~          .LineColor = "Black"
            ;~          .LineStyle = "RMC_LINESTYLEDOT"
            ;~          .DecimalDigits = 0
            ;~          .AxisUnit = ""
            ;~          .AxisText = ""
            ;~      EndWith ;DataAxis(1)
            ;~      
            ;~      '************** Add label axis to region 1 *****************************
            ;~      .AddLabelAxis
            ;~      With $Obj1.AddLabelAxis.LabelAxis
            ;~          .AxisCount = 1
            ;~          .TickCount = 5
            ;~          .Alignment = "RMC_LABELAXISBOTTOM"
            ;~          .FontSize = 8
            ;~          .TextColor = "Black"
            ;~          .TextAlignment = "RMC_TEXTCENTER"
            ;~          .LineColor = "Black"
            ;~          .LineStyle = "RMC_LINESTYLENONE"
            ;~          $sTemp = "Label 1*Label 2*Label 3*Label 4*Label 5"
            ;~          .LabelString = $sTemp
            ;~      EndWith ;LabelAxis

            ;~      '************** Add Series 1 to region 1 *******************************
            ;~      .AddBarSeries
            ;~      With $Obj1.AddBarSeries.BarSeries(1)
            ;~          .SeriesType = "RMC_BARSINGLE"
            ;~          .SeriesStyle = "RMC_BAR_FLAT_GRADIENT2"
            ;~          .Lucent = False
            ;~          .Color = "CornflowerBlue"
            ;~          .Horizontal = False
            ;~          .WhichDataAxis = 1
            ;~          .ValueLabelOn = False
            ;~          .PointsPerColumn = 1
            ;~          .HatchMode = "RMC_HATCHBRUSH_OFF"
            ;~          '****** Set data values ******
            ;~          $sTemp = "50*70*40*60*30"
            ;~          .DataString = $sTemp
            ;~          
            ;~          .SetColorValue 3, "Red"      ; Set the color for the third bar to Red
            ;~      EndWith ;BarSeries(1)

                $nRetval = .Draw
            Endwith
    EndSwitch
WEnd


; This is my custom defined error handler
Func MyErrFunc()

  $HexNumber=hex($oMyError.number,8)    ; for displaying purposes
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF _
            )
  SetError(1)  ; to check for after this function returns
Endfunc
Edited by gcriaco
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...