How to inport a win32 dll and get HWND parents
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.
if you just have the dll and no import library you have to use the winapi functions
GetProcAddressto call the functions inside the dll.
winID()member function of your widget will return a
WId, that can be cast to
WIdmay change at run-time. Catch the
WinIdChangeevent to update your
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);