CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2005
    Posts
    59

    A HWND without a Window

    I'd like to create a HWND to process messages (to give to Winsock applications). I'd like to use as little memory as possible.

  2. #2
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658

    Re: A HWND without a Window

    http://www.codeproject.com/internet/winsockintro03.asp

    Does that article help you at all? What you're asking about is having a message pump, but without a window. You can't really have a HWND without a window, but you can create a window that simply never appears. However, before you go through all that trouble, why not see if that article helps If not, post a reply and we'll see what we can do.
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  3. #3
    Join Date
    Jun 2005
    Posts
    59

    Re: A HWND without a Window

    I know Winsock, and that's a nice article, I could still learn stuff from it (like command line arguments). I've built a few client/server programs before, but this is how my newest app will work.

    The program loads a DLL. The DLL does all the work, including intercepting the Winsock Messages it wants.

    It would be kinda messy if the user had to code the messages in their own WinProc, plus then it would be limited to Windows and GUI apps.

  4. #4
    Join Date
    Sep 2005
    Posts
    11

    Re: A HWND without a Window

    Did I understand you well, that you are the author of that Dll?
    Then may ::GetActiveWindow() help you. It retrieves the HWND of the thread's active window.

  5. #5
    Join Date
    Dec 2002
    Location
    St.Louis MO, USA
    Posts
    672

    Re: A HWND without a Window

    As my understanding u have a dll which deals with socket sending and receiving and u want to pass a HWND to ur dll to get intercept when any message is received or want to send a message.

    Why u did not use function pointers, set your OnReceive function pointer in ur dll and get your dll's OnSend function pointer in ur code. and its not limited to GUI or HWND.
    A Person who is polite is given goodness and a person who is away from Politeness is away from Goodness.

    NAUMAAN

  6. #6
    Join Date
    Jul 2005
    Location
    Germany
    Posts
    1,194

    Re: A HWND without a Window

    I don't know if I understood you:
    Do you want the HWND to process the winsock notifications from WSAAsyncSelect() ?
    If you don't have a window you can also use event objects with WSAEventSelect() and create a thread which waits for the events.
    Please don't forget to rate users who helped you!

  7. #7
    Join Date
    Jun 2005
    Posts
    59

    Re: A HWND without a Window

    I want to create a HWND inside the DLL for use with the DLL.

    I don't want the person using the DLL have anything to do with passing a HWND, because I might port this to Linux, or it may be a Win32 console app.

    For that reason, I need to create my OWN HWND.

  8. #8
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658

    Re: A HWND without a Window

    Do you need an HWND or are you just looking for asynch (non-blocking) sockets so you can do other things while waiting for a receive? If so, you can do that with winsock. Do a search for: select winsock asynchronous

    the select function will probably get you what you want without requiring a window. In fact, if you do some research and see that it will get you what you want (without requiring a HWND) I'll attach a TFTP (trivial file transfer protocol) server/client I had to do back in college. It's pretty, well, trivial, so it might help you see how it's done
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  9. #9
    Join Date
    Jun 2005
    Posts
    59

    Re: A HWND without a Window

    I know about ASYNC Winsock, as I've used it in a couple apps now.

    I also will probably use a timer, and maybe other things I might need one for.

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

Featured