Funktionreferenz


_WinAPI_CloseEnhMetaFile


Closes an enhanced-metafile device context and returns a handle that identifies an enhanced-format metafile

#include <WinAPIGdi.au3>
_WinAPI_CloseEnhMetaFile ( $hDC )

Parameter

$hDC Handle to an enhanced-metafile device context.

Rückgabewert

Success: Handle to an enhanced metafile.
Failure: 0.

Bemerkungen

When the application no longer needs an enhanced-metafile handle, it should delete the handle by calling the
_WinAPI_DeleteEnhMetaFile() function.

Verwandte Funktionen

_WinAPI_DeleteEnhMetaFile

Siehe auch

Suche nach CloseEnhMetaFile in der MSDN Bibliothek.

Beispiel

#include <MsgBoxConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPIMisc.au3>

Local Const $sEmf = @TempDir & '\Test.emf'

If FileExists($sEmf) Then
    If MsgBox(($MB_YESNOCANCEL + $MB_DEFBUTTON2 + $MB_ICONQUESTION + $MB_SYSTEMMODAL), 'Create Enhanced Metafile', $sEmf & ' is already exists.' & @CRLF & @CRLF & 'Do you want to replace it?') <> 6 Then
        Exit
    EndIf
    If Not FileDelete($sEmf) Then
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Create Enhanced Metafile', 'Unable to delete file.')
        Exit
    EndIf
EndIf

; Create device context for an enhanced-format metafile
Local $tRECT = _WinAPI_CreateRect(0, 0, 250, 250)
Local $hDC = _WinAPI_CreateEnhMetaFile(0, $tRECT, 1, @TempDir & '\Test.emf')

; Draw objects
Local $hBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH))
Local $hPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_PEN))
_WinAPI_SetDCBrushColor($hDC, 0xAA0000)
_WinAPI_Rectangle($hDC, $tRECT)
_WinAPI_SetDCBrushColor($hDC, 0xFFFFFF)
Local $aPoint[10][2] = [[0, 90], [95, 90], [125, 0], [154, 90], [250, 90], [172, 147], [202, 238], [125, 181], [47, 238], [77, 147]]
Local $hRgn = _WinAPI_CreatePolygonRgn($aPoint)
_WinAPI_OffsetRgn($hRgn, 0, 6)
_WinAPI_PaintRgn($hDC, $hRgn)

; Release objects
_WinAPI_SelectObject($hDC, $hBrush)
_WinAPI_SelectObject($hDC, $hPen)
Local $hEmf = _WinAPI_CloseEnhMetaFile($hDC)

; create a copy
Local $hCopyEmf = _WinAPI_CopyEnhMetaFile($hEmf) ; copy to memory
_WinAPI_DeleteEnhMetaFile($hCopyEmf)

_WinAPI_DeleteEnhMetaFile($hEmf)
_WinAPI_DeleteObject($hRgn)

; Show created .emf file into the Microsoft Paint
If FileExists($sEmf) Then
    ShellExecute(@SystemDir & '\mspaint.exe', $sEmf)
EndIf