News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MSChart made easy with ObjAsm32

Started by Biterider, June 01, 2009, 12:02:40 PM

Previous topic - Next topic

Biterider

Hi
In the last weeks I was struggling with the MSChart ActiveX component to integrate it into one of my projects. I'll post here my results since I believe it is worth to take a look at it because it can reduce the development time if you are looking for one of the several chart types this OCX offers.
To use this control we need an OCX container. Since it has the needed functionality, I used the ATL71 for this purpose. As an alternative, a custom OCX container can be coded to avoid the ATL71.DLL dependency. Not a big challenge, but a few 100 lines of code more. If you are going for it, take a look at Japheth's implementation of OCXContainer. It implements the barebones, but it is enough for most of the existing controls.

The MSChart implementation is done using ObjAsm32. The core object is a simple descendant of WinPrimer, but it embeds a COM event sink to catch notifications from the control. This sink is a container object that hosts an IDispatch interface that acts as a callback for the control events. The coded dispatch mechanism uses the build in event table used to dispatch WM_* messages. This way a clean implementation is achieved. I'm considering extending the table generation to all method types for a future OA32 release.
I coded all dispatch methods to perform no response actions. In a further step you can easily intercept them to modify the chart behaviour. If you activate one of the axes in the attached example, a popup dialog is shown to modify the scale values. This is done one level higher overriding the AxisLabelActivated method of the current object instance.

MSChart runs in runtime mode, therefore it doesn't require an extra license. If you want to use it in design mode, you will require some special behaviour at the client side and a design time license. The main advantage is a property dialog to customize the control, but all features can also be accessed at runtime using the put_* and set_* methods.

There are tons of examples on how to customize the MSChart control, so I will not go further on this.

If you get in the supplied example the error message "MSChart can't initialize" then one of the needed DLLs or OCX are missing or installed incorrectly.


Regards,

Biterider


[attachment deleted by admin]

UtillMasm


Biterider

Hi UtillMasm
This is an environment variable which is set when you install the OA32 package http://objasm32.winasm.net/. Once done, I recommend running the updater (project folder) to get the newest files.

Biterider

UtillMasm