Sinna
2007-02-12 09:37:18 UTC
Hi all,
I started a new chapter in the SetFocus issue as I found out it really
had nothing to do with the ShellExecuteEx API itself.
(Sorry for the long post but it's quite difficult to situate the issue here)
First some explanation of what I want to achieve:
I want to mimic the Windows Explorer by allowing the user to launch the
associated executable for a given file (for editing). I also want to
monitor if the user has made some changes to the file to keep it in sync
with the server.
To launch the associated executable, I use the ShellExecuteEx API (as
mentioned in the ShellExecuteEx SetFocus problem thread). In that way I
don't have to look up the associated executable myself. (Why re-invent
the wheel?).
To monitor changes in the opened/edited file, I monitor for the closing
of the launched application using the MsgWaitForMultipleObjects API.
Now the problem:
Due to the fact that VB is single-threaded, In some cases I experience
timing issues causing my application to appear stalling. To circumvent
this, I launch a worker thread (read: separate ActiveX EXE) that deals
with the MsgWaitForMultipleObjects API. This has a nasty side-effect as
the application launched does not pop up but seems to be minimized in
the task bar. The launched application receives the focus (blinking a
few times), but it doesn't pop up.
As long as I don't use the separate ActiveX EXE, everything works as
expected.
What I assume is that, since the ActiveX EXE has no GUI, the OS doesn't
know where to put the launched application in front of.
Calling the AppActive statement doesn't work out.
Strange enough, when using the ShellExecuteEx API, it works as expected
in 95% of the cases, but fails in the other 5% causing major grief by
the end user. If I look up the associated executable myself (digging
into the registry) and launches the application using the built-in Shell
function, it fails in 95% of the case, succeeding in the other 5%.
Any suggestions how to deal with this nasty side effect?
Please feel free to ask some sources, but it's quite difficult to post
them as they are quite large.
Thanks in advance,
Sinna
I started a new chapter in the SetFocus issue as I found out it really
had nothing to do with the ShellExecuteEx API itself.
(Sorry for the long post but it's quite difficult to situate the issue here)
First some explanation of what I want to achieve:
I want to mimic the Windows Explorer by allowing the user to launch the
associated executable for a given file (for editing). I also want to
monitor if the user has made some changes to the file to keep it in sync
with the server.
To launch the associated executable, I use the ShellExecuteEx API (as
mentioned in the ShellExecuteEx SetFocus problem thread). In that way I
don't have to look up the associated executable myself. (Why re-invent
the wheel?).
To monitor changes in the opened/edited file, I monitor for the closing
of the launched application using the MsgWaitForMultipleObjects API.
Now the problem:
Due to the fact that VB is single-threaded, In some cases I experience
timing issues causing my application to appear stalling. To circumvent
this, I launch a worker thread (read: separate ActiveX EXE) that deals
with the MsgWaitForMultipleObjects API. This has a nasty side-effect as
the application launched does not pop up but seems to be minimized in
the task bar. The launched application receives the focus (blinking a
few times), but it doesn't pop up.
As long as I don't use the separate ActiveX EXE, everything works as
expected.
What I assume is that, since the ActiveX EXE has no GUI, the OS doesn't
know where to put the launched application in front of.
Calling the AppActive statement doesn't work out.
Strange enough, when using the ShellExecuteEx API, it works as expected
in 95% of the cases, but fails in the other 5% causing major grief by
the end user. If I look up the associated executable myself (digging
into the registry) and launches the application using the built-in Shell
function, it fails in 95% of the case, succeeding in the other 5%.
Any suggestions how to deal with this nasty side effect?
Please feel free to ask some sources, but it's quite difficult to post
them as they are quite large.
Thanks in advance,
Sinna