Ferme un contexte de p�riph�rique de m�tafichier �tendu et retourne le handle qui identifie un m�tafichier au format �tendu
#include <WinAPIGdi.au3>
_WinAPI_CloseEnhMetaFile ( $hDC )
$hDC | Handle du contexte de p�riph�rique de m�tafichier �tendu. |
Succ�s: | Retourne le handle du m�tafichier �tendu. |
�chec: | Retourne 0. |
Lorsque l'application n'a plus besoin du handle du m�tafichier �tendu, il faut le supprimer en appelant la fonction _WinAPI_DeleteEnhMetaFile().
Consultez CloseEnhMetaFile 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