|
Hi,
if the pc change from a sleep state to an active state,
what system event will the system provide to notify my application
that it is awakened ? Coz my program need to do some stuff
when the pc change from sleep to nonsleep mode.
Thanks
|
|
|
|
|
|
Hi there...
I dont have a "mainform" so i created a notifyicon, contextmenu and the correspondig eventhandler in a normal class which is ran by the Main-function (including a ManualResetEvent - but this isnt important for my problem):
<br />
private NotifyIcon m_notifyIcon = null;<br />
<br />
public ChatNotifier()<br />
{<br />
Initialize();<br />
}<br />
<br />
private void Initialize()<br />
{<br />
<br />
ContextMenu contextMenu = new ContextMenu();<br />
<br />
MenuItem mi1 = new MenuItem();<br />
mi1.Text = "&Optionen...";<br />
mi1.Click += new EventHandler( mnuOptions_OnClick );<br />
mi1.Index = 0;<br />
<br />
contextMenu.MenuItems.Add( mi1 );<br />
<br />
<br />
m_notifyIcon = new NotifyIcon();<br />
<br />
m_notifyIcon.Icon = new Icon( @"c:\test.ico" );<br />
m_notifyIcon.Visible = true;<br />
m_notifyIcon.ContextMenu = contextMenu;<br />
}<br />
<br />
private void mnuOptions_OnClick( object sender, EventArgs eventArgs )<br />
{<br />
new OptionWindow().ShowDialog();<br />
}<br />
What happens:
- The NotifyIcon appears...
- Click on the NotifyIcon and the ContextMenu appears...
- Selecting the MenuItem doesnt do anything...
- Clicking on the NotifyIcon again (NOT the MenuItem) the mnuOptions_OnClick code will be fired and the Form appears...
Whats the beahvoir of this? Why isnt the code fired "immeaditly" when clicking the menuitem?
-----
Thanks for reading
|
|
|
|
|
Hi!
Not having a MainForm could be exactly the reason. I suppose the windows messages are not routed to/from the NotifyIcon to your application correctly without one.
Is there a regular message pump running in your application anywhere?
Regards,
mav
|
|
|
|
|
There isnt any message pump...maybe in the configuration form - but i dont want to keep it in the back
--------------------
Thanks for reading
|
|
|
|
|
Hi all,
I have a problem:
i have a windows user control for example with 1 button and I show it in IE using an html page with
<object classid="http:MyUserControl.dll#MyUserControl.MyUserControl" VIEWASTEXT></object>
and it works fine.
But if MyUserControl contains another Windows user control it stops to work and it does'nt appear
in IE
Any suggestion?
Thanks
|
|
|
|
|
I’m writing ADO program connected to MS access with DataReader. Need to bind a checkedListBox to a table. This is what I wrote:
public void BindCheckedListBox(CheckedListBox BooksCheckedListBox)
{
ArrayList books = new ArrayList();
string sqlBindList = "SELECT BookName " +
"FROM books "+
"ORDER BY BookName ";
OleDbCommand cmdShowStock = new OleDbCommand();
cmdShowStock.Connection = cnShop;
cmdShowStock.CommandType = CommandType.Text;
cmdShowStock.CommandText = sqlBindList;
cnShop.Open();
OleDbDataReader reader = cmdShowStock.ExecuteReader();
BooksCheckedListBox.DataSource = reader;
}
When run it with debbuger I get an exception:
“Complex DataBinding accepts as a data source either an IList or an IListSource”.
Trying to figure out how to work with those interfaces I got nowhere
Please help me clear up this issue!
TIA,
sea#
|
|
|
|
|
Hi,
You can only assign those objects as a datasource which implements ILIst or IListSource interface e.g. DataSet, Array. So you can not assign DataReader as a datasource to a listbox or combobox.
Jayant
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
Hello all,
I’m trying to develop a simple/personal firewall using C#. I used Jesus O’s class for setting the rules and it is working smoothly. However, I’m trying to search for a way to make the application ask the user if a certain program is trying to access the internet, showing the port, address, direction…etc (just like the popup dialog in ZoneAlarm). I’m not even sure if this is the right place to ask, but any hint on how to do it, implement it, the algorithm for it or the API would be highly appreciated.
Many thanks in advance,
tmp0
|
|
|
|
|
I want to make a programm for checking commentinformation (like summary, param, remarks ans so on) with the real code.
My Problem is who can i read out this information?
In Visual-Studio i can see this in object-explorer an by autointilsence. But who can i get it.
Can anybody help me?
|
|
|
|
|
|
Okay, but who can i do this.
I Want read out the information about class,properties, methods an so on with reflection.
But i see no way to bring together the both information parts.
|
|
|
|
|
Good morning,
I would like to use Microsoft projct 2000 with C#. I have already added the necessary references but I don't know what to include as namespaces to open a *.mpp file or access to saved data.
Some code lignes would be helpfull for me.
Thanks for help.
|
|
|
|
|
My problem is, i have migrated from VB.net to C# recently. In vb.net, in the code window's left combo box we get the list of controls and in the right combobox we get the list of events associated with the selected control in the left combobox. And when we select an event from the combobox list vb.net writes the declaration for that event. But in C# i am finding difficulty in writing events by my own. I know how can we add events in C#, like, we have to go to windows designer code and write a new eventhandler like : this.button1.KeyDown += new System.EventHandler(this.button1_KeyDown);
and then i have to go to my forms code window (i m using .net 2005) and write a method there with name "button1_Keydown". But my problem is i dont know what arguments i have to pass in this method. In vb.net the designer itself write the method with arguments for me so i dont have to worry about what are the event's arguments.
Please help me how can i get the list of events with its arguments associated with a controls.
Thansks in advance .
sheel
|
|
|
|
|
In the designer select the control you want an event for. In the property grid switch to "events" and double click the event you want to implement.
|
|
|
|
|
Many thanks to you my friend. You solved my big problem.
Happy Coding
Sheel
sheel
|
|
|
|
|
Though personally i think this approach is perfect (and i admit using it often)... but I'd hate to rely on the UI designer for the control events and such. Most of the times, for the sake of clealiness, I myself associate the events manually. And the C# IDE has a great intellisense for events. As soon as you type "MyControl.Event+=" .. simply press "Tab" twice and it'll do the job.
- Malhar
|
|
|
|
|
I am just starting out in C# and find my self stuck on a problem that looks to me to be a permission problem within my application. Any suggesions on where I should create the instance so both forms can access it?
I am tring to have a single instance of a class be accessable within multible forms.
Dumb version of what Im doing
NameSpace – App
{
Class Testing class
{ create an array of int's}
Form1
{
- Create instance of Testing class
}
Form2
{
- Access class created in Form1 !! ERRROR, I not see the instance..
}
}
|
|
|
|
|
Hi,
Implement your class as a Singleton?
So....
==================
using System;
namespace MyApp
{
public class MyClass
{
private static MyClass myClass;
//Make the constructor private instead of public.
private MyClass(){}
//Call this method to return the same instance to all.
public static MyClass GetInstance()
{
if (myClass == null)
{
myClass = new MyClass();
}
return myClass;
}
}
}
==================
|
|
|
|
|
Hi,
How can I write a timer function in C#, so that the timer
can register the datetime (but not the interval) of the event ?
And if my timer program sleep as the PC sleep while the user away,
how can I alert the timer to re-check the scheduled event to see if
there are any events that is over-due ? (i.e. is there are any
event handling for watching the PC system awaking from sleep ?)
Thanks
|
|
|
|
|
ChristmasTree wrote:
How can I write a timer function in C#, so that the timer
can register the datetime (but not the interval) of the event ?
You can't. The best you can do is to write a frequent timer that checks the date/time to see if it has passed.
ChristmasTree wrote:
And if my timer program sleep as the PC sleep while the user away,
how can I alert the timer to re-check the scheduled event to see if
there are any events that is over-due ? (i.e. is there are any
event handling for watching the PC system awaking from sleep ?)
Same as above - check the time regularly, and if it has passed, then act. It won't matter then if it's passed by 1/2 second, or by 20 years.
<edit>
Of course, Windows HAS a scheduler, I don't know much about it, but I presume you can schedule your own task there, but I take it to mean you want to do something entirely in code within your existing program.
</edit>
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Why c# programs don't run on PCs where there's no a setuped visual studio ????
i tried to run a c# executable file on a pc where there was no setuped visual studio, and i was surprised when the error message appeared.
Don't Smile To The World...It Does Not Smile To You
|
|
|
|
|
comingsoon wrote:
Why c# programs don't run on PCs where there's no a setuped visual studio ????
i tried to run a c# executable file on a pc where there was no setuped visual studio, and i was surprised when the error message appeared.
I'm astounded how many people use the .NET framework and have absolutely no idea how it works.
C# and VB.NET programs compile to an intermediate language called MSIL. The .NET framework installer runs as part of the VS install, obviously. Anyone who wants to run your C# executable needs to also have the .NET framework installed. If you don't want that requirement, use C++.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is there any other solution 4 that prob ?
where can i find the .NET framework ???
Thanks for reply, Christian
Good is Good
|
|
|
|
|
comingsoon wrote:
Is there any other solution 4 that prob ?
No, your options are C++ and the .NET framework. If there was any other option, why would anyone download the framework to start with ?
comingsoon wrote:
where can i find the .NET framework ???
Choose[^] any of the hits I got from google, I'm sure at least the first four will give you a download link.
Christian Graus - Microsoft MVP - C++
|
|
|
|