• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

Help DLL PostMessage ???


   I have write a DLL which is staticly linking to the main application and I want to post a message to the main window from the DLL by using PostMessage(...) to indicate the progress of work being done.
   However,there 's no success after a number of trials.

   Or what else should I do in order to achieve this purpose???

   Could anyone kindly tell me what's wrong with it???

Thankyou !
  • 2
1 Solution
Your dll (Dynamic Link Library) is staticly linked?  I'll guess that you mean implicitly linked.

You didn't really give enough information to say what exactly your problem is, but here are some good canidates:

1)The DLL doesn't have the HWND of the main window.  You can check this by using a tool like spy to see what the HWND really is, or many other methods.

2)The DLL and the main program aren't using the same message number.  If you defined the message yourself, make sure both the DLL and the main program are using the same header file.  For testing, try using a predefined message number (WM_USER, or WM_NULL are some good choices).

3) You don't return to your GetMessaageLoop.  This will happen if either the DLL or the Main Program is in a continuous loop and not calling PeekMessage or GetMessage.

If this is the case, and you don't have multiple threads involved, you can use SendMessage.  SendMessage will always transfer control to the Main Window WndProc.

4) You don't have a handler for this particular message.  In which case you just need to add one to your message map.

My guess would be #3.
surenechanAuthor Commented:
Thank you !!!
It work now after I use SendMessage instead of PostMessage .

So now we know the answer was #3.  Glad all is well.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now