Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »Archive (2017 and earlier) »IQFeed Developer Support »Not receiving WM_MOUSEMOVE Messages
Author Topic: Not receiving WM_MOUSEMOVE Messages (5 messages, Page 1 of 1)

kweiss
-Interested User-
Posts: 8
Joined: Mar 28, 2005


Posted: Mar 28, 2005 10:02 PM          Msg. 1 of 5
Hi! I don't appear to be receiving WM_MOUSEMOVE messages after I call RegisterClientApp (via the "Connect" method) from my C# program. I've included the code below. Hopefully you'll be able to see something I missed. Thanks....

--------------------------------------------------------------------------------------------

using System;
using System.Windows.Forms;
using System.Security.Permissions;
using System.Runtime.InteropServices;

namespace DtnFeed
{
public class IqFeed: NativeWindow
{
public enum Status
{
Unknown,
Connecting,
Connected,
Terminating,
Terminated
}

private int SUCCESS = 0;
private const int WM_MOUSEMOVE = 0x0200;
private const string DLL_NAME = "IQ32.DLL";

~IqFeed()
{
if(this.Handle != IntPtr.Zero)
this.DestroyHandle();
}

[DllImport(DLL_NAME, CallingConvention=CallingConvention.StdCall)]
private extern static int RegisterClientApp(IntPtr handle,
[MarshalAs(UnmanagedType.LPStr)] string productName,
[MarshalAs(UnmanagedType.LPStr)] string productKey,
[MarshalAs(UnmanagedType.LPStr)] string productVersion);

[DllImport(DLL_NAME, CallingConvention=CallingConvention.StdCall)]
private extern static void RemoveClientApp(IntPtr handle);

[DllImport(DLL_NAME, CallingConvention=CallingConvention.StdCall)]
private extern static int SetAutoLogin(
[MarshalAs(UnmanagedType.LPStr)] string userName,
[MarshalAs(UnmanagedType.LPStr)] string password);

public delegate void StatusEventHandler(object sender, Status status);

public event StatusEventHandler OnStatus;

public void Connect(string product, string key, string version,
string userName, string password)
{
CreateParams cp = new CreateParams();

this.CreateHandle(cp);

if(OnStatus != null)
OnStatus(this, Status.Connecting);

SetAutoLogin(userName, password);

if(RegisterClientApp(this.Handle, product, key, version) != SUCCESS)
throw new ApplicationException(); //Improve this
}

public void Terminate()
{
if(this.Handle != IntPtr.Zero)
{
if(OnStatus != null)
OnStatus(this, Status.Terminating);

RemoveClientApp(this.Handle);
}
}

protected override void WndProc(ref Message message)
{
if(message.Msg == WM_MOUSEMOVE)
{
uint x = (uint)message.LParam & 0xFFFF;
uint y = (uint)message.LParam >> 16;

if(OnStatus != null)
{
if((x == 0) && (y == 0))
OnStatus(this, Status.Connected);
else if((x == 0) && (y == 1))
OnStatus(this, Status.Unknown);
else if((x == 1) && (y == 0))
OnStatus(this, Status.Terminated);
else if((x == 1) && (y == 1))
OnStatus(this, Status.Terminating);
else
throw new ApplicationException();
}
}

base.WndProc(ref message);
}
}
}

DTN_Natalie_H
-DTN Evangelist-
Posts: 175
Joined: May 10, 2004

DTN Market Access, LLC.


Posted: Mar 31, 2005 08:53 AM          Msg. 2 of 5
I'll look into it and get back to you. In the meantime, you can look at the C# example app that is installed with the IQFeed developer package, if you haven't already done so. Thanks!

Natalie Hannan DTN Market Access, LLC.

DTN_Natalie_H
-DTN Evangelist-
Posts: 175
Joined: May 10, 2004

DTN Market Access, LLC.


Posted: Apr 7, 2005 09:39 AM          Msg. 3 of 5
Did looking at the example app help you? I don't see anything from looking at the code that you sent. Thanks!

Natalie Hannan DTN Market Access, LLC.

squirlhntr
-Interested User-
Posts: 62
Joined: Feb 12, 2005


Posted: May 1, 2005 12:26 PM          Msg. 4 of 5
Make sure iq32.dll and the other DLLs are not in the same directory as the application you are running. The code needs to reference the DLLs from the place they were installed by the installation program and if instead the code ends up using the DLL in the currect directory, for whatever reason you won't get the MOUSEMOVE messages.

swhitney
-Interested User-
Posts: 21
Joined: Nov 3, 2005


Posted: Nov 5, 2005 10:31 PM          Msg. 5 of 5
This Cracks the Nut Directly...and simply

This will open the IQ server and prime it for a socket connection in C#

</OCX>

//use appropriate marshalling resources
using System.Runtime.InteropServices;

//define a delegate
public delegate void CallBackDelegate(int x, int y);

//Explicit DLL function references
//reference the external call back function (make sure IQ32.dll is nearby or define a path)
//NOTE!!! -> WE PASS A LOCALLY DEFINED DELEGATE TYPE (CallBackDelegate type)
//Define your local reference to the external function with local object params...
[DllImport("IQ32.dll")]
public static extern void SetCallbackFunction(CallBackDelegate callback);
//define a local ref to the reg client function
[DllImport("IQ32.dll")]
public static extern int RegisterClientApp(IntPtr hClient, string szProductName,string szProductKey, string szProductVersion);

The following 3 called from Load or Initialize or whatever gets you going
//declare a  new call back delegate pointing to our local function [SLAVE]
CallBackDelegate callback = new CallBackDelegate(this.CallBack);

//send the delegate pointer to IQ****
SetCallbackFunction(callback);

//register the app, passing the main object pointer,name,key,ver
RegisterClientApp(this.Handle,strName,strKey,strVersion);

//poor little callback [SLAVE]	
private void CallBack(int x, int y)
{
// Do Somthing
string[,] callbackMsg =
{
{"Connection OK", "N/A"},
{"Offline Notification","IQFeed Terminating"}
};
Console.WriteLine(callbackMsg[x,y]);
};

**** Note: Create and Set in one swoop: SetCallbackFunction(new CallBackDelegate(this.CallBack));


Edited by swhitney on Nov 5, 2005 at 11:41 PM
 

 

Time: Thu October 31, 2024 7:35 PM CFBB v1.2.0 12 ms.
© AderSoftware 2002-2003