掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
プリンタのデバイスコンテキストを取得するには (ID:685)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
HDCは 0でも構わないようです。 もしCanvasのHDCを使うなら、HDCを作成すればいいのでは? ------------------------------------------------ procedure TForm1.Button1Click(Sender: TObject); var MyMetafile : TMetafile; MyMetaCanvas: TMetafileCanvas; MyCanvas : TCanvas; MyHDC : HDC; begin MyCanvas := Form1.Canvas; // 描画対象のキャンバス MyMetafile := TMetafile.Create; // MyMetafileを作成 MyHDC := GetDC(MyCanvas.Handle); // MyHDCを作成 MyMetaCanvas := TMetafileCanvas.Create(MyMetafile, MyHDC); // MyMetaCanvasを作成 with MyMetaCanvas do begin try Brush.Color := clFuchsia; Ellipse(0, 0, 100, 100); finally Free; // MyMetaCanvasを破棄 ReleaseDC(MyCanvas.Handle, MyHDC); // MyHDCを破棄 end; end; MyCanvas.Draw(0, 0, MyMetafile); // MyMetafileをMyCanvasに描画 // MyMetafileに追加描画するには、MetafileCanvasを再作成する MyMetaCanvas := TMetafileCanvas.Create(MyMetafile, 0); // HDCは0でも構わない with MyMetaCanvas do begin try Draw(0, 0, MyMetafile); // 以前の描画実行 Brush.Color := clAqua; FillRect(Rect(100, 100, 200, 200)); Brush.Color := clBlue; Ellipse(100, 100, 200, 200); finally Free; end; end; MyCanvas.Draw(0, 0, MyMetafile); // MyMetafileをMyCanvasに描画 end; ------------------------------------------------
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.