- Offizieller Beitrag
Hallo
Ich stehe (schon wieder) auf dem Schlauch
Ich will ein CallBack erzeugen. Aber wenn dieser Callback aufgerufen werden sollte, stürzt AutoIt ab (AutoIt.exe hat ein Problem festgestellt und muss...)
In der Hilfe steht:
Spoiler anzeigen
lgLcdSoftbuttonsChangedContext/lgLcdOnSoftButtonsCB
The lgLcdSoftbuttonsChangedContext is part of the lgLcdOpenContext and is used to give the library enough information to allow changes in the state of the soft buttons to be signaled into the calling application through a callback.
// Callback used to notify client of soft button change typedef DWORD (WINAPI *lgLcdOnSoftButtonsCB)(IN int device,
IN DWORD dwButtons,
IN const PVOID pContext);
typedef struct
{
// Set to NULL if no softbutton notifications are needed
lgLcdOnSoftButtonsCB softbuttonsChangedCallback;
PVOID softbuttonsChangedContext;
} lgLcdSoftbuttonsChangedContext;
[i][b]Members[/b][i]
[b]softButtonsChangedCallback[/b]
Specifies a pointer to a function that should be called when the state of the soft buttons changes. If no notification is needed, leave this parameter NULL.
[b]softbuttonsChangedContext[/b]
Specifies an arbitrary context value of the application that is passed back to the client in the event that soft buttons are being pressed or released. The new value of the soft buttons is reported in the dwButtons parameter of the callback function.[/spoiler]
So, in einem C++ Script sieht das so aus:
[spoiler][code]Structure lgLcdSoftbuttonsChangedContext
;softbuttonsChangedCallback.lgLcdOnSoftButtonsCB
*softbuttonsChangedCallback
*softbuttonsChangedContext
EndStructure
//[...]
Procedure.l MY_lgLcdOnSoftButtonsCB(device.l, dwButtons.l, *pContext)
If MyG15\WindowID
If dwButtons & #LGLCDBUTTON_BUTTON0
SetGadgetText(MyG15\Buttons[0], "< 1 >")
Else
SetGadgetText(MyG15\Buttons[0], "1")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON1
SetGadgetText(MyG15\Buttons[1], "< 2 >")
Else
SetGadgetText(MyG15\Buttons[1], "2")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON2
SetGadgetText(MyG15\Buttons[2], "< 3 >")
Else
SetGadgetText(MyG15\Buttons[2], "3")
EndIf
If dwButtons & #LGLCDBUTTON_BUTTON3
SetGadgetText(MyG15\Buttons[3], "< 4 >")
Else
SetGadgetText(MyG15\Buttons[3], "4")
EndIf
EndIf
If MyG15\CB
MyG15\CB(device.l, dwButtons.l, *pContext)
EndIf
EndProcedure
Alles anzeigen
[/spoiler]
Mein Versuch sah ca so aus:
[autoit]Global Const $LGLCD_STRUCT_SoftbuttonsChangedContext = DllStructCreate("ptr;ptr")
[/autoit] [autoit][/autoit] [autoit]$hReg = DllCallbackRegister("_Test","dword","int;dword;ptr")
[/autoit] [autoit][/autoit] [autoit]DllStructSetData($LGLCD_STRUCT_SoftbuttonsChangedContext,1,DllCallbackGetPtr($hReg))
DllStructSetData($LGLCD_STRUCT_SoftbuttonsChangedContext,2,DllCallbackGetPtr($hReg))
;[...]
Func _Test($iDevice,$dwButtons,$pContext)
ConsoleWrite($iDevice & @CRLF)
ConsoleWrite($dwButtons & @CRLF)
ConsoleWrite($pContext & @CRLF)
EndFunc
(Bei [...] ist natürlich noch mehr Code)
Aber er schafft noch nicht mal die ConsoleWrites. Sobald ich die Buttons auf dem LCD drücke schmiert er ab. Interessant ist auch, dass selbst wenn ich dies Freilasse, also statt "DllCallbackGetPtr($hReg)" einfach False reinschreibe (sollte laut Hilfe ja klappen) schmiert er auch ab.
Hat da jemand eine Idee?
Vielen Dank
Mfg Spider