Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy 3D graph to clipboard not working

Hi, I had problem in implement "copy & paste" the 3D graph in .NET  (#C). Here is what I did:

 

1. Add an axCWGraph3D1 to the form and add a button on the toolstrip.

2. Some simple code to generate a 3D surface plot.

3. Implement the button_click event as

        Clipboard.Clear();

        Clipboard.SetImage(this.axCWGraph3D1.ControlImage());

 

 then tried to copy the surface plot and paste it on to a Power Point slide. It did not work. I also tried

        Clipboard.SetData(System.Windows.Forms.DataFormats.EnhancedMetaFile, this.axCWGraph3D1.ControlImage());

 

and I tried the "MetafilePict" format too, none of them worked. However, similar lines in VB6 worked:

 

        Clipboard.Clear
        Clipboard.SetData CWGraph3D1.ControlImage, vbCFMetafile 

 

I am not sure if this is a bug. Can someone tell me the way get around it? I am using Measurement Studio 8.5.

 

Dufei

 

0 Kudos
Message 1 of 4
(4,178 Views)

Hello Dufei,

Thank you for posting on the NI Discussion Forums.  If you take a look at the help for the Clipboard.SetImage( ) method, you will see that it takes in a System.Drawing.Image object as an input to paste to the clipboard, which is not the same as a CW3DGraph object. 

I would, however, expect the second line of code that you tried to work.  What version of Visual Studio are you working with?  Does the code throw back an exception, or does the clipboard just say that the image cannot be collected because the format is not supported?
Chris_G
Sr Test Engineer
Medtronic, Inc.
0 Kudos
Message 2 of 4
(4,160 Views)

Hi, Chris:

 

Here is the lines for the button click event:

 

         private void copyImageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Clipboard.Clear();
                // Clipboard.SetImage(this.axCWGraph3D1.ControlImage());
                Clipboard.SetData(DataFormats.EnhancedMetafile, this.axCWGraph3D1.ControlImage());
            }
            catch (Exception ex)
            {
                MessageBox.Show("msg: " + ex.Message);  
            }
        }

 

when I do the copy (click), no complain from my application. When I tried to paste on a Power Point slide, no complain either. However, when I tried to  paste it to Paint (Mircrosoft), it complains as "Error getting the clipboard data!".

 

I am using MS Visual Studio 2005. I can temperalily skip this problem since I can use the following lines to save it to file and then paste it:

    

        Image img = this.axCWGraph3D1.ControlImage();

        img.Save( myFileName, System.Drawing.Imaging.ImageFormat.Emf);

 

but I just wonder how come I can convert it to Image class but can not copy it to clipboard directly.

 

Dufei

 

0 Kudos
Message 3 of 4
(4,126 Views)

Dufei,

This has been reported to R&D (#130528) for further investigation.  The work-around you came up with is a very good one, and will hopefully get you through the issue for now.  Also, there is another application called Paint.NET, which interestingly enough, can have the image pasted into it using the following line of code from your original post:Clipboard.SetImage(this.axCWGraph3D1.ControlImage());

Thanks for the feedback.  We really appreciate it when our customers tells us about these kinds of things!

Chris_G
Sr Test Engineer
Medtronic, Inc.
0 Kudos
Message 4 of 4
(4,106 Views)