Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

annotation image printout/clipboard

How can an image annotation in a CNiGraph be printed out resp. copied to the clipboard? The m_Graph.ControlImage()function seems not to work with image anntations. Any ideas?

Peter
0 Kudos
Message 1 of 3
(3,165 Views)
I'm not sure I understand the question - are you saying that image annotations are not included when you copy an image of the graph to the clipboard? If so, try this sample code and see if this works:

// Assuming that the class has a m_graph member that is a CNiGraph

// Add an image annotation.
CNiAnnotation annotation = m_graph.Annotations.Add();
CNiShape shape = annotation.Shape;
shape.Type = CNiShape::Picture;
shape.Image.Url = _T("C:\\Windows\\Zapotec.bmp");
shape.Image.Reload();

// Copy an image of the graph to the clipboard.
CNiPicture pic = m_graph.ControlImage();
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(
CF_ENHMETAFILE,
::CopyEnhMetaFile(reinterpret_cast(pic.Handle), NULL)
);
::CloseClipboa
rd();

After this code runs you should be able to paste a bitmap of the control to Paint and see the graph with the image annotation. If this was not your question or this did not resolve your problem, please post a reply with additional information and sample code that demonstrates how to reproduce your problem. Thanks.

- Elton
0 Kudos
Message 2 of 3
(3,165 Views)
The sample code line throws an exception SCODE:-2147467262. So I loaded the bitmap in the resource workshop and it works with the clipboard.

The only but important difference is the file format. I have a WMF file. On screen everything looks fine but the WMF is not included on the paper printout nor in the clipboard image. This is also true for some other bitmaps.

Are there any restrictions regarding file formats? Any ideas how to work with WMF?

Peter
0 Kudos
Message 3 of 3
(3,165 Views)