By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,833 Members | 2,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,833 IT Pros & Developers. It's quick & easy.

How to display a notification form on top of the main form?

P: n/a
I have a separate thread that handles data transfer operations (with a mobile
device). I've set things up so that a small notification form is displayed
in the lower right corner of the window. This all works fine.

But what I can't figure out how to do is to get it to display on top of my
main form, if the main form is maximized. I've tried all of the following:

statusForm = new frmNotify();
statusForm.Show(); // Display Notification Window asynchronously

statusForm.Focus();
BringWindowToTop((int) statusForm.Handle);
SetForegroundWindow(statusForm.Handle);

With the last two being API calls. But nothing seems to work. I KNOW that
this notification form will display over top of the main form because I can
do so manually but I can't seem to do so programmatically. What am I missing?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Robert,
I am not sure why you can't get the form to show ontop of your main form,
unless the main form has a proprety like TopMost set to true.

You could set your small form to have it's TopMost property set to true
and see if that helps you, then it will always be ontop of the other form.

Mark.

"Robert W." wrote:
I have a separate thread that handles data transfer operations (with a mobile
device). I've set things up so that a small notification form is displayed
in the lower right corner of the window. This all works fine.

But what I can't figure out how to do is to get it to display on top of my
main form, if the main form is maximized. I've tried all of the following:

statusForm = new frmNotify();
statusForm.Show(); // Display Notification Window asynchronously

statusForm.Focus();
BringWindowToTop((int) statusForm.Handle);
SetForegroundWindow(statusForm.Handle);

With the last two being API calls. But nothing seems to work. I KNOW that
this notification form will display over top of the main form because I can
do so manually but I can't seem to do so programmatically. What am I missing?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2

P: n/a
Mark,

Coming from the VB6 world, I wasn't aware of the TopMost property. I just
checked and both forms had it set to False. So I set my Notification form's
TopMost property to True and voila, it worked.

Thank you!!!

P.S. I think I need more coffee and less sleep (or is it the other way
around?)

--
Robert W.
Vancouver, BC
www.mwtech.com

"Mark R. Dawson" wrote:
Hi Robert,
I am not sure why you can't get the form to show ontop of your main form,
unless the main form has a proprety like TopMost set to true.

You could set your small form to have it's TopMost property set to true
and see if that helps you, then it will always be ontop of the other form.

Mark.

"Robert W." wrote:
I have a separate thread that handles data transfer operations (with a mobile
device). I've set things up so that a small notification form is displayed
in the lower right corner of the window. This all works fine.

But what I can't figure out how to do is to get it to display on top of my
main form, if the main form is maximized. I've tried all of the following:

statusForm = new frmNotify();
statusForm.Show(); // Display Notification Window asynchronously

statusForm.Focus();
BringWindowToTop((int) statusForm.Handle);
SetForegroundWindow(statusForm.Handle);

With the last two being API calls. But nothing seems to work. I KNOW that
this notification form will display over top of the main form because I can
do so manually but I can't seem to do so programmatically. What am I missing?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #3

P: n/a
If you need the notification form to display over all open windows, you
can set the TopMost property of the form to true
statusForm.TopMost=true;

If you just need the notification form to display just over your main
form whenever your main form is in view, then you need to set the Owner
property of your notification form.

statusForm.Owner=mainForm;
// OR
mainForm.AddOwnedForm(statusForm);

However, keep in mind that when a form is owned by another form, it is
minimized and closed with the owner form. For example, if Form2 is
owned by form Form1, if Form1 is closed or minimized, Form2 is also
closed or minimized.

Sarin.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.