473,783 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening a form in a Windows service

Hello,

Is there any way to make a form part of a windows service application
and launch it upon double-click of a system tray icon?

I already have the NotifyIcon working and have added an event to it for
the _DoubleClick.

I added a form and tried to open it with:

{Form Name}.ActiveFor m.Show();

I am not sure if that is correct or not... I grew up in the VB world and
that is similar to what I am used to using for code to open a form.

Help?

Thanks!

Andrew
Nov 15 '05 #1
11 8958
the correct code for showing the form is

MyForm f = new MyForm();
f.Show();

However, I am unsure how this will work when launching from a Windows
service, as the service is likely to be running as a different user then the
currently logged in user.

"Andrew Mueller" <am******@inste chnet.com> wrote in message
news:uk******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

Is there any way to make a form part of a windows service application
and launch it upon double-click of a system tray icon?

I already have the NotifyIcon working and have added an event to it for the _DoubleClick.

I added a form and tried to open it with:

{Form Name}.ActiveFor m.Show();

I am not sure if that is correct or not... I grew up in the VB world and
that is similar to what I am used to using for code to open a form.

Help?

Thanks!

Andrew

Nov 15 '05 #2
It looks like the code for the NotifyIcon is not executing.. Here is what I
have:

namespace EPA
{
public class EPAClass : System.ServiceP rocess.ServiceB ase
{
Log log = new Log(); //This is a log writer. It will write
to file any information I send it
private System.Windows. Forms.NotifyIco n notifyIcon1;

public EPAClass()
{
InitializeCompo nent();
}

private void InitializeCompo nent()
{
this.notifyIcon 1 = new
System.Windows. Forms.NotifyIco n(this.componen ts);
this.notifyIcon 1.Text = "EPA Service";
this.notifyIcon 1.Visible = true;
this.notifyIcon 1.Icon = new System.Drawing. Icon(GetType(),
"Svc.ico");
this.notifyIcon 1.Click += new
System.Windows. Forms.MouseEven tHandler(this.n otifyIcon1_Clic k);
}

private void notifyIcon1_Cli ck(object sender,
System.Windows. Forms.MouseEven tArgs e)
{
log.WriteToLog( "Notify Icon Clicked");
}

}
}

I am not getting the log file written.... Not sure why. There is obviously
more code here, but this should be enough to understand my problem.
Thanks!

Andrew Mueller

"Bob Boran" <mc*******@hotm ail.com> wrote in message
news:e$******** ********@tk2msf tngp13.phx.gbl. ..
the correct code for showing the form is

MyForm f = new MyForm();
f.Show();

However, I am unsure how this will work when launching from a Windows
service, as the service is likely to be running as a different user then the currently logged in user.

"Andrew Mueller" <am******@inste chnet.com> wrote in message
news:uk******** ******@TK2MSFTN GP11.phx.gbl...
Hello,

Is there any way to make a form part of a windows service application and launch it upon double-click of a system tray icon?

I already have the NotifyIcon working and have added an event to it
for
the _DoubleClick.

I added a form and tried to open it with:

{Form Name}.ActiveFor m.Show();

I am not sure if that is correct or not... I grew up in the VB world and
that is similar to what I am used to using for code to open a form.

Help?

Thanks!

Andrew


Nov 15 '05 #3
Hi Andrew,

Have a look here
http://msdn.microsoft.com/library/de...w_stations.asp
for a general discussion on services and the desktop.

Cheers

Doug Forster

"Andrew Mueller" <am******@inste chnet.com> wrote in message
news:uk******** ********@TK2MSF TNGP11.phx.gbl. ..
Hello,

Is there any way to make a form part of a windows service application
and launch it upon double-click of a system tray icon?

I already have the NotifyIcon working and have added an event to it for the _DoubleClick.

I added a form and tried to open it with:

{Form Name}.ActiveFor m.Show();

I am not sure if that is correct or not... I grew up in the VB world and
that is similar to what I am used to using for code to open a form.

Help?

Thanks!

Andrew

Nov 15 '05 #4
The problem is that the event for the NotifyIcon is not occuring for a
windows service.... I don't see how that url explains that, unless I am
missing something.

Thanks.

Andrew

PS - If I can get the NotifyIcon to react to a click event or a double-click
event, then everything should be fine. I tested it again by putting code in
these events which would write to the NT Application Event Log, but nothing
happened.
"Doug Forster" <doug_ZAPTHIS_A T_TONIQ_ZAPTHIS _co.nz> wrote in message
news:uX******** ********@tk2msf tngp13.phx.gbl. ..
Hi Andrew,

Have a look here
http://msdn.microsoft.com/library/de...w_stations.asp for a general discussion on services and the desktop.

Cheers

Doug Forster

"Andrew Mueller" <am******@inste chnet.com> wrote in message
news:uk******** ********@TK2MSF TNGP11.phx.gbl. ..
Hello,

Is there any way to make a form part of a windows service application and launch it upon double-click of a system tray icon?

I already have the NotifyIcon working and have added an event to it

for
the _DoubleClick.

I added a form and tried to open it with:

{Form Name}.ActiveFor m.Show();

I am not sure if that is correct or not... I grew up in the VB world and
that is similar to what I am used to using for code to open a form.

Help?

Thanks!

Andrew


Nov 15 '05 #5
Anyone find the fix to this? I to am attempting to have a Windows
Service that can interact with the desktop... the "Interact With
Desktop" option in the service control manager has no effect on the code
executing.

S. Steefel, MCSE
Snr. Software Engineer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #6
Anyone find the fix to this? I to am attempting to have a Windows
Service that can interact with the desktop... the "Interact With
Desktop" option in the service control manager has no effect on the code
executing.

S. Steefel, MCSE
Snr. Software Engineer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7
Anyone find the fix to this? I to am attempting to have a Windows
Service that can interact with the desktop... the "Interact With
Desktop" option in the service control manager has no effect on the code
executing.

S. Steefel, MCSE
Snr. Software Engineer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #8
Anyone find the fix to this? I to am attempting to have a Windows
Service that can interact with the desktop... the "Interact With
Desktop" option in the service control manager has no effect on the code
executing.

S. Steefel, MCSE
Snr. Software Engineer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #9
Anyone find the fix to this? I to am attempting to have a Windows
Service that can interact with the desktop... the "Interact With
Desktop" option in the service control manager has no effect on the code
executing.

S. Steefel, MCSE
Snr. Software Engineer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #10

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

Similar topics

2
2080
by: Eric Caron | last post by:
Hi Here's my problem, I create a windows service with Config.xml file. All setup for my service is in this file. I create a windows application to manage these settings (Config.XML File). This work good if the two applications are in the same folder and Config.XML is in the folder too but If not, my windows application setting don't work. In my windows form I have a Service controler components to manage my service (start, stop, ...)....
14
11096
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
3
2568
by: tomyboy | last post by:
Read this from Dev Ashish http://www.mvps.org/accessfr/forms/frm0034.htm for opening a form in an other db This seems useful for my job I've a db named INVOICING making invoice and a 2nd db name Mini_D_ASDEV checking debit/payment, without relation between them Then, 1st : is this /frm0034.htm working with Access 2002 under XP as well? 2nd : my form OPENED is INVOICE from db INVOICING
1
3283
by: Ian | last post by:
I want to open a form at a particular record, but I think I'm running into problems because the recordsource query is executing asynchronously. In the form's open event I use recordsetclone.findfirst to get a bookmark and then set the form's bookmark to this value. normally that works fine, but the form I am using has a very large number of records and isn't being set to the correct record, even though it is found successfully in the...
2
1920
by: John | last post by:
Hi My app is in vb.net but the backend db is access. I am posting my question here as there is more access expertise here than in vb.net group. Here is the problem; I am opening a connection on a shared access db as below. Conn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=\\Server\f\Events Data\Events Data.mdb;User
6
2050
by: Dean R. Henderson | last post by:
I have a DTS Package I am able to execute successfully from a Windows Form application, but I cannot get this to work from an ASP.NET Web Service, although the Web Service impersonates the same user the Windows Form runs under. When I run the Web Service, I make a call to "System.Security.Principal.WindowsIdentity.GetCurrent().Name" and this verifies the user-id is the same account I am logged onto when I successfully run my Windows...
3
14356
by: Vitaly Zayko | last post by:
Is it possible to attach a form (C# .NET 2) to windows service and show it in OnStart event? When I tried to do this in general (new, Show()) way it just didn't do anything nor gave me any errors. I want to use this form for interaction with the service. Thanks! Vit Zayko
0
2320
by: andyedw | last post by:
I have created a windows service in .net and a form to control and monitor the service which I would like to open onStart event of the service. I have tried allowing the service access to the desktop and calling the form but have had issues with this. I think the best way to do this would be to run the form .exe. Does anyone know the code (C#) to do this? I am finding it harder than expected to find an example on the Web. Or does anyone...
0
1660
by: pintu | last post by:
Hello friends, i am creating an application using .net 2.0 and c#..My requirement is to open a form which will take inputs from user to update one table through web service..But my problem is that this should be done using windows service..I have tried to find out the solution but failed to open the form from windows service..(though i have alternative to open a console application at startup and call webservice to do the task.But i want...
0
9643
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
9480
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
10147
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...
1
10083
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
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
8968
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.