PDA

Click to See Complete Forum and Search --> : Windows messaging question


softwareguy74
Jan 3rd, 2001, 01:53 AM
Hi,

I recently asked this question in the VB forum but I thought I'd ask you C++ guys to see how you would handle this..

Say you're building a DLL with VC++. In it you are implementing an api function that uses callbacks to let you know when the operation has completed. The problem is these require the hWnd of the window to receive the windows message. But, since this is in a DLL, there is now windows, correct? So, how do you specify that the DLL should receive the notification so that it can determine the message and then report it back to the client app using the DLL?

Using VB, someone suggested that I just place a form in the DLL to accept the windows messages.. Using C++, would you just create a window in the DLL but not show it?

Any help would be appreciated..

Dan

parksie
Jan 3rd, 2001, 05:41 AM
I'd use a function callback. Just call another function in the DLL to say you've finished.

softwareguy74
Jan 3rd, 2001, 08:22 AM
How would I do that? Say I'm using the following api function:


int WSAAsyncSelect(
SOCKET s,
HWND hWnd,
unsigned int wMsg,
long lEvent
);


You say to "just call another function in the dll to say you've finished" but the above winsock api requires the hWnd of a window to receive the message, not a function. Where would I specify in the above function to call a function in my dll when it's done processing? Does my function have an hWnd associated with it? I thought only a window or control had an hWnd?

I know that if I were just creating a regular windows program, I would just have a window handle the message notification but since I'm developing a dll which does not have a user interface tied to it, there will be no window to handle the callback. I need this to happen within the dll..

Any help would be appreciated..

Dan

parksie
Jan 3rd, 2001, 12:04 PM
I thought you were talking generically there :( Well, for that, you can use the WSAEventSelect function.

softwareguy74
Jan 3rd, 2001, 02:00 PM
Thanks, I think we might be getting somewhere.. But what I used:


HANDLE WSAAsyncGetHostByName(
HWND hWnd,
unsigned int wMsg,
const char FAR *name,
char FAR *buf,
int buflen
);


It requires the hWnd of a window to receive the message notification. Would I just specify the hWnd as NULL and then use the WSAEventSelect or is there something else I need to do?

Thanks,

Dan