|
|
I want to create an Windows Service which displays notifynicon on the taskbar with contextmenu. If user choose "show management panel" from the context menu a simple Windows Form appears and user can modify service behaviour form it.
So what is the problem?
1.
I created simple WIndows Service (local system whith access to the desktop) and added NotifyIcon and contextmenu components to it. When I rum my service notify icon appears on the taskbar and everything seems to work properly... but when I right-click on the icon context menu does not appear. What's more - I added double-click event for the NotifyIcon and It also does not work properly - Message box does no appear.
The same components in simple Windows Form Application work well. So I thought that I must add windows form to the service to make it work.
2.
Maybe, but Application.Run(new MainForm()); needs to be invoked in different thread because service waits for the WIndow to be closed - there must be much more simple way to do it.
I'm new to Windows Services, coud you help me with my problem?
|
|
|
|
|
1. Services can run without an interactive (logged-in) user, so services which allow interaction need to be configured as such. So, open the Services control applet, and goto the properties of your service and ensure that "Allow service to interact with the desktop" is selected.
2. You should read up on remoting and communicate with your service in this way.
|
|
|
|
|
Interaction with desktop is allowed.
|
|
|
|
|
I know that windows service shoudn't have user interface.
Do you think that using .NET Remoting to comunicate with service is better than include management form inside service?
But the question was why my context menu isn't working. And why events such as double-click aren't catched.
And what about creating window in another thread inside service?
-- modified at 12:58 Friday 3rd March, 2006
|
|
|
|
|
Maybe the reason why it isn't working is that Windows Service does not have classic Message Loop as Windows Applications have.
I currently solved my problem in, let's say - no professional way.
I created Window in a different thread:
public partial class Server : ServiceBase
{
MainForm window;
Thread thread;
public Server()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
thread = new Thread(new ThreadStart(WindowFunction));
thread.Start();
}
protected override void OnStop()
{
}
private void WindowFunction()
{
Application.Run(window = new MainForm());
}
}
but is it really the best solution?
|
|
|
|
|
Like others have said before, the usual way to do something like this is to have the service running without desktop access and to have a controller-type application that's communicating with the service, for example by using remoting.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
hi
i need an example how to work with datagrid in C#
lets say i have table in SQL server that called Stock_ID
and one of the collumn is Symbol
how can i get the value of the Symbol from the datagrid
lets say i awnt to display all Symbols
thanks
eyalso
|
|
|
|
|
|
protected void get_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=lzq;database=pubs;uid=sa;pwd=");
SqlDataAdapter da = new SqlDataAdapter("select * from lzq", conn);
DataSet ds = new DataSet();
da.Fill(ds, "t1");
datagrid1.DataSource = ds.Tables["t1"].DefaultView;
datagrid1.DataBind();
}
|
|
|
|
|
I have made an application where the user may set the Desktop Wallpaper.
Using the method:
WinAPI.SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, fileName, SPIF_SENDCHANGE);
everything works fine, until I restart the computer.
How do I make the new wallpaper survice a computer restart ??
|
|
|
|
|
try this:
private const int SPIF_SENDWININICHANGE = 0x2;<br />
private const int SPIF_UPDATEINIFILE = 0x1;<br />
<br />
WinAPI.SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, fileName, SENDWININICHANGE ||SPIF_UPDATEINIFILE);
I am pretty sure this is what I am using for my Desktop Radnomizer program that I wrote.
Regards,
1tg46
Check out 3D Game Development with Dark Basic Professional [^]programming.
|
|
|
|
|
How do set column of crystal report dynamic by user?? isn't possible to do that??
angela
|
|
|
|
|
I am facing a problem in Date format in our project. This problem exists only for the month of March.
Our client machine,server machin and DB server machine are in German OS.
In German language, the name of the month for March is 'MÄRZ' (which contains a spl character 'Ä'). The middle tyre of our project will support only the date format 'dd-MMM-yyyy' , example 25-Jan-05. While converting the date of month March in .NET, it is not understanding the spl character and convert the month as 'Mrz', for example
'25-Mrz-05'. But Oracle and SQL Server can understand only MÄR and not Mrz. So, in the month of march we are getting so many exceptions in our project.
We got a temprary soluntion in SQLServer. But we yet to find a solution in Oracle. Kindly help me to resolve this.
With Love
Siva.
|
|
|
|
|
Hi!
The problem is not that the 'ä' is "not understood" by .NET while converting the month, it's just that the short 3-letter form .NET uses for march in German is "Mrz".
Although I must admit that I've never tried to feed localized dates to SQLServer (or Oracle), it's hard to believe that the DB systems are choking on this because "Mrz" is a very common abbreviation for März here in Germany, even though it's the only one not taking the first 3 letters of the month's name.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
Where does the date come from, and how do you convert it?
Why do you handle the date as a string, and not as a DateTime?
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
The date come from my date picker control.I am not handling as a string.
The middle tyre of my project should support only the format dd-MMM-yyyy.
So, i am converting whatever the date i selected in date picker control to the above said format.
With Love
Siva.
|
|
|
|
|
If you don't handle the date as a string, it doesn't have a format. A date value only gets a format when you convert it into a string. If you don't convert it to a string, there is no way of specifying a format.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
can any please help me with the following,
How to Convert a System.Drawing.Bitmap object to stdole.IPictureDisp() object.? or How to put a picture on a Button Created in outlook.?
Thanks in Advance
kss
|
|
|
|
|
Hi frnds,
I have dynamically created dropdownlist control on my web page and tried to create an event like..
DropDownList DDL = new DropDownList();
DDL.ID="DDL"+i.ToString();
DDL.AutoPostBack=true;
DDL.SelectedIndexChanged += new System.EventHandler(this.DDL_selectFontFamily);
void DDL_selectFontFamily(object sender, System.EventArgs e)
{
DropDownList DDL = (DropDownList)PlaceHolder1.FindControl("DDL0");
string FFamily = DDL.SelectedItem.Value;
Response.Write(FFamily);
}
but it is not working. Infact the control is not going into DDL_selectFontFamily()...saying that DDL is out of scope.
Plz help me out guys.
Abhishek
|
|
|
|
|
|
hi
my application needs the merging of two images.
Actually when iselct a picturebox the image in the picturebox should merge with the photo captured and shown in another picturebox from the web cam . can anyone help
thanks
|
|
|
|
|
|
Dear all,
Im using a class named Events where i have some property like
CLass Events
{
private string _EvDate;
public string EvDate
{
get{ return _EvDate }set { _EvDate = value;}
}
}
I have one more class as below
Class EventProp
{
private string _TZid;
then get set
}
Requirement is EvDate has attributes such as TZID, So i want to set the attribute value from the Events, that is
EvDate.Tzid = some vlaue from some function();
Please help me out to solve this problem.Thank you in advance for the solution for my problem.
Regards
Mukil
|
|
|
|
|
I am sorry, but EvDate itself is an attribute of the Events class
how can u create an attribute for it?
u can set a value to EvDate by creating an object of the events class
Events ev = new Events();
ev.EvDate = Some value from some function();
regards,
Pramod
|
|
|
|