Thread: Creating object of type HWND from a dll

  1. #1
    Unregistered
    Guest

    Question Creating object of type HWND from a dll

    I am Java programmer who is pretty inexperienced when it comes to windows programming. I am trying to create a DLL that calls some native Windows code written by a third party. I can then call this DLL from my Java code via Java Native Interface.

    The problem is, the functions I have to call from the DLL I am writing require that I pass an object of type HWND. In Visual C++ 6, I can get an HWND object if I am creating a Windows Application, but I need to create a Windows DLL, not an Application.

    So, how can I create an object of type HWND inside a DLL? The only reason I have to pass the HWND object is because the native code uses a Windows Timer that it gets from the HWND obejct, so it doesn't have to be a sophisticated HWND object, just one that can supply a Windows Timer.

    Thanks,
    Nick

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    The easiest way I suppose is to use FindWindow()...

    The problem is, the functions I have to call from the DLL I am writing require that I pass an object of type HWND. In Visual C++ 6, I can get an HWND object if I am creating a Windows Application, but I need to create a Windows DLL, not an Application.
    The reason why SetTimer need a HWND is because that window will then process the WM_TIMER messages that are received.....if you have no window that you will not be able to process these messages

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    And you need the same HWND to stop / kill the timer (should you have more than one dlg / window using the same callback).

    GetActiveWindow() could help, 'retrieves the window handle to the active window attached to the calling thread's message queue'.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Trying to make C++ DLL, got a problem with hWnd
    By Ragoune in forum C++ Programming
    Replies: 8
    Last Post: 03-11-2009, 03:24 PM
  3. DLL Global Object Constructor String Error
    By n00b3 in forum Windows Programming
    Replies: 1
    Last Post: 06-29-2008, 07:42 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. Replies: 3
    Last Post: 12-03-2001, 01:45 PM