Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Copying Chart to Clipboard
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Copying Chart to Clipboard

 Post Reply Post Reply
Author
Message
ChristineK View Drop Down
Newbie
Newbie


Joined: 30 January 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChristineK Quote  Post ReplyReply Direct Link To This Post Topic: Copying Chart to Clipboard
    Posted: 30 January 2012 at 12:18pm
I am using ChartPro version 15.2.1
I need to be able to copy the chart that is drawn in my application to the clipboard for users to paste as a picture into something like Word or PowerPoint. Is there an easy way to do this?
Back to Top
ABuenger View Drop Down
Newbie
Newbie
Avatar

Joined: 02 February 2006
Status: Offline
Points: 1075
Post Options Post Options   Thanks (0) Thanks(0)   Quote ABuenger Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2012 at 2:19pm
Hello,

please open a ticket and I'll provide the necessary code.

Andre

Codejock support
Back to Top
ChristineK View Drop Down
Newbie
Newbie


Joined: 30 January 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChristineK Quote  Post ReplyReply Direct Link To This Post Posted: 01 February 2012 at 10:07am
I'm sorry...I am new to ChartPro and this message board. How do I open a ticket?
Back to Top
evoX View Drop Down
Senior Member
Senior Member
Avatar

Joined: 25 July 2007
Status: Offline
Points: 207
Post Options Post Options   Thanks (0) Thanks(0)   Quote evoX Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 9:19am
Why don't you post here the code? because I also need this.
Product: Xtreme ToolkitPro 19.30
Platform: Windows 10 64bit
Language: Visual C++ (VS 2019)
Back to Top
Arnoutdv View Drop Down
Groupie
Groupie


Joined: 29 September 2010
Status: Offline
Points: 38
Post Options Post Options   Thanks (0) Thanks(0)   Quote Arnoutdv Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 9:38am
I accomplished this by using an invisible picture control on the form.

The Visible property is set to False
The AutoRedraw property is set to True

Private Sub ChartToClipBoard()
  picChartClipBoard.Width = theChart.Width
  picChartClipBoard.Height = theChart.Height
  theChart.PrintToDC picChartClipBoard.hdc, -1, -1, theChart.Width / Screen.TwipsPerPixelX, theChart.Height / Screen.TwipsPerPixelY
  Clipboard.Clear
  Clipboard.SetData picChartClipBoard.Image, vbCFBitmap
End Sub
VB6 SP6, SuitePro 16.3.0 / 18.2.0, Win10/64
Back to Top
ChristineK View Drop Down
Newbie
Newbie


Joined: 30 January 2012
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote ChristineK Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 9:45am
I figured out how to do this on my own. Here's the function I wrote:
 

void MyClass::OnCopyToClipboardChart()

{

                // Get the size of the chart rectangle

                CRect rect;

                m_chartControl1.GetClientRect(rect);

                rect.NormalizeRect();   

                if(rect.IsRectEmpty() || rect.IsRectNull())

                                return; 

 

                // get the chart's device context

                CDC *pDc = m_chartControl1.GetWindowDC();

                CDC memDc;

                if(!memDc.CreateCompatibleDC(pDc))

                                return;

 

                // create a bitmap of the chart's current state

                CBitmap bitmap;

                if( !bitmap.CreateCompatibleBitmap(pDc,rect.Width(), rect.Height()))

                                return;

                CBitmap* pOldBitmap = memDc.SelectObject(&bitmap);

                memDc.BitBlt(0,0,rect.Width(),rect.Height(),pDc,rect.left ,  rect.top ,SRCCOPY );                              

                if(OpenClipboard())

                {

                                // empty clipboard data

                                EmptyClipboard();

                                // put the chart bitmap on the clipboard

                                SetClipboardData(CF_BITMAP,bitmap.GetSafeHandle());

                                CloseClipboard();

                }

                memDc.SelectObject(pOldBitmap);

}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.