Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to inport a win32 dll and get HWND parents
QtWS25 Last Chance

How to inport a win32 dll and get HWND parents

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 972 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmet4697
    wrote on 30 Apr 2015, 15:44 last edited by
    #1

    I want use a win32 dll file in my project .I am using MinGW compiler.how can import my dll into my project and use its functions.
    My dll have functions that need HWND parent windows. Can i use an Widget as window for HWND and how can i get HWND of a widget.
    Can anybody help me.I have a api header file for my dll.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sneubert
      wrote on 30 Apr 2015, 16:44 last edited by
      #2

      Hi ahmet4697,

      if you just have the dll and no import library you have to use the winapi functions LoadLibrary and GetProcAddress to call the functions inside the dll.

      The winID() member function of your widget will return a WId, that can be cast to HWND. The WId may change at run-time. Catch the WinIdChangeevent to update your HWND.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rondog
        wrote on 30 Apr 2015, 23:28 last edited by
        #3

        It depends on the reason for the DLL to need the HWND value and how it uses it.

        If, for example, the DLL uses SendMessage() to talk to the parent window then your DLL won't work properly without the message loop. There may be other reasons for passing the HWND value but likely this is the primary reason.

        For this scenerio what I have done is to register a window class and create a dummy hidden window, When you register the window class you will pass the call back function as one of the parameters. When you create the window all messages that belong to this window are sent to the call back function. Just add what is needed there.

        if the winID() function actually returns a HWND value (to a window class you know nothing about) you could install a message hook and monitor for messages that you need access to.

        Maybe the HWND value is not required for anything important in which case why not pass NULL to the DLL?.

        If you use 'LoadLibrary' you should make sure your DLL doesn't have the names mangled. In the DLL the exported functions should be decorated something like this:

        // BOOL Non_Manged_Name(DWORD);
        external "C" __declspec(dllexport) BOOL __cdecl Non_Mangled_Name(DWORD data);
        1 Reply Last reply
        0

        1/3

        30 Apr 2015, 15:44

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved