Hi.
Etwas, was schon mehrfach gefragt wurde. Wie stelle ich einen Rechtsklick auf ein bestimmtes Control fest? Ich kenne 2 Methoden durch GUIRegisterMsg, die beide nicht funktionieren.
Spoiler anzeigen
#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]$hGUI = GUICreate("Bild", 360, 640)
$hPic = GUICtrlCreatePic("", 0, 0, 360, 640)
_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBitmap = _GDIPlus_ImageLoadFromFile("light.jpg")
$hNewBitmapHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
SetBitmapToCtrl($hPic, $hNewBitmapHandle)
GUISetState()
[/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg(0x004E, "MyUserFunction") ;0x004E = $WM_NOTIFY
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep(50)
If GUIGetMsg() = -3 Then Exit
WEnd
Func MyUserFunction($hWnd, $vMsgID, $vWParam, $vLParam)
;geht nicht
If $vWParam = $hPic Then
$vTagNMHDR = DllStructCreate("int;int;int", $vLParam)
$vEvent = DllStructGetData($vTagNMHDR, 3)
If $vEvent = -5 Then ;-5 = $NM_RCLICK
MsgBox(0,"","Rechtsklick auf Bild")
EndIf
EndIf
;geht auch nicht
Local $hGUIFrom, $iCode, $tNMHDR ;$iIDFrom
$tNMHDR = DllStructCreate($tagNMHDR, $vLParam)
$hGUIFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
If $hGUIFrom = $hPic Then
;$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
If $iCode = 0x700 Then
Local $tMsgFilter = DllStructCreate("int;int;int;uint msg;int wParam;int lParam", $vLParam)
If DllStructGetData($tMsgFilter, 4) = 0x205 Then ; WM_RBUTTONUP
MsgBox(0,"","Rechtsklick auf Bild")
EndIf
EndIf
EndIf
Return 'GUI_RUNDEFMSG'
EndFunc ;==>_SM_NotifyActions
;Set a bitmap to a control - by Zedna
Func SetBitmapToCtrl($vCtrlID, $h_Bitmap)
Local $hWnd = GUICtrlGetHandle($vCtrlID)
If $hWnd = 0 Then Return SetError(1, 0, 0)
Local $vOldStyle = _WinAPI_GetWindowLong($hWnd, -16)
_WinAPI_SetWindowLong($hWnd, -16, BitOR($vOldStyle, 0xE))
Local $vOldBmp = _SendMessage($hWnd, 0x0172, 0, $h_Bitmap)
If $vOldBmp <> 0 Then _WinAPI_DeleteObject($vOldBmp)
EndFunc ;==>_SM_SetBitmapToCtrl
Das es nicht geht liegt an der Funktion SetBitmapToCtrl. Ich brauche also eine Alternative. Habe schon ein paar Threads durchgeguckt aber nur auf die 2 Methoden gestoßen, oder halt durch Mousepos und IsPressed und so, was ich aber nicht möchte.
Warum ich das Bild so lade spielt keine Rolle, das lässt sich nicht ändern.
Kennt noch jemand eine Methode?
Edit: Hier noch das Bild:
[Blockierte Grafik: http://img3.imagebanana.com/img/lq4g01k0/light.jpg]