473,623 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows interop...

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 ...

Nov 16 '05 #1
8 2266
use the following code in order to start the application.

[System.Diagnost ics.DebuggerSte pThrough()]

[STAThread]

static void Main()

{
Application.Run (new Form1());

Application.Exi t();

Environment.Exi t(0);

}

"Jacek Jurkowski" <jj********@dat acomp.szczecin. pl> wrote in message
news:ux******** *****@tk2msftng p13.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 ...

Nov 16 '05 #2
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********@dat acomp.szczecin. pl> wrote in message
news:ux******** *****@tk2msftng p13.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 ...

Nov 16 '05 #3
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"?
Nov 16 '05 #4
Hi,
"Jacek Jurkowski" <jj********@dat acomp.szczecin. pl> wrote in message
news:ux******** *****@tk2msftng p13.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
Nov 16 '05 #5
>> 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,

Nov 16 '05 #6
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
Nov 16 '05 #7
Jacek,

In your Closing event, are you doing something like this to iconise the form
when it is closed?
private void MainForm_Closin g(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,


Nov 16 '05 #8
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();
}


Nov 16 '05 #9

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

Similar topics

1
1616
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 WindowsXP and was wondering if anybody can explain this behaviour. My application runs in the background to collect data through the serial
5
2214
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 executable, and not the icon that has been specified by form. another usenet post here (watch for URL wrap) ...
2
4203
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 could start the *** thing as a Windows Service (to make the process automatic at regular intervals). What do I need to configure to get it installed as a service (on a non-development box Win2k3)?
0
2023
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 compiling the code. the problem arises when I try to install the service using installutil. The error message I get is the following
3
2340
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 outlook application object.
5
8765
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 : System.IO.FileNotFoundException: The specified module could not be found. at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid) at System.Windows.Forms.AxHost.CreateWithoutLicense() at...
1
2103
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 navigation controls and a header. The form loads wizard steps via. the type Wizard.Interop.Step (wizard.Interop is a seperate assembly) and Wizard.Interop.Step inherits System.Windows.Forms.UserContorl. I have no problem loading the control which...
2
11712
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 another CD, and gets caught in a loop when I try to delete it! It mentions MS.net frame error # 1706. The "details" code follows...hope someone can help me to either fix it or get out of the loop! I tried running "Windows Registry Repair Pro"...but no help...
1
3694
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 office web components in c# windows application? I would like to know how to regenerate interop assembly for excel I tried using tlbimp, getting error as below TlbImp : error TI0000 : The input file 'C:\DEV\test\ExcelInterop\O
41
11629
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 exits immediately with a start/stop/nothing to do error. What could be wrong?
0
8224
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8163
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8610
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8469
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7145
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1471
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.