Board index » cppbuilder » SetFocus not working for created process

SetFocus not working for created process


2004-07-04 02:12:33 PM
cppbuilder81
Hi, my app uses createprocess with CREATE_SUSPENDED so i can load job
objects. As such waitidleinput doesn't work the way it should. To get around
this, i'm sleeping my app until the foreground window is the top level
window of the launced app.Problem is, i must stop the user from clicking
other app. windows and bringing their windows to the top. To do this i use
blockinput, prior to and after createprocess along with a sleep. Viola, for
the second or so it takes to create the new process i get the window of the
newly opened app. which is what i want.
Problem - the newly opened app is the foreground app. i can see that and
test it. But, when i mouse click the apps window, the first click removes
focus from that window, and the second click refocuses.
How do i get past this? - this behaviour goes away if i don't use
blockinput.
I have already tried all the various setfocus functions etc. including
AttachThreadInput between my own app and the thread of the newly opened
app.. but to no avail.
There are at least 2 solutions - use a differnet method than blockinput or
solve the problem induced by block input.
Can anyone help me either way on this one please.
Many thanks in advance, Angus.
 
 

Re:SetFocus not working for created process

Well, the answer is P. But then i guess you all knew that correct. Adding
hooks instead of blockinput()
is the most obvious way to suck the messages out of the queue and just bin
them. Works a charm.
Angus
"Angus" < XXXX@XXXXX.COM >wrote in message
Quote
Hi, my app uses createprocess with CREATE_SUSPENDED so i can load job
objects. As such waitidleinput doesn't work the way it should. To get
around
this, i'm sleeping my app until the foreground window is the top level
window of the launced app.Problem is, i must stop the user from clicking
other app. windows and bringing their windows to the top. To do this i use
blockinput, prior to and after createprocess along with a sleep. Viola,
for
the second or so it takes to create the new process i get the window of
the
newly opened app. which is what i want.
Problem - the newly opened app is the foreground app. i can see that and
test it. But, when i mouse click the apps window, the first click removes
focus from that window, and the second click refocuses.

How do i get past this? - this behaviour goes away if i don't use
blockinput.

I have already tried all the various setfocus functions etc. including
AttachThreadInput between my own app and the thread of the newly opened
app.. but to no avail.

There are at least 2 solutions - use a differnet method than blockinput or
solve the problem induced by block input.
Can anyone help me either way on this one please.

Many thanks in advance, Angus.