Graphics.AddMetafileComment メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Graphics.AddMetafileComment メソッドの意味・解説 

Graphics.AddMetafileComment メソッド

現在の Metafileコメント追加します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Sub AddMetafileComment ( _
    data As Byte() _
)
Dim instance As Graphics
Dim data As Byte()

instance.AddMetafileComment(data)
public void AddMetafileComment (
    byte[] data
)
public:
void AddMetafileComment (
    array<unsigned char>^ data
)
public void AddMetafileComment (
    byte[] data
)
public function AddMetafileComment (
    data : byte[]
)

パラメータ

data

コメント含まれているバイト配列

解説解説

このメソッドは、この GraphicsMetafile関連付けられている場合にだけ有効です。

使用例使用例

次の例は、Windows フォームでの使用意図してデザインされており、Paint イベント ハンドラパラメータである PaintEventArgse と、たとえば Form などの thisForm が必要です。このコード次のアクション実行します

Public Sub AddMetafileCommentBytes(ByVal
 e As PaintEventArgs)

    ' Create temporary graphics object for metafile
    ' creation and get handle to its device context.
    Dim newGraphics As Graphics = Me.CreateGraphics()
    Dim hdc As IntPtr = newGraphics.GetHdc()

    ' Create metafile object to record.
    Dim metaFile1 As New
 Metafile("SampMeta.emf", hdc)

    ' Create graphics object to record metaFile.
    Dim metaGraphics As Graphics = Graphics.FromImage(metaFile1)

    ' Draw rectangle in metaFile.
    metaGraphics.DrawRectangle(New Pen(Color.Black, 5), 0, 0,
 100, 100)

    ' Create comment and add to metaFile.
    Dim metaComment As Byte()
 = {CByte("T"), CByte("e"),
 CByte("s"), _
    CByte("t")}
    metaGraphics.AddMetafileComment(metaComment)

    ' Dispose of graphics object.
    metaGraphics.Dispose()

    ' Dispose of metafile.
    metaFile1.Dispose()

    ' Release handle to scratch device context.
    newGraphics.ReleaseHdc(hdc)

    ' Dispose of scratch graphics object.
    newGraphics.Dispose()

    ' Create existing metafile object to draw.
    Dim metaFile2 As New
 Metafile("SampMeta.emf")

    ' Draw metaFile to screen.
    e.Graphics.DrawImage(metaFile2, New Point(0, 0))

    ' Dispose of metafile.
    metaFile2.Dispose()
End Sub
public void AddMetafileCommentBytes(PaintEventArgs
 e)
{
    // Create temporary Graphics object for metafile
    //  creation and get handle to its device context.
    Graphics newGraphics = this.CreateGraphics();
    IntPtr hdc = newGraphics.GetHdc();
             
    // Create metafile object to record.
    Metafile metaFile1 = new Metafile("SampMeta.emf",
 hdc);
             
    // Create graphics object to record metaFile.
    Graphics metaGraphics = Graphics.FromImage(metaFile1);
             
    // Draw rectangle in metaFile.
    metaGraphics.DrawRectangle(new Pen(Color.Black, 5), 0, 0,
 100, 100);
             
    // Create comment and add to metaFile.
    byte[] metaComment = {(byte)'T', (byte)'e', (byte)'s', (byte)'t'};
    metaGraphics.AddMetafileComment(metaComment);
             
    // Dispose of graphics object.
    metaGraphics.Dispose();
             
    // Dispose of metafile.
    metaFile1.Dispose();
             
    // Release handle to temporary device context.
    newGraphics.ReleaseHdc(hdc);
             
    // Dispose of scratch graphics object.
    newGraphics.Dispose();
             
    // Create existing metafile object to draw.
    Metafile metaFile2 = new Metafile("SampMeta.emf");
             
    // Draw metaFile to screen.
    e.Graphics.DrawImage(metaFile2, new Point(0, 0));
             
    // Dispose of metafile.
    metaFile2.Dispose();
}
public:
   [SecurityPermission(SecurityAction::Demand, Flags = SecurityPermissionFlag::UnmanagedCode)]
            
   void AddMetafileCommentBytes( PaintEventArgs^ e )
   {
      // Create temporary Graphics object for metafile
      //  creation and get handle to its device context.
      Graphics^ newGraphics = this->CreateGraphics();
      IntPtr hdc = newGraphics->GetHdc();

      // Create metafile object to record.
      Metafile^ metaFile1 = gcnew Metafile( "SampMeta.emf",hdc );

      // Create graphics object to record metaFile.
      Graphics^ metaGraphics = Graphics::FromImage( metaFile1 );

      // Draw rectangle in metaFile.
      metaGraphics->DrawRectangle( gcnew Pen( Color::Black,5.0f ), 0, 0, 100,
 100 );

      // Create comment and add to metaFile.
      array<Byte>^metaComment = {(Byte)'T',(Byte)'e',(Byte)'s',(Byte)'t'};
      metaGraphics->AddMetafileComment( metaComment );

      // Dispose of graphics object.
      delete metaGraphics;

      // Dispose of metafile.
      delete metaFile1;

      // Release handle to temporary device context.
      newGraphics->ReleaseHdc( hdc );

      // Dispose of scratch graphics object.
      delete newGraphics;

      // Create existing metafile object to draw.
      Metafile^ metaFile2 = gcnew Metafile( "SampMeta.emf" );

      // Draw metaFile to screen.
      e->Graphics->DrawImage( metaFile2, Point(0,0) );

      // Dispose of metafile.
      delete metaFile2;
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Graphics.AddMetafileComment メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Graphics.AddMetafileComment メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS