A
atpgroups
I am creating a specialised form or chart (an XY plot with the
underside of the curve forming a colour map of Z values, with
contours)
The chart is embedded in a class module which handles the extra
features (a whole lot of coloured polygons and lines added to the
chart's shapes collection)
When the axis limits are changed by the user, then the colour map
needs to be replotted. I can trap the chart events but none of them
seem to trigger when the user changes the axis limits. (unless one of
you knows better).
Plan B is an "Update Plot" context menu on the shapes collection. That
is actually pretty easy:
Private Sub ch_BeforeRightClick(Cancel As Boolean)
CommandBars("Shapes").Reset
With CommandBars("Shapes").Controls.Add
..Caption = "Update Plot"
..OnAction = ????????????????
End With
End Sub
However, getting the OnAction to call the correct subroutine in the
correct instance of the class is baffling me.
The event handler code is running in the correct instance, so I can
just update the plot on every right-click, but it is fairly time-
consuming so would prefer to do it only if the user selects the option
in the menu.
I think I want to set OnAction to be a sub in a standard module,
passed a link to the correct instance of the class module to run an
update method by the event handler. But I am getting in a terrible
muddle, and can't figure it out.
I suspect I might be trying to do the impossible, as you can only pass
a string in an OnAction parameter, and that probably isn't enough to
allow a standard module subroutine call a method of a specific
instance of a class.
Is it possible to iterate through all instances of a class looking for
one that contains ActiveChart? sort of like
For Each MyClass in <The current Scope>
if MyClass.EmbededChart.Name = ActiveChart.Name then
MyClass.UpDatePlot
Endif
Next
Perhaps I need to cancel the standard context menu, drop down my own,
and act on it internally to the instance of the class module?
underside of the curve forming a colour map of Z values, with
contours)
The chart is embedded in a class module which handles the extra
features (a whole lot of coloured polygons and lines added to the
chart's shapes collection)
When the axis limits are changed by the user, then the colour map
needs to be replotted. I can trap the chart events but none of them
seem to trigger when the user changes the axis limits. (unless one of
you knows better).
Plan B is an "Update Plot" context menu on the shapes collection. That
is actually pretty easy:
Private Sub ch_BeforeRightClick(Cancel As Boolean)
CommandBars("Shapes").Reset
With CommandBars("Shapes").Controls.Add
..Caption = "Update Plot"
..OnAction = ????????????????
End With
End Sub
However, getting the OnAction to call the correct subroutine in the
correct instance of the class is baffling me.
The event handler code is running in the correct instance, so I can
just update the plot on every right-click, but it is fairly time-
consuming so would prefer to do it only if the user selects the option
in the menu.
I think I want to set OnAction to be a sub in a standard module,
passed a link to the correct instance of the class module to run an
update method by the event handler. But I am getting in a terrible
muddle, and can't figure it out.
I suspect I might be trying to do the impossible, as you can only pass
a string in an OnAction parameter, and that probably isn't enough to
allow a standard module subroutine call a method of a specific
instance of a class.
Is it possible to iterate through all instances of a class looking for
one that contains ActiveChart? sort of like
For Each MyClass in <The current Scope>
if MyClass.EmbededChart.Name = ActiveChart.Name then
MyClass.UpDatePlot
Endif
Next
Perhaps I need to cancel the standard context menu, drop down my own,
and act on it internally to the instance of the class module?