Jump to content
Sign in to follow this  
testmeout

How do you debug GUIRegisterMsg

Recommended Posts

testmeout

Well after trial and error I have finally been able to communicate with openticks dll through a dll wrapper. I can call the functions just fine, and get good results, but to achieve what I want, I need to be able to recieve messages from the dll, which is not working for me.

So I am stuck agian and not sure where to go at this point. Does anyone have any ideas on how to debug GUIRegisterMsg?

Here is my code so far.

#include <GUIConstants.au3>
Global Const $OTFEED_LOGIN = ($WM_USER + 2500)
$gui = GUICreate("DataDump")
$hwnd = WinGetHandle($gui)
sleep(1000)
$dll = DllOpen("OTFeedAPI.dll")
If $dll = -1 Then
    MsgBox(0,"","Error - dll failed to open.")
    Exit
EndIf
$addhost = DllCall($dll,"none","AddHost","str","feed1.opentick.com","int",10010)
;$client.addHost("feed1.opentick.com", 10010) ; Real-time data
;$client.addHost("feed2.opentick.com", 10010) ; Real-time data
sleep(200)
$login = DllCall($dll,"none", "Login", "str", "myusername", "str", "mypassword")
$callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd)
GUIRegisterMsg($OTFEED_LOGIN, "onlogin")
DllClose($dll)
    
Func onlogin($hwnd,$msg,$w,$l)
msgbox(0, "Status", "Success")
EndFunc

The script does not terminate so I am assuming it is frozen. When I remove the DllClose($dll) for some reason the taskbar icon disappears but the script has not terminated yet.

Any help is greatly appreciated.

Share this post


Link to post
Share on other sites
martin

Well after trial and error I have finally been able to communicate with openticks dll through a dll wrapper. I can call the functions just fine, and get good results, but to achieve what I want, I need to be able to recieve messages from the dll, which is not working for me.

So I am stuck agian and not sure where to go at this point. Does anyone have any ideas on how to debug GUIRegisterMsg?

Here is my code so far.

#include <GUIConstants.au3>
Global Const $OTFEED_LOGIN = ($WM_USER + 2500)
$gui = GUICreate("DataDump")
$hwnd = WinGetHandle($gui)
sleep(1000)
$dll = DllOpen("OTFeedAPI.dll")
If $dll = -1 Then
    MsgBox(0,"","Error - dll failed to open.")
    Exit
EndIf
$addhost = DllCall($dll,"none","AddHost","str","feed1.opentick.com","int",10010)
;$client.addHost("feed1.opentick.com", 10010) ; Real-time data
;$client.addHost("feed2.opentick.com", 10010) ; Real-time data
sleep(200)
$login = DllCall($dll,"none", "Login", "str", "myusername", "str", "mypassword")
$callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd)
GUIRegisterMsg($OTFEED_LOGIN, "onlogin")
DllClose($dll)
    
Func onlogin($hwnd,$msg,$w,$l)
msgbox(0, "Status", "Success")
EndFunc

The script does not terminate so I am assuming it is frozen. When I remove the DllClose($dll) for some reason the taskbar icon disappears but the script has not terminated yet.

Any help is greatly appreciated.

Can't offer much with what you said so far, but this bit

$callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd)

looks wrong to me. I assume that there should be a pointer to a procedure passed as a parameter not the handle for your form. If you do not have a callback function then maybe you can pass 0 instead of $hwnd.

Also, if the Callback is used by the Login function then presumably you must have to set it before you use the Login function.

Are you sure that the Login really does not return anything?

I don't know anything about openticks, this is all guesswork.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
testmeout

Can't offer much with what you said so far, but this bit

$callback = DllCall($dll, "int", "SetCallbackWindProcHandle", "hwnd", $hwnd)

looks wrong to me. I assume that there should be a pointer to a procedure passed as a parameter not the handle for your form. If you do not have a callback function then maybe you can pass 0 instead of $hwnd.

Also, if the Callback is used by the Login function then presumably you must have to set it before you use the Login function.

Are you sure that the Login really does not return anything?

I don't know anything about openticks, this is all guesswork.

Thanks for the reply, it is not actually a callback that is just poorly written code by me. I am calling an open source dll wrapper which has 2 options message based events and callbacks. I decided on message based events. Here is the setup for it

Message based events
Use this OR callback ptr table events - but NOT both (see Callback ptr table events) (see notes above) 

This function allows you to set a Windproc handle that all message event will be sent too. The message number constants are defined in the API, eg. "OTFEED_xxx". A message is sent when the matching event occurs. 

BOOL SetCallbackWindProcHandle(HWND hwnd);
  
    Returns false or true on success.

I have added Return $GUI_RUNDEFMSG on my onlogin function and after doing so it actually worked, but it only seemed to work acouple of times, it is not consistent.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×