Trolleule Posted August 10, 2014 Share Posted August 10, 2014 hi, does someone know why i cant access the data of the structure? Or can someone explain, how to pass an array to _SubclassProc2. expandcollapse popup#include <WinAPIShellEx.au3> #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> OnAutoItExitRegister('OnAutoItExit') ; Create GUI Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()')) Local $hCombo = _GUICtrlComboBox_Create($hForm, "", 2, 2, 396, 296) ; Register DLL callback that will be used as window subclass procedure Local $hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Local $pDll = DllCallbackGetPtr($hDll) Local $hDll2 = DllCallbackRegister('_SubclassProc2', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Local $pDll2 = DllCallbackGetPtr($hDll2) Local $test = 1 ; Install window subclass callback _WinAPI_SetWindowSubclass($hForm, $pDll, 1000, 0) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _SubclassProc($hWnd, $iMsg, $iwParam, $ilParam, $ID, $pData) #forceref $ID, $pData If $test Then Local $struct = DllStructCreate("wchar[5];wchar[6];wchar[4]") DllStructSetData($struct, 1, "test") DllStructSetData($struct, 2, "hallo") DllStructSetData($struct, 3, "gih") ConsoleWrite("pointer: " & DllStructGetPtr($struct) & @CRLF) _WinAPI_SetWindowSubclass($hCombo, $pDll2, 1001, DllStructGetPtr($struct)) $test = 0 EndIf Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $iwParam, $ilParam) EndFunc ;==>_SubclassProc Func _SubclassProc2($hWnd, $iMsg, $iwParam, $ilParam, $ID, $pData) #forceref $ID, $pData Local $point = Ptr($pData) Local $struct = DllStructCreate("wchar[5];wchar[6];wchar[4]", $point) ConsoleWrite("data1: " & DllStructGetData($struct, 1) & " data2: " & DllStructGetData($struct, 2) & " data3: " & DllStructGetData($struct, 3) & " $pData: " & $pData & " Ptr: " & Ptr($pData) & @CRLF) ConsoleWrite("Hwnd: " & $hWnd & " $iMsg: " & $iMsg & " $iwParam: " & $iwParam & " $ilParam: " & $ilParam & @CRLF) $struct = 0 ;~ _WinAPI_RemoveWindowSubclass($hCombo, $pDll2, 1001) Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $iwParam, $ilParam) EndFunc ;==>_SubclassProc Func OnAutoItExit() _WinAPI_RemoveWindowSubclass($hCombo, $pDll2, 1001) _WinAPI_RemoveWindowSubclass($hForm, $pDll, 1000) DllCallbackFree($hDll) DllCallbackFree($hDll2) EndFunc ;==>OnAutoItExit Link to comment Share on other sites More sharing options...
Trolleule Posted August 11, 2014 Author Share Posted August 11, 2014 (edited) Sorry if i missed some informations. I don't get it work. The _SubclassProc2 procedure catches the messages from the ComboBox control, $pData contains the pointer to the structure, which i passed with _WinAPI_SetWindowSubclass($hCombo, $pDll2, 1001, DllStructGetPtr($struct)) in the form procedure, but although the pointer is equal, the data is different. Sometimes it reads the data properly and sometimes only one of the elements is properly. Has someone an idea please? Edited August 11, 2014 by Trolleule Link to comment Share on other sites More sharing options...
Trolleule Posted August 12, 2014 Author Share Posted August 12, 2014 ... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now