1. GUSTAVO MARCELINO
  2. PowerBuilder
  3. Thursday, 5 March 2020 13:29 PM UTC

Hello, 

I'm doing a project that retrieves data from the Betfair website, through the ESA API: https://docs.developer.betfair.com/display/1smk3cen4v3lu3yomq5qye0ni/Exchange+Stream+API

In this link above there is an example in C #, I downloaded, adapted the code and generated a DLL. The goal is to receive / send information on the Betfair server in real time, in this DLL it is recording the information it receives from the server in a Log.txt, and it is working perfectly.

I managed to connect this DLL to the powerbuilder, through:

OLEObject example
example.ConnectToNewObject ('Betfair.dll')
example.Start ()
// It started recording in Log.txt the information I need in a DW.

My question: How can I bring this data to a DataWindow? The idea of ​​creating a 1second Timer and updating the information is not feasible for me. I need the powerbuilder to retrieve the information as soon as it updates.

I don't know if I made my question clear, but thanks in advance. A translator was used, so I apologize if anything is not clear.

GUSTAVO MARCELINO Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 19:41 PM UTC
  2. PowerBuilder
  3. # 1

I was unable to do this process that you described, I have never worked with "Handle" and I am having difficulties. I did the following:

 

IN POWERBUILDER:

long ll_handle

ll_handle = Handle(dw_1)
il_dll.SetHandle(ll_handle)
il_dll.Start(gs_host, gs_key_application)

 

DLL in C#:

ls_return = process(); //Do all the process I need and return a String

SendMensageTraderSoft.SendString(ls_retorno);


/////////////////////////////////
class SendMensageTraderSoft
{
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, uint wParam, int lParam);

public const int WM_USER = 0x0400 + 1;
private static IntPtr _hwnd = IntPtr.Zero;

[STAThread]
public static void SendString(string sMsg)
{
    byte[] bytes = Encoding.UTF8.GetBytes(sMsg);
    foreach (byte b in bytes)
{
    SendMessage((IntPtr)Funcoes.GetHandle(), WM_USER, 1024, b);
}


//send terminating character so receiving app knows
//to stop reading string
SendMessage((IntPtr)Funcoes.GetHandle(), WM_USER, 1024, 0);
}
}
///////////////////////////////////

in powerbuilder dw_1 > pbm_custom01

MessageBox('test', 'test').

 

In powerbuilder the MessageBox is not calling, the application stops responding.

 
Comment
  1. René Ullrich
  2. Friday, 6 March 2020 06:26 AM UTC
ASAIK: WM_USER is 0x0400; if you send a message to event ID 0x0400 + 1 you have to use pbm_custom02!



As I understand you right you want to send a string to your application. (I thought you simply want to inform your application to read new information from log file.)



If you want to send the data with SendMessage I think it's not the best way to send each byte of string. Maybe it is better to send a pointer to the string (see https://social.msdn.microsoft.com/Forums/vstudio/en-US/b495207b-03bd-4fef-ad77-5b0669dab49a/how-to-pass-string-using-sendmessage?forum=vcgeneral).

In your Powerbuilder application you can receive the string from te pointer (see https://community.appeon.com/index.php/qna/q-a/receive-string-data-from-c-sendmessage)



But: I'm not a C# expert!



Regards,

René
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 5 March 2020 13:56 PM UTC
  2. PowerBuilder
  3. # 2

Hi Gustavo,

If you don't want to use a timer your applications needs to get information about the update.

Just an idea:

- add a function (e.g. SetHandle) to your DLL that you can call from your application to inform the DLL about the handle of a window or datawindow that should receive an event (e.g. WM_USER) if something changes

- send an event to the window using the handle if the data changes

- in your application call the SetHandle function before the Start() function

- implement the event (WM_USER is event ID  pbm_custom01) in your application to update the datawindow

HTH,

René

Comment
  1. David Peace
  2. Thursday, 5 March 2020 16:13 PM UTC
I think this approach is your best option.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.