Jump to content

Recommended Posts

Posted

I needed to return some data from self-written FreeBasic DLL so I written callback function and managed successfully  call it by pointer from DLL but... it works... not always - in most cases it crash claiming variable not declared while this variable is global or declared local just above, ( this crash can even take place in WM_NOTIFY function - mostly when i make callback function  volatile) , Sometimes callback function quit/return on halfway.

 

Is there a some tips to make reliable callback function in autoit to call it from self-written dll?

 

Func CallBackFunc_DataData($iDataID, $iTreeViewMinWidthRaw, $pData)

    Local $tData = DllStructCreate($tagDataW, $pData), $i = $iDataID

    $GlobalRef_iTreeViewMinWidth = $iTreeViewMinWidthRaw
    ;----------------------------------------------------------------------------------
    If $iDataID > $GlobalRef_aData[0][0] Then
        $GlobalRef_aData[0][0] += 1

        ReDim $GlobalRef_aData[$GlobalRef_aData[0][0] + 1][32]
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][0] =   DllStructGetData($tData,2)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][1] =   DllStructGetData($tData,3)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][2] =   DllStructGetData($tData,4)
            ;--------------------------------------------------------------------------
        $GlobalRef_aData[$i][6] =   DllStructGetData($tData,12)
            ;--------------------------------------------------------------------------
        $GlobalRef_aData[$i][8] =   DllStructGetData($tData,14)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][9] =   DllStructGetData($tData,15)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][10] =  DllStructGetData($tData,16)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][11] =  DllStructGetData($tData,17)
        ;------------------------------------------------------------------------------
        $GlobalRef_aData[$i][16] =  DllStructGetData($tData,19)
        ;------------------------------------------------------------------------------
        $GlobalRef_oNameToID.Add($GlobalRef_aData[$i][0],$i)
    EndIf
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][3] =   DllStructGetData($tData,5)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][4] =   DllStructGetData($tData,6)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][5] =   DllStructGetData($tData,9)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][7] =   DllStructGetData($tData,13)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][15] =  DllStructGetData($tData,23)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][17] =  DllStructGetData($tData,20)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][18] =  DllStructGetData($tData,21)
    ;----------------------------------------------------------------------------------
    $GlobalRef_aData[$i][24] =  DllStructGetData($tData,22);            treeViewState_itemHandle
    $GlobalRef_aData[$i][25] =  DllStructGetData($tData,23);            treeViewState_itemIcon
    $GlobalRef_aData[$i][26] =  DllStructGetData($tData,24);            treeViewState_textColor
    $GlobalRef_aData[$i][27] =  DllStructGetData($tData,25);            treeViewState_textBold
    $GlobalRef_aData[$i][28] =  DllStructGetData($tData,26);            treeViewState_NewItems
    $GlobalRef_aData[$i][29] =  DllStructGetData($tData,27);            treeViewState_UnreadItems
    $GlobalRef_aData[$i][30] =  DllStructGetData($tData,28);            treeViewState_TotalItems
    $GlobalRef_aData[$i][31] =  DllStructGetData($tData,29);            treeViewState_feedStats
    ;----------------------------------------------------------------------------------

    ;----------------------------------------------------------------------------------
EndFunc

 

Posted

Hello. It would be better if you share a runnable example script. that way people round here can check and debug the issue.

Saludos

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...