1) How to prevent user to run secound copy of application
on the same mahine? I would like to show dialog
"Already run" instead of launching a secound insrance.
2) Why, if minimized into a notify icon, my application
prevents Windows from shutdown and restart?
I'm handling SessionEnding event and it works fine if
application window is showed to the user but when window
is hidden and notyfy icon is displayed instead, it doesn't
work at all... Windows is not shutting down...
3) How to enable WindowsService option "Allow interact with dektop"
from service installer? Without that option checked my service
desnt show notify icon ... I couldn't find that option enywhere ... 8 2250
use the following code in order to start the application.
[System.Diagnostics.DebuggerStepThrough()]
[STAThread]
static void Main()
{
Application.Run(new Form1());
Application.Exit();
Environment.Exit(0);
}
"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:ux*************@tk2msftngp13.phx.gbl... 1) How to prevent user to run secound copy of application on the same mahine? I would like to show dialog "Already run" instead of launching a secound insrance. 2) Why, if minimized into a notify icon, my application prevents Windows from shutdown and restart? I'm handling SessionEnding event and it works fine if application window is showed to the user but when window is hidden and notyfy icon is displayed instead, it doesn't work at all... Windows is not shutting down... 3) How to enable WindowsService option "Allow interact with dektop" from service installer? Without that option checked my service desnt show notify icon ... I couldn't find that option enywhere ...
Windows Forms Tips and Tricks shows you how to prevent a second copy running
and bring the first copy to the foreground.
Instead of hiding the main application window when the notifyicon is shown,
move it off screen and make it very small so that it cannot be seen. This
will allow the message loop to keep running.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:ux*************@tk2msftngp13.phx.gbl... 1) How to prevent user to run secound copy of application on the same mahine? I would like to show dialog "Already run" instead of launching a secound insrance. 2) Why, if minimized into a notify icon, my application prevents Windows from shutdown and restart? I'm handling SessionEnding event and it works fine if application window is showed to the user but when window is hidden and notyfy icon is displayed instead, it doesn't work at all... Windows is not shutting down... 3) How to enable WindowsService option "Allow interact with dektop" from service installer? Without that option checked my service desnt show notify icon ... I couldn't find that option enywhere ... Instead of hiding the main application window when the notifyicon is shown, move it off screen and make it very small so that it cannot be seen. This will allow the message loop to keep running.
Why? I'm affraid that my not hidden window will capture the focus
in windows window queue and user will be confused "where the focus gone".
Why hiding window is stoppinh a "message loop"?
Hi,
"Jacek Jurkowski" <jj********@datacomp.szczecin.pl> wrote in message
news:ux*************@tk2msftngp13.phx.gbl... 1) How to prevent user to run secound copy of application on the same mahine? I would like to show dialog "Already run" instead of launching a secound insrance.
http://www.yoda.arachsys.com/csharp/...ation.instance
2) Why, if minimized into a notify icon, my application prevents Windows from shutdown and restart? I'm handling SessionEnding event and it works fine if application window is showed to the user but when window is hidden and notyfy icon is displayed instead, it doesn't work at all... Windows is not shutting down...
Being in the systray is not inpediment to shutdown, are you processing the
Close event?
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
>> 2) Why, if minimized into a notify icon, my application prevents Windows from shutdown and restart? I'm handling SessionEnding event and it works fine if application window is showed to the user but when window is hidden and notyfy icon is displayed instead, it doesn't work at all... Windows is not shutting down... Being in the systray is not inpediment to shutdown, are you processing the Close event?
Yes I did but seems to SessionEnding event doesn't raise
in that state ...
Trick with hoding window outside the screen doesn't help
anyway ... there is no way to close my application with
NotifyIcon displayed ...
cheers,
Hi, Trick with hoding window outside the screen doesn't help anyway ... there is no way to close my application with NotifyIcon displayed ...
The bad thing about the window solution is that it's displayed using
alt+tab ( this can be solved though )
what I don't understand is what is the problem with the systray , I have a
couple of application running like this and I have never had a complain from
the client that he can not shutdown, he does it everydays cause he has the
theory that it's good for the computers :)
I will run them when I get home and let you know what happens
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jacek,
In your Closing event, are you doing something like this to iconise the form
when it is closed?
private void MainForm_Closing(object sender, CancelEventArgs e)
{
e.Cancel = true;
Hide();
}
if so then this event will be firing before the SessionEnding event, and
prevent SessionEnding (because you have prvented the form from closing).
A solution is to change the above to:
if (this.Visible)
{
e.Cancel = true;
Hide();
}
Now the form will iconise if it is fully open, but if it's already iconised
then Closing won't be cancelled and SessionEnding gets a chance.
The downside is that now you can't log off immediately if the form is fully
open, but if the normal state is iconised that won't be a big problem.
Chris
"Jacek Jurkowski" wrote: 2) Why, if minimized into a notify icon, my application prevents Windows from shutdown and restart? I'm handling SessionEnding event and it works fine if application window is showed to the user but when window is hidden and notyfy icon is displayed instead, it doesn't work at all... Windows is not shutting down...
Being in the systray is not inpediment to shutdown, are you processing the Close event?
Yes I did but seems to SessionEnding event doesn't raise in that state ...
Trick with hoding window outside the screen doesn't help anyway ... there is no way to close my application with NotifyIcon displayed ...
cheers,
Using Hide() in Main application window doesn't actually
hide it bu releases it and application is ending... A solution is to change the above to:
if (this.Visible) { e.Cancel = true; Hide(); } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Codemonkey |
last post by:
Hi,
Sorry for the cross group post, but I couldn't find a group that deals with
threading in .net.
Anyway, I've noticed a difference in the way my program acts on Windows 98
than it does on...
|
by: Matthew Fitzpatrick |
last post by:
when multiple similar forms are opened up, windows xp can group them into an
application group button on the start bar.
Unfortunately, this application group uses the icon of the application's...
|
by: Joris Dobbelsteen |
last post by:
Is it possible to make a Windows Service that has a COM interop.
I want to synchronize my database and ISA server blocklist. The application
is quite simple and should do the trick, provided I...
|
by: W Akthar |
last post by:
Hi All,
I have created a simple Windows Service which needs to be
able to send appointments to Outlook.
I have no problem makeing a reference to Microsoft
Outlook 11.0 Object Library and...
|
by: W Akthar |
last post by:
Hi
I am trying to create a windows service which queries SQL
Server on timed intervals and depending on the results
send appointments to Outlook.
The problem lies when I try to create an...
|
by: andy.g.ward |
last post by:
I keep getting this when trying to create an MFC activex control in a
c# windows service - anyone got any ideas what the missing module could
be???
Exception thrown :...
|
by: Martin Carolan |
last post by:
Hi there,
I'm having a bit of trouble figuring out how to do this, help would be appreachiated:
I have a windows form inside an exe called frmWizard, it is just a wizard
interface with some...
|
by: sambo251 |
last post by:
After running a few updates I get this very annoying "Windows Installer" error #1706 that will ne go away! It keeps saying that it cannot find the file "instantsharedevices.msi", that it is on...
|
by: Manikandan |
last post by:
Hi,
I have a question reg excel interop.
I have no excel installation(office installation) in my system
I'm using office web components in my application.
is there any help available to use...
|
by: pbd22 |
last post by:
Hi.
I know my windows service works when i run it in debug mode on my dev
machine.
It also works in release mode on my dev machine. But, when I move the
service to
a production server, it...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
| |