ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Sample for pure win32 application with mouse interaction
Posted by Kuldip on Feb-03-2012 22:43
Hi,

I am new to ChartDirector and am learning it. I want to make a pure win32 c++ application
(not using MFC or Qt) which shows a window with the graph in it. I also want to be able to
interact with the graph(such as clicking or getting a tooltip on mouse hover). I have been
able to find parts of code (under "Using ChartDirector with Other GUI Frameworks").
However, I have not been able to find detailed explanation/sample code for the same. Can
you please direct me to some samples/tutorials designed for this issue?

Thanks
Kuldip
Tally Solutions Pvt. Ltd.

  Re: Sample for pure win32 application with mouse interaction
Posted by Peter Kwan on Feb-04-2012 02:58
Hi Kuldip,

Because there are several dozens GUI frameworks in C++, and we are not familiar with all of them, it is not practical for us to translate our sample code to all these GUI frameworks. So our sample code are only available on MFC and QT, two of the most popular GUI frameworks in C++. If you are using other GUI frameworks (or just Win32 without usng any GUI framework), you would need to translate the MFC or QT sample code. (The source code of CChartViewer and QChartViewer are included in the sample code.)

In brief, to support "hot spots", you would need to create an image map using BaseChart.getHTMLImageMap, and using it to create an "ImageMapHandler" object. Then, when the mouse moves on the chart (I suppose in "pure" Win32, you would have a message loop that listens to the GUI messages to get the mouse coordinates), you can use ImageMapHandler.getHotSpot to determine if the mouse is over a hot spot. If it is in fact over a hot spot, you can use ImageMapHandler.getValue to get its attribute. In the sample code, we use the "title" attribute for tooltips, and we use the tooltip facilities of MFC or QT to display them. In your own code, you can get the "title" attribute to obtain the tooltip text, and use your own method to show them on screen.

As a reference, you may see the code in CChartViewer::OnMouseMove in "ChartViewer.cpp". Although the code is based on MFC, the logic should be similar in all GUI frameworks. The difference is how to obtain the mouse coordinates, and how to display the tooltip after getting it.

Hope this can help.

Regards
Peter Kwan