> We use an program (Bentley's MicroStation CADD software)
> that opens two application windows. The VB (actually VBA)
> app that I'm writing needs to:
>
> 1. Stay on top of BOTH of these two windows.
If you know the Titles of these windows, use "FindWindow" to get a handle to
one of the windows.
If not, or they change... you may be able to use Spy++ or something similar
to find the Program Windows' Class Name, and then use that as the first
Parameter in FindWindow.
hWindow1 = FindWindow(vbNullString, "Bentley's MicroStation CADD")
Then all you need to do is use "SetWindowPos" with that Window's Handle.
SetWindowPos(Me.hWnd, hWindow1, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOMOVE or
SWP_NOSIZE)
Now, not knowing how the program works makes it a bit difficult to get it to
appear above both windows.
Does the program bring both Windows to the top when you click one?
If so, the way I would do things would be to use the "GetWindow" function.
hWindow2 = FindWindow(vbNullString, "Bentley's MicroStation CADD Window 2")
First get a handle to the second window.
If GetWindow(hWindow1, GW_HWNDPREV) = hWindow2 Then
Now get the Window Handle that is above Window 1, and compare it to Window
2's Handle.
If they are the same, call SetWindowPos with hWindow2 instead of hWindow1.
That way it will stay above both Windows.
> 2. Minimize along with the main program window.
Check out the "GetWindowPlacement" function. The simplest way would be to
have a timer that checks when the window is minimised, and then minimise
your VB application.
> 3. NOT obscure other windows applications.
That should happen if you maintain the Z-Order of your window properly with
the above code. I don't know if you can make your window stay in the
background when it is activated.
> 4. NOT show up in the task bar.
The Form itself has a property "ShowInTaskbar". Set it to False.
Not sure if VBA has that property though, probably not since it's pretty
obvious.
> 5. (Optional) Ensure my early, wealthy retirement.
*chuckle* Good luck with that one.
> So far, I've managed to make my app EITHER stay on top of
> ALL other applications, or on top of ONE of Bentley's two
[quoted text clipped - 9 lines]
>
> Thanks, in advance, for any help and suggestions you can offer.
Patrick Pirtle - 27 Sep 2003 21:42 GMT
MANY thanks for your reply. I'm anxious to try these
suggestions.
In answer to your questionS:
> Does the program bring both Windows to the top when you click one?
> If so, the way I would do things would be to use the "GetWindow" function.
The Bentley app windows act somewhat independently. Either one
can be minimized without affecting the other. However, if one is
closed by clicking the form close icon, the program terminates.
> If you know the Titles of these windows, use "FindWindow" to get a handle to
> one of the windows.
The titles both are the same, and are the path and filename of the drawing
I'm
currently working on, so it should be easy to use your suggested solution.
Thanks, again. I'll try these suggestions when I get to work on
Monday.
----- Original Message -----
From: "AlphaGremlin" <@hotmail.com>
Newsgroups: microsoft.public.vb.winapi
Sent: Saturday, September 27, 2003 4:07 AM
Subject: Re: A new (?) twist on the old Form-on-top question
> > We use an program (Bentley's MicroStation CADD software)
> > that opens two application windows.
[snip]
> We use an program (Bentley's MicroStation CADD software)
> that opens two application windows. The VB (actually VBA)
[quoted text clipped - 23 lines]
>
> Thanks, in advance, for any help and suggestions you can offer.
You say you are writing a VBA program... are you writing you program in the
VB that is bundled inside of Microstation (in the "old" days, it was named
Microstation Basic, but I have a hunch it isn't referred to that way
anymore). If so, you should have a **rich** set of built-in functions and
subroutines available to you with which to control the entire Microstation
session. Do you have any documentation for the built-in Basic? Check the
written documentation (if they still distribute that), the CD or the Bentley
web site. I've not worked with Microstation for a few years now, so my
knowledge is only about the original form of Microstation Basic, but they
should not have changed it (function/subroutine-wise) too much since then.
Patrick Pirtle - 29 Sep 2003 15:39 GMT
Thanks, Rick, for your reply. You're right about the terrific
support for MicroStation that Bentley provided in the original
MicroStation Basic Environment (MBE.) As they did with
user commands, they are now phasing MBE out, and are
moving into true VBA. They're doing a GREAT job of it
as well. Their only failing in this respect, as is the case with
so many software packages, is that they provide documentation
only through compiled on-line help. [briefly stepping onto my
soapbox] I've NEVER seen an on-line help package that
was anything more than a collection of over-linked random
thoughts! [...and stepping off again.]
BTW, you say you're no longer working with MicroStation.
Did you leave the field, or go over to the "Dark Side" - AutoCad?
Hehe
>> We use an program (Bentley's MicroStation CADD software)
>> that opens two application windows.
[snip]
> You say you are writing a VBA program... are you writing you program
> in the VB that is bundled inside of Microstation (in the "old" days,
> it was named Microstation Basic, but I have a hunch it isn't
referred
> to that way anymore). If so, you should have a **rich** set of
> built-in functions and subroutines available to you with which to
> control the entire Microstation session. Do you have any
> documentation for the built-in Basic? Check the written
documentation
> (if they still distribute that), the CD or the Bentley web site.
I've
> not worked with Microstation for a few years now, so my knowledge is
> only about the original form of Microstation Basic, but they should
> not have changed it (function/subroutine-wise) too much since then.
Rick Rothstein - 29 Sep 2003 16:28 GMT
> Thanks, Rick, for your reply. You're right about the terrific
> support for MicroStation that Bentley provided in the original
> MicroStation Basic Environment (MBE.) As they did with
> user commands, they are now phasing MBE out, and are
> moving into true VBA.
But the VBA environment must still offer the rich library of functions for
manipulating your Microstation environment and drawings, right? You should
be able to do anything you want using them. There must be some documentation
on them, even if it is on the CD. I'd be surprised if there wasn't a true
reference guide available there for the various functions and methods
available. If not, I'd contact Bentley directly and ask them for one (it
**must** exist).
> BTW, you say you're no longer working with MicroStation.
> Did you leave the field, or go over to the "Dark Side" - AutoCad?
> Hehe
Even better... I retired. I worked in the New Jersey Department of
Transportation's CADD development program for the last 13 or so years of my
career (although I had some non-CADD assignments thrown in there from
time-to-time). We were then, and they still are, a Microstation shop.
Autocad... pfffttt!
Rick - MVP