WINAPI Method

Hi there,

I'm wondering if anyone can advise me on how to overcome a problem i'm having.

I have got a program which calls a dll, this dll consists of callback functions(external functions). These functions return a continuos stream of data(which is fine). My problem is that i want to output this data in a list box which i created in "Form1". I cant figure out how to do this because these functions seem to be external to the rest of my code (so basically i need these functions to recognise either the methods i've created in Form1.cpp or get it to recognise the listbox in Form1. The supplier of the dll sent me the following code:

void WINAPI PriceUpdate(PriceUpdStructPtr data)
{
int nRow=-1;
PriceStruct newPrice;

CListBox *pListBox=NULL;
pListBox=(CListBox*)AfxGetApp()->m_pMainWnd->GetDlgItem(IDC_LIST2);

CString CDisplyString;
cDisplayString.Format("Price Update callbacl Exchange=%s ", data->ExchangeName);
nRow=pListBox->AddStirng(cDisplayString);
pListBox->SelectString(nRow-1, cDisplayString);
}

However i cannot use this code because my form was not create with MFC, I've used the toolbox in Microsoft visual C++.

Thanks in advance for your suggestions.
[1328 byte] By [e2c] at [2007-11-20 1:51:53]
# 1 Re: WINAPI Method
It sounds like you are using the .net framework - which means you'd have to use the native inter-op mechanisms.
Zaccheus at 2007-11-9 13:24:53 >
# 2 Re: WINAPI Method
You can use GetDlgItem to get the edit control like so:

ControlhWnd = ::GetDlgItem(hWndOwner, IDC_CONTROL);

Where hWndOwner is the owner of the control and IDC_CONTROL is the ID of the specific control you want to get.

As for the text, I'm sure there is a way to do this with strings, but I'm not too great with them, but you could use char *s and sprintf_s(safer version of sprintf in VS 2005)

To add a string to a text box use How To Append Text To An Edit Control (http://www.dev-archive.com/forum/showthread.php?t=350435)
Notsosuperhero at 2007-11-9 13:25:54 >
# 3 Re: WINAPI Method
Thanks alot guys i'll give it a try.
e2c at 2007-11-9 13:27:02 >
# 4 Re: WINAPI Method
Is it possible to use ControlWnd even though i am using the .Net framework? because my understand was that this could only be used if i had created MFC components?
e2c at 2007-11-9 13:27:56 >
# 5 Re: WINAPI Method
It sounds like you are using the .net framework - which means you'd have to use the native inter-op mechanisms.
:wave:
Zaccheus at 2007-11-9 13:29:05 >
# 6 Re: WINAPI Method
hehe thanks Zaccheus. I did spot your message and have been looking into interop (with little success). I just thought i would clarify my undertanding of things.
e2c at 2007-11-9 13:30:04 >
# 7 Re: WINAPI Method
If you can understand C#, this example might be helpful:
http://www.devx.com/dotnet/Article/6991/0/page/1
:thumb:
Zaccheus at 2007-11-9 13:31:07 >