Results 1 to 5 of 5

Thread: Windows messaging question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    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

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    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

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    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
  •  



Click Here to Expand Forum to Full Width