Link to home
Start Free TrialLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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,

matt.
Avatar of flynny
flynny
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

sorry guys the message i was intecepting was the WM_WINPOSCHANGED not WM_WINDOWCHANGED
Avatar of flynny

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of flynny

ASKER

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.

https://www.experts-exchange.com/questions/23144025/Help-using-postmessage-and-WM-USER.html

Avatar of flynny

ASKER

great thanks for all your help jkr