C++Builder XE6 での印刷の基本


普段はC#やPHPで開発を行っていますので基礎はある程度わかっているつもりです。

VC++は持ってるのですがexe一つでフォームアプリが作れることに魅力を感じて、この際と思いC++Builerを入手しました。
コンポーネントまで購入する余裕がなかったので、とりあえず手動で印刷をがりがりやろうと思い、取り急ぎマニュアルの印刷部分をそのままテストすることにしました。

http://docwiki.embarcadero.com/RADStudio/XE4/ja/FireMonkey_%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%8B%E3%82%89%E3%81%AE%E5%8D%B0%E5%88%B7

#include "FMX.Printer.hpp" も追加してあり、コンパイルは通るのですが、実行して画像をセットしてボタンをクリックすると
  Printer->ActivePrinter->SelectDPI(1200, 1200);
の部分でエラーが出ます。(画像添付)
メモリアクセス違反系のエラーなのはわかるのですが、最小限のプログラムでエラーが出ているので訳がわからないです・・・
とりあえずDPIを600で試してみたり、ActiveDPIIndex = 1;で試したりしましたが結果は同じでした。
(同じ場所でエラーになる)

何かヒントをいただけませんでしょうか?

回答の条件
  • 1人5回まで
  • 登録:
  • 終了:2014/08/15 16:45:02

ベストアンサー

id:a-kuma3 No.1

回答回数4973ベストアンサー獲得回数2154

サイトを斜め読みしただけですが、サンプルのコードが間違ってるんじゃないでしょうか?

 void __fastcall TMyForm::PrintButtonClick(TObject *Sender)
 {
   TRectF SrcRect, DestRect;
// TPrinter *Printer = Printer;		   ★ここ
   TPrinter *Printer = Printer();	// ★こうじゃないでしょうか?
 
   /* Set the default DPI for the printer. The SelectDPI routine defaults
 	 to the closest available resolution as reported by the driver. */
   Printer->ActivePrinter->SelectDPI(1200, 1200);

   ...

Routines

  ...
Printer - Returns a global instance of TPrinter to manage any interaction with the printer.

FMX.Printer - RAD Studio API Documentation

Description

Returns a global instance of TPrinter to manage any interaction with the printer.
Printer creates an instance of a global TPrinter object the first time it is called. Use the Printer function to print using the TPrinter object.

FMX.Printer.Printer - RAD Studio API Documentation




追記です。
もしかしたら、Printer → Fmx::Printer::Printer() かもしれません。

 void __fastcall TMyForm::PrintButtonClick(TObject *Sender)
 {
   TRectF SrcRect, DestRect;
// TPrinter *Printer = Printer;
   TPrinter *Printer = Fmx::Printer::Printer(); // ★こうかも
 
   /* Set the default DPI for the printer. The SelectDPI routine defaults
     to the closest available resolution as reported by the driver. */
   Printer->ActivePrinter->SelectDPI(1200, 1200);

   ...

マニュアルに従えば、Fmx ではなく FMX のような気もしますが、こんなのがネットに落ちてたので。
http://www.blueshop.com.tw/board/FUM20050124191259IGD/BRD2014051611380669C.html
あ、でもこっちも、落ちちゃうよ、ってな話か...

id:landy77

返信ありがとうございます。

試したところ、そもそもコンパイルが通らなくて、
「E2314 関数でないものを呼び出している」
というエラーが出てます。

もう少し調べてみます・・・

2014/08/14 18:04:22
id:a-kuma3

回答にも追記しましたが、Printer → Fmx::Printer::Printer() かもしれません。

2014/08/15 09:59:03

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません