Affiche l'image stockée dans un métafichier au format étendu spécifié
#include <WinAPIGdi.au3>
_WinAPI_PlayEnhMetaFile ( $hDC, $hEmf, $tRECT )
| $hDC | Handle du contexte de périphérique pour le périphérique de sortie sur lequel l'image apparaîtra. |
| $hEmf | Handle du métafichier étendu. |
| $tRECT | Structure $tagRECT qui contient les coordonnées du rectangle englobant utilisé pour afficher l'image, en unités logiques |
| Succès: | Retourne True |
| Échec: | Retourne False |
Un métafichier étendu peut être intégré dans un métafichier étendu nouvellement créé en appelant _WinAPI_PlayEnhMetaFile() et en jouant le métafichier étendu source dans le contexte de périphérique pour le nouveau métafichier étendu.
Consultez PlayEnhMetaFile dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIGdiDC.au3> #include <WinAPIHObj.au3> #include <WinAPIMisc.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> ; Charge un métafichier étendu (.emf) et récupére sa dimension (x6) Local $hEmf = _WinAPI_GetEnhMetaFile(@ScriptDir & '\Extras\Flag.emf') Local $tSIZE = _WinAPI_GetEnhMetaFileDimension($hEmf) Local $iWidth = 6 * DllStructGetData($tSIZE, 'X') Local $iHeight = 6 * DllStructGetData($tSIZE, 'Y') ; Crée une GUI Local $hForm = GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), $iWidth, $iHeight) Local $idPic = GUICtrlCreatePic('', 0, 0, $iWidth, $iHeight) Local $hPic = GUICtrlGetHandle($idPic) ; Crée un bitmap à partir du métafichier étendu Local $hDC = _WinAPI_GetDC($hPic) Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, $iWidth, $iHeight, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_3DFACE))) Local $hMemSv = _WinAPI_SelectObject($hMemDC, $hBitmap) Local $tRECT = _WinAPI_CreateRectEx(0, 0, $iWidth, $iHeight) _WinAPI_PlayEnhMetaFile($hMemDC, $hEmf, $tRECT) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_SelectObject($hMemDC, $hMemSv) _WinAPI_DeleteDC($hMemDC) ; Libère le métafichier étendu _WinAPI_DeleteEnhMetaFile($hEmf) ; Définit le bitmap dans le contrôle Picture _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) Local $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE