473,395 Members | 1,474 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,395 software developers and data experts.

Keep my application on top

Hi, Group

I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.

Please let me know

Best regard
MArio
Nov 15 '05 #1
6 10007
> I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.


I don't believe you can without reverting to Win32 API funtions. I simply
needed a BringToFront for the main application window and couldn't find it,
Win32's SetForeGroundWindow seemed the only way.

Martin.
Nov 15 '05 #2
> I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.


I don't believe you can without reverting to Win32 API funtions. I simply
needed a BringToFront for the main application window and couldn't find it,
Win32's SetForeGroundWindow seemed the only way.

Martin.
Nov 15 '05 #3
Mario,

You can get top most behavior by setting the form property TopMost to
boolean true; Something like this:

/* ************************************** */
private void Form1_Load(object sender, System.EventArgs e) {
this.TopMost = true;
}
This will keep your for above all other windows, until another application
sets a window to TopMost -- then all TopMost windows compete for top most
based on foreground/active states...

One side note - debugging an app with a TopMost window is a bit of a pain -
the Debugger/IDE is ends up behind the app form...

I hope this helps a bit....

regards
roy fine
"Mario Reiley" <mr*****@cantv.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Group

I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.

Please let me know

Best regard
MArio

Nov 15 '05 #4
Mario,

You can get top most behavior by setting the form property TopMost to
boolean true; Something like this:

/* ************************************** */
private void Form1_Load(object sender, System.EventArgs e) {
this.TopMost = true;
}
This will keep your for above all other windows, until another application
sets a window to TopMost -- then all TopMost windows compete for top most
based on foreground/active states...

One side note - debugging an app with a TopMost window is a bit of a pain -
the Debugger/IDE is ends up behind the app form...

I hope this helps a bit....

regards
roy fine
"Mario Reiley" <mr*****@cantv.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Group

I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.

Please let me know

Best regard
MArio

Nov 15 '05 #5
> You can get top most behavior by setting the form property
TopMost to boolean true;


I don't know what I did wrong before but this just works now. I had been
messing with it and found it didn't work for forms, I must have been
screwing something up. I ended up doing

// couldn't find a .NET-way to bring the window
// to top, reverting to old Win32 functions...
[DllImport("User32.dll")]
public static extern Int32 FindWindow(String lpClassName,String
lpWindowName);
[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);

private void triMain_Click(object sender, System.EventArgs e)
{
Show();
int hWnd = FindWindow(null, "Pacemaker"); // Win32 API, don't want
to use this
SetForegroundWindow(hWnd); // Wim32 API, don't want to use this
}

Now it is clean:

Show();
TopMost = true;
TopMost = false;

I am resetting TopMost to false because I just want it to bring the form to
top when the tray icon is clicked and not stay on top persistently.

Thank you!

Martin.
Nov 15 '05 #6
OK guys Thanks for all

Mario

"Mario Reiley" <mr*****@cantv.net> escribió en el mensaje
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi, Group

I am C# and VB.6 programmer but in this moments I have the followin
question:

How Can I keep my application on the top of all applications on my Windows
desktop.

Please let me know

Best regard
MArio

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Fisher | last post by:
I have a Java desktop GUI application that the user can run multiple times. In order to keep one instance of the application distinct from another, I'd like to put the instance number of the...
2
by: medhanush | last post by:
Hi, Can somebody please tell me how to keep application running even though user logs out ? scenario is, user logs in, starts an exe and logs out, exe need to run for couple of hours. One...
3
by: Jeff Greenland | last post by:
Hello everyone, I am having problems with Timers in a web application. They just seem to stop running after 15 minutes or so. My web application is set up like this: When a user hits a...
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
1
by: ChainsawDude | last post by:
I can keep the session variables across application restarts by storing the session state in StateServer (rather than inprocess). However, the application variables are still lost! Please would...
6
by: Mad Scientist Jr | last post by:
My asp.net pages sessions are timing out after 20 minutes, and when I asked my Web host about it they said due to the nature of a shared hosting environment they cannot allow for sessions to keep...
2
by: Mark Huebner | last post by:
I am trying to create a web application with Visual Studio 2005 and C# that will start up a "keep alive" application on my web site's server. My DotNetNuke home page loads slowly when the site...
35
by: salad | last post by:
I have an application written in MS-Access. It is a complete application that manages the day-to-day operations of a business. The program is nearly ready to be used in other customer sites. ...
2
by: manontheedge | last post by:
In Visual Basic, how do I keep a program that I'm running on top of EVERYTHING? For example, I have an application in Visual Basic that has a GUI, and I want it to stay on top of anything that may...
7
by: mail747097 | last post by:
I would like to keep IIS alive on my web site and prevent Application_End from occuring in global.asax. Any ideas?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.