Hi all,
seems like I am trying to fight a "feature" here. Well, maybe there is some
help.
I am developing a multi-window Office add-on. It's not MDI, and the windows
are not all the same. As I don't want to handicap users working with Office
by modal dialogs, I have decided to make most of the dialogs modeless. Thus,
it is possible to open about 10 different windows simultaneously without
blocking the Office program.
The issue is that on activating any of the dialogs (by clicking the mouse in
it or activating the appropriate window button in the task bar), all of the
other open windows of my app are also put to the foreground even if the user
wanted to gain access only of the one form he/she clicked.
I suspect that this is an intended behaviour of VB6, but for me it's rather
inconvenient and I'd like to know about ways to get around it. I cannot put
each window in a different thread (it's VB6), and even if it were possible
that way, it still demands too much time to develop and may have some
negative impact on the application's overall stability.
Steps for reproduction:
- create a new standard VB6 EXE project
- add a new module to the project so now you have an unnamed form and an
unnamed module
- in the project properties, set startup mode to "Sub Main()"
- create a sub Main() in the module, with the following source code:
Sub Main()
Dim oFrm As Form1
Dim n As Long
For n = 1 To 10
Set oFrm = New Form1
Call oFrm.Show
Set oFrm = Nothing
Next
End Sub
Running the project will result in a cascade of 10 windows in the top-left
corner of the screen. Drag any of them to a random screen position, then put
some different window in the foreground in the top-left corner (e.g. an
Explorer) so it hides the other nine windows at least partially.
Clicking on the one you dragged away will show not only the one on which you
clicked, but also the nine other windows from behind the Explorer will
reappear in front of it unintendedly. You can repeat this with any of the 10
windows. Activating any of them will always make all of the windows topmost.
Is there some way to make sure that the nine hidden windows stay in the
background in this situation? I'd like to do this the cleanest way possible
to make sure it runs in any environment, does not produce flicker or other
inconveniences.
Thank you a lot for your help!
Regards,
Joe
Archived from group: microsoft>public>vb>winapi