0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder XE4 > TeeChart > TEdit付きのChart1をクリップボードへ送る| #include <ClipBrd.hpp> | HDC dc = GetDC(Panel1->Handle); | ClipBrd.hpp

Last updated at Posted at 2018-12-06
動作環境
C++ Builder XE4
TeeChart Lite v2013.08.130414 32bit VCL

前置き

  • Chart1をFastReportへ送ろうとしている
  • Chart1にTEditを配置したが、Chart1からTeeCreateMetafile()をコールしてもTEditは含まれない
  • クリップボードを使うとどうか

TEdit付きのChart1をクリップボードへ送る
方法を調べた。

参考

情報感謝です (I appreciate your information).

実装

Unit1.h
//---------------------------------------------------------------------------

# ifndef Unit1H
# define Unit1H
//---------------------------------------------------------------------------
# include <System.Classes.hpp>
# include <Vcl.Controls.hpp>
# include <Vcl.StdCtrls.hpp>
# include <Vcl.Forms.hpp>
# include <Vcl.ExtCtrls.hpp>
# include <VCLTee.Chart.hpp>
# include <VCLTee.TeEngine.hpp>
# include <VCLTee.TeeProcs.hpp>
# include "frxClass.hpp"
# include "frxExportPDF.hpp"
# include <VCLTee.Series.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE で管理されるコンポーネント
	TButton *Button1;
	TPanel *Panel1;
	TChart *Chart1;
	TEdit *Edit1;
	TFastLineSeries *Series1;
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);

private:	// ユーザー宣言
public:		// ユーザー宣言
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
# endif
Unit1.cpp
//---------------------------------------------------------------------------

# include <vcl.h>
# pragma hdrstop

# include <ClipBrd.hpp>
# include <DateUtils.hpp>
# include "Unit1.h"
//---------------------------------------------------------------------------
# pragma package(smart_init)
# pragma link "frxClass"
# pragma link "frxExportPDF"
# pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	TBitmap *lBmp = new TBitmap();

	try {
		lBmp->SetSize(Panel1->ClientWidth, Panel1->ClientHeight);
		HDC dc = GetDC(Panel1->Handle);
		BitBlt(lBmp->Canvas->Handle, 0, 0, Panel1->ClientWidth, Panel1->ClientHeight, dc, 0, 0, SRCCOPY);
		Clipboard()->Assign(lBmp);
	} catch (...) {
	}

	delete lBmp;
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormShow(TObject *Sender)
{
	// ダミーデータでグラフ生成
	Chart1->Series[0]->XValues->DateTime = true;
	Chart1->BottomAxis->DateTimeFormat = L"nn:ss";

	TDateTime dt;

	dt = Now();

	double yval;
	for (int idx=0; idx < 10; idx++) {
		yval = (1+ idx) % 2;
		Series1->AddXY(dt, yval, "", clRed);
		dt = IncSecond(dt, 1);
	}
}
//---------------------------------------------------------------------------


フォームデザイン

2018-12-06_16h35_59.png

動作例

  1. Button1を押下
    • クリップボードに画像イメージが送られる
  2. Windowsの「ファイル名を指定して実行」からpbrushでペイントブラシを起動
  3. ペイントブラシにてCtrl + v

2018-12-06_16h34_34.png

Edit1(TEdit)も含まれている。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?