Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Topmost property

14 views
Skip to first unread message

Simanovsky

unread,
Sep 18, 2003, 12:49:12 PM9/18/03
to
Hello,

I've got a problem with making a form topmost in the
application.
I need that a form is shown on top of other forms of my
application, but it should not be on top of other
applications windows.
I tried to use Form.TopMost property, but if I use it
the form appears also on top of other applications even
when the focus is not in my application. Callling
Form.BringToFront() on Focus event also does not work.
Has anybody any ideas on how I can achieve the desired
form behaviour?

Thanks in advance,
A.Simanovsky

Robert Jacobson

unread,
Sep 18, 2003, 1:13:19 PM9/18/03
to
There's an API call that might help, SetWindowLong with the GWL_HWNDPARENT
flag set. It takes the handles to two forms as an input, and makes one the
parent of the other -- the parent being below, and the child being always
on top of the parent.

There's some sample code in this post:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OD9lA6HtCHA.1644%40TK2MSFTNGP12

And more discussion of it here:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=eJ9l9g2JCHA.2160%40tkmsftngp10
(Complete thread)

You can also try the SetParent api call, but this is makes one form a child
MDI form to a parent form -- it doesn't just make it on top.

Hope this helps,
Robert Jacobson


"Simanovsky" <asima...@yahoo.com> wrote in message
news:031001c37e04$c97f06a0$a101...@phx.gbl...

Tom

unread,
Sep 18, 2003, 2:30:52 PM9/18/03
to
I found the easiest thing to do is something like:
dlgField.Owner = this.ParentForm;
(if your poping it up from a control), or

dlgField.Owner = this;

if you're bringing it up from a Form.

Tom Clement
Apptero, Inc.

"Simanovsky" <asima...@yahoo.com> wrote in message
news:031001c37e04$c97f06a0$a101...@phx.gbl...

> Hello,

Robert Jacobson

unread,
Sep 18, 2003, 3:00:17 PM9/18/03
to
I think that will make it behave like an MDI child window -- the child won't
be able to be positioned outside of the main form. (It gives the same
result as the SetParent api call, as far as I know.) That can be good or
bad, depending on what you need.


"Tom" <TomReM...@Apptero.com> wrote in message
news:e4R1FMhf...@TK2MSFTNGP11.phx.gbl...

Tom

unread,
Sep 18, 2003, 4:04:15 PM9/18/03
to
It actually does just what the original poster wants, as far as I can tell.
It doesn't limit the child to the boundaries of the parent form.
Tom

"Robert Jacobson" <rjacobson_at...@nospam.com> wrote in message
news:edSchchf...@TK2MSFTNGP09.phx.gbl...

Robert Jacobson

unread,
Sep 18, 2003, 4:47:38 PM9/18/03
to
Good to know. Thanks.


"Tom" <TomReM...@Apptero.com> wrote in message

news:ua0TRAi...@TK2MSFTNGP12.phx.gbl...

Simanovsky

unread,
Sep 19, 2003, 8:53:08 AM9/19/03
to
Hello Robert, Tom,

Thanks a lot. Your advice with SetWindowLong did help.
I also used Form.ShowDialog(IWin32Window) for modal forms.
Unfortunately, I could not use Form.Owner property as Tom
have suggested -- I'm sorry for not stating that my main
application window is not a .NET form.

WBR,
A.Simanovsky

0 new messages