Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set the text property in CWCaption?

I am using CWGraph imported as an ActiveX component in Borland C++Builder 6. I am unable to set the Text property in CWCaption. Should I be able to set this programmatically in the MouseOver event, or is it only available at design time?
0 Kudos
Message 1 of 5
(3,358 Views)
I assume that you want to change the caption of an annotation when the user mouses over the annotation. This is possible. The key is that you have to set CWGraph::TrackMode to cwGTrackAllEvents. This corresponds to "Plot & Cursor Events" in the property pages (admittedly not the best name for this track mode).

The following code in VC++ changes an annotation caption when it is moused over.

void CSetAnnotationCaptionDlg::OnAnnotationMouseMoveCwgraph2(short FAR* Button, short FAR* Shift, double FAR* XPos, double FAR* YPos, long FAR* AnnotationIndex, long FAR* AnnotationPart)
{
CString caption;
caption.Format("AnnotationIndex = %d", *AnnotationIndex);
COleVariant index(static_cast((*AnnotationIndex) + 1), VT_I4);
m_graph.GetAnnotati
ons().Item(index).GetCaption().SetText(caption);
}
0 Kudos
Message 2 of 5
(3,358 Views)
Thanks for the quick response.

Here's what I'm trying to do. I have graph with multiple plots, and want to be able to display information about a given plot as the user moves the mouse over the plot. When the mouse is elsewhere, I don't want the annotation to be displayed, so I don't think using the AnnotationMouseMove event will work.
0 Kudos
Message 3 of 5
(3,358 Views)
You should be able to use the PlotMouseMove and PlotAreaMouseMove events to do this. In the PlotMouseMove event handler, you can make the annotation visible and in the PlotAreaMouseMove event handler, you can make the annotation not visible.

You will likely have to come up with a clever algorithm to get the exact behavior that you are looking for. For example, you might want to hide the annotation 1 second after the first PlotAreaMouseMove event you receive after having made the annotation visible. You might need to ignore some PlotAreaMouseMove events if you receive them immediately after the PlotMouseMove event (othewise the user would have to be very precise with mouse movements).
0 Kudos
Message 4 of 5
(3,358 Views)
Okay, I'll work on that and see what I can come up with. Thanks for your help.
0 Kudos
Message 5 of 5
(3,358 Views)