Graphics.AddMetafileComment(Byte[]) Graphics.AddMetafileComment(Byte[]) Graphics.AddMetafileComment(Byte[]) Graphics.AddMetafileComment(Byte[]) Method

정의

현재 Metafile에 주석을 추가합니다.Adds a comment to the current Metafile.

public:
 void AddMetafileComment(cli::array <System::Byte> ^ data);
public void AddMetafileComment (byte[] data);
member this.AddMetafileComment : byte[] -> unit
Public Sub AddMetafileComment (data As Byte())

매개 변수

data
Byte[]

주석을 포함한 바이트의 배열입니다.Array of bytes that contains the comment.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수인를 Paint 이벤트 처리기 뿐만 thisForm, Form 예입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler, as well as thisForm, the Form for the example. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • 임시 만듭니다 Graphics 메타 파일을 가져옵니다 작성용는 hdc, 해당 디바이스 컨텍스트에 대 한 핸들입니다.Creates a temporary Graphics for creating the metafile and gets an hdc, a handle to its device context.

  • 사용 하 여 새 메타 파일을 만듭니다는 hdc합니다.Creates a new metafile using the hdc.

  • 만듭니다는 Graphics 에서 메타 파일의 표시를 Metafile입니다.Creates a Graphics for display of the metafile from the Metafile.

  • 메타 파일에 사각형을 그립니다.Draws a rectangle to the metafile.

  • 메타 파일에 메모를 추가 합니다.Adds a comment to the metafile.

  • 삭제 된 Graphics 메타 파일 닫습니다 메타 파일에 대 한 합니다.Disposes the Graphics for the metafile-which closes the metafile.

  • 메타 파일을 삭제 합니다.Disposes the metafile.

  • 임시 해제 hdc합니다.Releases the temporary hdc.

  • 임시 삭제 Graphics합니다.Disposes the temporary Graphics.

  • 이전에 만든된 파일에서 두 번째 메타 파일을 만듭니다.Creates a second metafile from the previously created file.

  • 화면에 메타 파일을 그립니다.Draws the metafile to the screen.

  • 메타 파일을 삭제 합니다.Disposes the metafile.

private:
   [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;
   }
private 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();
}
Private 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

설명

이 메서드는이 경우에 유효 Graphics 과 연관 된 Metafile합니다.This method is valid only if this Graphics is associated with a Metafile.

적용 대상