Moinsen,
leider sitze ich immer noch an dem Problem, weil das Hintergrundbild ja falsch angezeigt wird.
Hätte da jemand vielleicht jetzt dazu noch eine Lösung? Es ist wichtig fuer mich.
mfg Freaky
Bilder als Buttons bei GDI+ Hintergrund Bild + Hover
-
- [ offen ]
-
Freaky -
18. Dezember 2011 um 02:57 -
Geschlossen -
Erledigt
-
-
Hey,
ich brauche Leider immer noch Hilfe an meinem Problem. Es ist mitlerweile fast 1 Monat her, dass ich an meinem Problem sitze und ich habe bis jetzt immer noch kein Weg gefunden
Bitte hilft mir.
mfg Freaky -
Hi, also so geht's bei mir ...
Spoiler anzeigen
[autoit]
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <StaticConstants.au3>
#include <GDIPlus.au3>
#include <IE.au3>Global $iImagePfad = @ScriptDir & "\Bilder\"
[/autoit] [autoit][/autoit] [autoit];~ Global Const $IMAGE_BITMAP = 0
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Global Const $SC_DRAGMOVE = 0xF012
Global Const $STM_SETIMAGE = 0x0172
;~ Global Const $LWA_ALPHA = 0x00000002; The script's entry point
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Exit (ScriptMain ( ))Func ScriptMain ( )
[/autoit] [autoit][/autoit] [autoit]Local $hWnd
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Local $oIE
Local $iButton [3]
Local $hBmp, $hImage, $hBrush
Local $iWidth, $iHeight
Local $hbrOld_GDIPlus_StartUp ( )
[/autoit] [autoit][/autoit] [autoit]$hImage = _GDIPlus_ImageLoadFromFile ($iImagePfad & "background.png")
[/autoit] [autoit][/autoit] [autoit]$iWidth = _GDIPlus_ImageGetWidth ($hImage)
[/autoit] [autoit][/autoit] [autoit]
$iHeight = _GDIPlus_ImageGetHeight ($hImage)$hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($hImage)
[/autoit] [autoit][/autoit] [autoit]; Create the main window
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$hWnd = GUICreate ("Test", $iWidth, $iHeight, -1, -1, _
BitOR ($WS_POPUP, $WS_CLIPCHILDREN), BitOR ($WS_EX_LAYERED, $WS_EX_TOPMOST))GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$bImage_Pic1 = _GDIPlus_ImageLoadFromFile($iImagePfad & "start_1.png")
[/autoit] [autoit][/autoit] [autoit]
$bImage_Pic2 = _GDIPlus_ImageLoadFromFile($iImagePfad & "start_2.png")$hbmpButton1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bImage_Pic1)
[/autoit] [autoit][/autoit] [autoit]
$hbmpButton2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($bImage_Pic2); Create the button
[/autoit] [autoit][/autoit] [autoit]
GUICreate ("", 118, 31, 100, 100, _
BitOr($WS_POPUP, $WS_CHILD, $WS_VISIBLE, $WS_CLIPSIBLINGS), $WS_EX_MDICHILD, $hWnd)
$iButton = GUICtrlCreatePic ("", 0, 0, 118, 31, BitOr($SS_NOTIFY, $WS_CLIPSIBLINGS, $GUI_SS_DEFAULT_PIC))
GUICtrlSendMsg ($iButton, $STM_SETIMAGE, $IMAGE_BITMAP, $hbmpButton1)GUISetState (@SW_SHOW, $hWnd)
[/autoit] [autoit][/autoit] [autoit]SetTransparentBitmap($hWnd, $hImage)
[/autoit] [autoit][/autoit] [autoit]_WinAPI_DeleteObject ($hBmp)
[/autoit] [autoit][/autoit] [autoit]
_GDIPlus_ImageDispose ($hImage); Create embedded "iexplore" object
[/autoit] [autoit][/autoit] [autoit]
$oIE = _IECreateEmbedded ( )If ($oIE <> 0) Then
[/autoit] [autoit][/autoit] [autoit]_CreateIEObject($hWnd, $oIE, 200, 200, 200, 200)
[/autoit] [autoit][/autoit] [autoit]_IENavigate($oIE, 'http://google.de')
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
Else
MsgBox (BitOR ($MB_OK, $MB_ICONHAND), 0, "_IECreateEmbedded fehlgeschlagen!")
EndIfLocal $isHover = False
[/autoit] [autoit][/autoit] [autoit]
Local $mem = True; Message loop
[/autoit] [autoit][/autoit] [autoit]
While (TRUE)Switch (GUIGetMsg ( ))
[/autoit] [autoit][/autoit] [autoit]
Case $iButton
ContinueCase
Case $GUI_EVENT_CLOSE
GUIDelete ($hWnd)
ExitLoop
EndSwitchLocal $aCoord = GUIGetCursorInfo ($hWnd)
[/autoit] [autoit][/autoit] [autoit]If $aCoord[4] = $iButton Then
[/autoit] [autoit][/autoit] [autoit]
If Not $isHover Then
GUICtrlSendMsg ($iButton, $STM_SETIMAGE, $IMAGE_BITMAP, $hbmpButton1)
$isHover = True
$mem = True
EndIf
Else
If $mem Then
GUICtrlSendMsg ($iButton, $STM_SETIMAGE, $IMAGE_BITMAP, $hbmpButton2)
$mem = False
$isHover = False
EndIf
EndIfWEnd
[/autoit] [autoit][/autoit] [autoit];~ _IEQuit ($oIE)
[/autoit] [autoit][/autoit] [autoit]
_GDIPlus_ImageDispose ($bImage_Pic1)
_GDIPlus_ImageDispose ($bImage_Pic2)
_WinAPI_DeleteObject ($hbmpButton1)
_WinAPI_DeleteObject ($hbmpButton2)
_WinAPI_DeleteObject ($hBrush)
_GDIPlus_ShutDown ( )Return 0
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Func _CreateIEObject ($iForm,$iVar,$iX,$iY,$iW,$iH)
[/autoit] [autoit][/autoit] [autoit]
$iIEForm = GUICreate ("",$iX,$iY,$iW,$iH,BitOr($WS_POPUP, $WS_CHILD, $WS_VISIBLE, $WS_CLIPSIBLINGS), $WS_EX_MDICHILD, $iForm)
GUICtrlCreateObj ($iVar,0,0,$iW,$iH)
GUISetState (@SW_SHOW,$iIEForm)
EndFuncFunc _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
[/autoit] [autoit][/autoit] [autoit]
_SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
EndFunc ;==>_WM_LBUTTONDOWNFunc SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF)
[/autoit]
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
_WinAPI_ReleaseDC(0, $hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, 0, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmapGruß
Greenhorn -
Hey,
vielen Dank, dass du dir die Zeit genommen hast um dir das anzugucken.
Das Hintergrundbild wird nun so angezeigt, wie ich mir das gewünscht habe. Leider spinnt nun der Button.
Wenn ich das Script starte, ist alles ok. Nach ca. 2 Sekunden, geht der Hover des Buttons and und bleibt auch an. Und $aCoord[4] zeigt mir dauerhaft 0 an, als ob es kein Object in der Form findet. Nicht einmal die IE Form.
Leider kann ich mir auch nicht erklären, wieso $aCoord[4] nichts findet. Gibt es dafür eine simple Begründung oder ist da ein Fehler?
mfg Freaky -
Hallo Freaky,
ich habe zwar nur deinen Eröffnungsbeitrag gelesen aber soeben habe ich unter https://autoit.de/index.php?page=Thread&threadID=30900 ein Beispiel gepostet, das zu deiner Problemstellung passt,
mfg autoBert
-