Supprime un métafichier au format étendu ou un handle de métafichier au format étendu
#include <WinAPIGdi.au3>
_WinAPI_DeleteEnhMetaFile ( $hEmf )
$hEmf | Handle d'un métafichier étendu. |
Succès: | Retourne True |
Échec: | Retourne False |
Si le paramètre $hEmf identifie un métafichier étendu stocké en mémoire, la fonction _WinAPI_DeleteEnhMetaFile() supprime le métafichier.
Si $hEmf identifie un métafichier stocké sur un disque, la fonction supprime la handle de métafichier mais ne détruit pas le métafichier réel.
Une application peut récupérer le fichier en appelant la fonction _WinAPI_GetEnhMetaFile().
Consultez DeleteEnhMetaFile dans la librairie MSDN.
#include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIHObj.au3> #include <WinAPIMisc.au3> Global Const $sEmf = @TempDir & '\Test.emf' If FileExists($sEmf) Then If MsgBox(BitOR($MB_YESNOCANCEL, $MB_ICONQUESTION, $MB_DEFBUTTON2, $MB_SYSTEMMODAL), 'Création du Métafichier Etendu', $sEmf & ' existe déjà.'& @CRLF & @CRLF & 'Voulez-vous le remplacer?') <> 6 Then Exit EndIf If Not FileDelete($sEmf) Then MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Création Métafichier Etendu', 'Impossible de supprimer le fichier.') Exit EndIf EndIf ; Crée un contexte de périphérique pour un métafichier au format étendu Global $tRECT = _WinAPI_CreateRect(0, 0, 250, 250) Global $hDC = _WinAPI_CreateEnhMetaFile(0, $tRECT, 1, @TempDir & '\Test.emf') ; Dessine les objets Global $hBrush = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($DC_BRUSH)) Global $hPen = _WinAPI_SelectObject($hDC, _WinAPI_GetStockObject($NULL_PEN)) _WinAPI_SetDCBrushColor($hDC, 0xAA0000) _WinAPI_Rectangle($hDC, $tRECT) _WinAPI_SetDCBrushColor($hDC, 0xFFFFFF) ; Définit une étoile à 5 branches Global $aPoint[10][2] Calcule($aPoint) Global $hRgn = _WinAPI_CreatePolygonRgn($aPoint) _WinAPI_OffsetRgn($hRgn, 0, 6) _WinAPI_PaintRgn($hDC, $hRgn) ; Supprime les objets _WinAPI_SelectObject($hDC, $hBrush) _WinAPI_SelectObject($hDC, $hPen) Global $hEmf = _WinAPI_CloseEnhMetaFile($hDC) _WinAPI_DeleteEnhMetaFile($hEmf) _WinAPI_DeleteObject($hRgn) ; Affiche le fichier .emf créé dans Microsoft Paint If FileExists($sEmf) Then ShellExecute(@SystemDir & '\mspaint.exe', $sEmf) EndIf func Calcule(ByRef $aPoint) Local $x = 0, $y = 90, $size = 95, $cap = 0 Local Const $pi = 4*atan(1) $aPoint[0][0] = $x $aPoint[0][1] = $y for $i = 1 to 9 $x += $size * Cos($cap) $y += $size * Sin($cap) $aPoint[$i][0] = Round($x) $aPoint[$i][1] = Round($y) $cap += (Mod($i,2) = 0 ? 4*$pi/5 : -2*$pi/5) Next EndFunc ;==>Calcule