|
-
Jan 3rd, 2001, 02:53 AM
#1
Thread Starter
Frenzied Member
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
-
Jan 3rd, 2001, 06:41 AM
#2
Monday Morning Lunatic
I'd use a function callback. Just call another function in the DLL to say you've finished.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 3rd, 2001, 09:22 AM
#3
Thread Starter
Frenzied Member
How would I do that? Say I'm using the following api function:
Code:
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
-
Jan 3rd, 2001, 01:04 PM
#4
Monday Morning Lunatic
I thought you were talking generically there Well, for that, you can use the WSAEventSelect function.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 3rd, 2001, 03:00 PM
#5
Thread Starter
Frenzied Member
Thanks, I think we might be getting somewhere.. But what I used:
Code:
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|