Hallo,
es tut mir leid, dass ich euch schon wieder nerven muss, aber ich komm einfach nicht weiter.
Hab eine Funktion _CheckHoverButton(...), die überprüfen soll, ob sich die Maus über dem "Button" befindet, funktioniert aber nur in eine Richtung.
Das Problem ist schwer zu beschreiben, wenn ihr das Skript ausführt, erkennt ihr aber glaube ich das Problem.
AutoIt
OnAutoItExitRegister("_Exit")
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
Local $iBtnState = 0
$hGui = GUICreate("", 300, 150, -1, -1, $WS_SYSMENU+$WS_POPUP)
GUISetBkColor(0xFFFFFF, $hGui)
$idBtn = GUICtrlCreatePic("", 105, 30, 90, 30)
GUICtrlSetCursor($idBtn, 0)
GUISetState(@SW_SHOW, $hGui)
_GDIPlus_Startup()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$hBrush_Hover = _GDIPlus_BrushCreateSolid(0xFF00FF00)
_Redraw()
While 1
_CheckHoverButton($idBtn, $iBtnState, $hGraphics, "Test", "Arial", 18, 128, 34, 105, 30, 90, 30)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_RESTORE
_Redraw()
Case $idBtn
MsgBox(0, "", "Button pressed!")
EndSwitch
WEnd
Func _Exit()
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BrushDispose($hBrush_Hover)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_Shutdown()
EndFunc
Func _Redraw()
_GDIPlus_GraphicsFillRect($hGraphics, 105, 30, 90, 30, $hBrush)
_DrawLabel($hGraphics, "Test", 128, 34, "Arial", 18, 0xFFFFFFFF)
EndFunc
Func _DrawLabel($hGraphics, $sText, $iLeft, $iTop, $sFont, $iPx, $Color)
$hFontFamily = _GDIPlus_FontFamilyCreate($sFont)
$hFont = _GDIPlus_FontCreate($hFontFamily, $iPx, 0, 2)
$tLayout = _GDIPlus_RectFCreate($iLeft, $iTop, 0, 0)
$hFormat = _GDIPlus_StringFormatCreate()
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat)
$hBrush = _GDIPlus_BrushCreateSolid($Color)
_GDIPlus_GraphicsDrawStringEx($hGraphics, $sText, $hFont, $aInfo[0], $hFormat, $hBrush)
_GDIPlus_FontFamilyDispose($hFontFamily)
_GDIPlus_FontDispose($hFont)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
EndFunc
Func _CheckHoverButton($idControl, $iState, $hGraphics, $sText, $sFont, $iFontSize, $iLeftString, $iTopString, $iLeft, $iTop, $iWidth, $iHeight)
$aMousePos = GUIGetCursorInfo($hGui)
If $aMousePos[4] = $idControl Then
If $iState = 0 Then
_GDIPlus_GraphicsFillRect($hGraphics, $iLeft, $iTop, $iWidth, $iHeight, $hBrush_Hover)
_DrawLabel($hGraphics, $sText, $iLeftString, $iTopString, $sFont, $iFontSize, 0xFFFFFFFF)
$iState = 1
EndIf
Else
If $iState = 1 Then
_GDIPlus_GraphicsFillRect($hGraphics, $iLeft, $iTop, $iWidth, $iHeight, $hBrush)
_DrawLabel($hGraphics, $sText, $iLeftString, $iTopString, $sFont, $iFontSize, 0xFFFFFFFF)
$iState = 0
EndIf
EndIf
EndFunc
Alles anzeigen
Bin dankbar um Antworten.
Lg NO1