473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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

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
3 3066
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
1
by: iggie | last post by:
Hello, everyone. How can I display text from another form that currently has the focus. I'm doing a search in sql 2000, to dot it. I call a search form and query my criteria, when it founds the...
9
by: yezanxiong | last post by:
Hello all, I am new in asp.net developer,I would like to ask a simple question. how to display a message box in web application using asp.net? If I just use Private Sub btnOK_Click(ByVal...
1
by: Johnfcf | last post by:
I have a database consisting of 3 tables, the main table with main contact info, a second table with additional address info and a third table consisting of additional contact information, or more...
2
by: N. Graves | last post by:
Thanks for your help and reading my note! I would like to display an image that would let the user know that more information was stored in a comments field. If the comments field is empty I...
11
by: bala | last post by:
hi!!! i need to display a disclaimer which is two page in length in a word document. i also need to format the text. the idea is something as follows on opening the application, a form which...
0
by: yasker | last post by:
Hi, I got a problem in display a sub form. My app contains two form: main and sub. I want sub form display before main form, to provide some information to it. I use a NotifyIcon to activity...
1
by: Regnab | last post by:
I've got a form where the user can edit the lookups available in the database. It consists of a list box of the various categories on the main form, a checkbox on the main form and a sub form which...
1
by: Claire | last post by:
Hi, I've a problem. Our app has a main screen, a user logs in to the system using a smart card. After login, several loops through a switch statement are performed to check for certain...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.