Heute wurde in der Shoutbox quasi danach gefragt, wie man mit GDI ein transparentes GDI+Bild zeichnen kann
Dies ist möglich mit DrawIcon:
#include <GDIPlus.au3>
#include <WinAPI.au3>
_GDIPlus_Startup()
Global $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\autoit_logo_gtaspider.png")
Global $iImageW = _GDIPlus_ImageGetWidth($hImage)
Global $iImageH = _GDIPlus_ImageGetHeight($hImage)
Global $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Global $hGui = GUICreate("Test", $iImageW, $iImageH)
GUISetBkColor(0x394E69)
GUISetState()
Global $hIcon = _WinAPI_CreateIconIndirect($hHBitmap, $hHBitmap)
_WinAPI_DeleteObject($hHBitmap)
Global $hDC = _WinAPI_GetDC($hGui)
_WinAPI_DrawIconEx($hDC, 0, 0, $hIcon, $iImageW, $iImageH)
_WinAPI_DestroyIcon($hIcon)
_WinAPI_ReleaseDC($hGui, $hDC)
While GUIGetMsg() <> -3
Sleep(10)
WEnd
; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_CreateIconIndirect
; Description....: Creates an icon or cursor that has the specified size, colors, and bit patterns.
; Syntax.........: _WinAPI_CreateIconIndirect ( $hBitmap, $hMask [, $XHotspot [, $YHotspot [, $fIcon]]] )
; Parameters.....: $hBitmap - Handle to the icon color bitmap.
; $hMask - Handle to the icon bitmask bitmap.
; $XHotspot - Specifies the x-coordinate of a cursor's hot spot. If creates an icon, the hot spot is always in
; the center of the icon, and this member is ignored.
; $YHotspot - Specifies the y-coordinate of the cursor's hot spot. If creates an icon, the hot spot is always in
; the center of the icon, and this member is ignored.
; $fIcon - Specifies whether creates an icon or a cursor, valid values:
; |TRUE - Creates an icon. (Default)
; |FALSE - Creates a cursor.
; Return values..: Success - Handle to the icon or cursor that is created.
; Failure - 0 and sets the @error flag to non-zero.
; Author.........: Yashied
; Modified.......:
; Remarks........: The system copies the bitmaps before creating the icon or cursor. Because the system may temporarily
; select the bitmaps in a device context, $hBitmap and $hMask should not already be selected into a device context.
; The application must continue to manage the original bitmaps and delete them by _WinAPI_DeleteObject() when they
; are no longer necessary.
; Related........:
; Link...........: @@MsdnLink@@ CreateIconIndirect
; Example........: Yes
; ===============================================================================================================================
Func _WinAPI_CreateIconIndirect($hBitmap, $hMask, $XHotspot = 0, $YHotspot = 0, $fIcon = 1)
[/autoit][autoit][/autoit][autoit]Local $tICONINFO = DllStructCreate($tagICONINFO)
[/autoit][autoit][/autoit][autoit]DllStructSetData($tICONINFO, 1, $fIcon)
DllStructSetData($tICONINFO, 2, $XHotspot)
DllStructSetData($tICONINFO, 3, $YHotspot)
DllStructSetData($tICONINFO, 4, $hMask)
DllStructSetData($tICONINFO, 5, $hBitmap)
Local $Ret = DllCall('user32.dll', 'ptr', 'CreateIconIndirect', 'ptr', DllStructGetPtr($tICONINFO))
[/autoit][autoit][/autoit][autoit]If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[0]
EndFunc ;==>_WinAPI_CreateIconIndirect
(Das Bild "autoit_logo_gtaspider.png" ist das AutoIt.de-Logo ganz oben)
E