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

help intercepting win32 messages and delaying the message being processed

Hi guys,

I hope you can help here. I created a program which 'hooks' into an external programs window win32 messages and adds a couple of buttons.

To do this i detect and intercept the programs WM_WINPOSCHANGED message. When i intercept this message i check if the window being opened is the one i want to add the buttons to (using the window title) and i add my button to the screen. However this has caused a couple of problems.

I have found out that there are a couple of windows with the same window title (i.e. "customers") that do totally different things, and so to distinguish between the different windows  i decided to look for a field on the screen which was unique to that screen, i.e. a field with the text "contacts".

So when i intercept the WM_WINPOSCHANGED from the window with the title "customers" i set up an EnumChildProc of its windows and iterate through the windows to see if a window with the text "contacts" is present. if so than i will want to add the button.

however the is when the WM_WINPOSCHANGED message is sent for the window "customers" all of the child windows have not been added to the screen. so when i  iterate through using the EmunChildProc i don't iterate through all the windows, and so cannot check the text in the field.

(this also adds the problem of the buttons not being added to the top the screen, but this can be solved using BringWindoToTop()).

Now, would it be possible to detect the WM_WINPOSCHANGED message and somehow put a hold (using a timer or something) executing my check and add button code until all the windows have been added?

(Could i perhaps intercept the WM_WINPOSCHANGED message wait and then post my own user message which would add the buttons? how would i do this?)

many thanks,

  • 4
1 Solution
flynnyAuthor Commented:
sorry guys the message i was intecepting was the WM_WINPOSCHANGED not WM_WINDOWCHANGED
flynnyAuthor Commented:
would it be worth trying WaitForInputIdle() for this?
if so, would this be possible to execute inside a callback function? i.e. the method waits until there is not message left to process in the thread, but if i'm processing the thread then is this possible?
>>Now, would it be possible to detect the WM_WINPOSCHANGED message and
>>somehow put a hold (using a timer or something) executing my check and add
>>button code until all the windows have been added?

You should be able to do that in a WH_GETMESSAGE hook. Just store the message and remove it via

MSG msg;
flynnyAuthor Commented:
As i'm still having problems in my other thread and as my questions are interlinked now i'll join this to my other question here.


flynnyAuthor Commented:
great thanks for all your help jkr
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

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