|
With the following declaration you can avoid the casting:
private MyDelegate delegateObj;
Also I would recommend your alternative to invoke the delegate because it is typesafe (you could put any kind of objects into the DynamicInvoke call - the compiler won't complain).
|
|
|
|
|
Hello, all. I'm writing a little app that lives in the system tray. I'd like to display a different context menu for the NotifyIcon control based on whether the user clicks the left or right mouse button. However, I can only get the context menu to display on a right-click, which is the NotifyIcon control's normal behavior. From doing a bit of reading on the internet, I've seen that the NotifyIcon control is not really a control but a component, though I'm not sure of the differences.
Anyone have an idea on how I could make this work? The less hack, the better... but I suppose I can't be too picky since I can't get it to work now anyway. Any help would be most appreciated. Thanks.
|
|
|
|
|
Have you tried catching the click event of your notify icon and calling the Show method of your context menu inside the event handler.?
www.troschuetz.de
|
|
|
|
|
Yep. Unfortunately, that produced some odd results. The context menu ends up showing at the top-left corner of the screen (0,0) instead of around the system tray where the mouse was clicked. Setting the top and left properties didn't seem to make a difference, it still stayed in the same position at the top-left of the screen. Any other thoughts would be appreciated.
|
|
|
|
|
How did you call Show method of your ContextMenu? I tried it myself and failed, cause both overloads require an instance of Control class, but unfortunately NotifyIcon is directly derived from Component type.
www.troschuetz.de
|
|
|
|
|
I am putting shapes in to a list array
Then I use the code below to draw them on the forms background, I have this in the forms paint handler.
foreach (Shape s in shapesArray)
{
s.Draw(g);
}
What I want to do is click on the form and a message box come up and saying true or false if the mouse point was in the shape.
I have tried using the region command and isvisible but I can not get it to work how I want.
Any help would be much appreciated.
|
|
|
|
|
Try to get the location where you clicked and check if it's contained in the control.
Must be something like this:
if (s.Location.ClientRectangle.Contains(e.Location) == true)
{
...
}
|
|
|
|
|
Hi. I'm trying to solve a very strange problem. I have a windows forms application that makes calls to a web service. When the web service method is invoked, it is executed without exceptions on the web service side. When this method returns, the application exits without exceptions. It simply closes with error 0 (success).
Other methods of the webservice are called before this problematic method without problems.
Another strange behaviour: if I am debugging the application, it ends on the initialization when I call the problematic webservice method. But if I run the executable itself (without debugging), the application starts (the problematic method works) but it fails on another webservice method invoked on a button click.
The windows forms application looks like this:
public void Main()
{
try
{
webService.NormalMethod1();
webService.NormalMethod2();
webService.ProblematicMethod1(); //returns a DataSet with one table and one row
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void button_Click(object sender, EventArgs e)
{
try
{
webService.NormalMethod3();
webService.ProblematicMethod2(); //returns a string
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
As I said, if I am debugging, after the webService.ProblematicMethod1() method is called the application ends. If I run the executable itself webService.ProblematicMethod1() works and when the button is clicked, webService.ProblematicMethod2() makes the application terminate. In both cases, the catch block is never reached (the MessageBox is never shown). I've created a event handler for the Application.ThreadException event but it is never invoked.
The windows application also communicates with mobile devices through ActiveSync. The described problem only occurs when devices running Windows Mobile 5.0 are connected. It works fine with older devices. In my point of view, the PDA should not affect the windows application since what's involved in this piece of code is only the web service.
I don't know what to do and I need to solve this problem as soon as possible. Any suggestions will be greatly appreciated.
Thanks
|
|
|
|
|
It's a normal behaviour, if you put code in your Main() like any other function,
it will return after the last instruction, in your case:
webService.ProblematicMethod1();
So, if there's nothing else to execute after, the program will terminate.
|
|
|
|
|
I've tried to simplify the code and made a obvious error. The code in Main method is in reality inside the Form.Load event. After the method calls the form should be displayed, but the application terminates.
Sorry for the confusion.
|
|
|
|
|
i can't really see where your code's wrong, maybe if you post more code or a link to it, more people could be able to help you.
|
|
|
|
|
Hi
I'm having a problem with the Server.MapPath() function... sometimes (mostly when Session expires) it returns the correct server path+"/ajax".
I'm using the Michael Schwarz free AJAX library.
Have anyone ever had a similar problem?
|
|
|
|
|
You'll most likely get an answer to this question in a forum dedicated to this particular AJAX library. Most folks here probably have never heard of the library let alone used it extensively enough to answer your question.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: I luv teh choco
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I have set up a fireworks controller board involving shift register chips and relays. My output will be a serial binary number 48 bits long through the parallel port, each bit being outputted after one clock tick. The timer for C# seems to have a 1 millisecond limit as to its speed, but the hardware device I am writting to can switch in less than 50 nanoseconds. Is there some way to use a faster timer in C# or is there some access to the CPU's clock I can use? Thanks in advance
William Miller
|
|
|
|
|
zotdoc wrote: the hardware device I am writting to can switch in less than 50 nanoseconds.
I somehow doubt its nano, u sure its not micro (u)?
|
|
|
|
|
That is what the spec sheet for the shift registers I am using says they will do, but who knows.
|
|
|
|
|
|
Hey thanks Steve, that was usefull!
|
|
|
|
|
Thanks, that was usefull!
|
|
|
|
|
Hello,
After the ToolStripMenuItem has been clicked, is there a way of getting the parent form that hosting the ToolStrip.
Thank you.
|
|
|
|
|
try the 'Owner' property.
|
|
|
|
|
I have been working to extract new emails from an outlook identity (Help Desk) to display in a windows form and save to sql server. I can expose some methods and properties but cannot see a new mail item. Does anyone have any experience in this area. I have used automation before coming over to C#. Thanks for any ideas.
Chuck
|
|
|
|
|
I wanted to pass an object instance to a a method in another class and execute one of its methods.
Is it possible to do this in C# ? (this example doesn't work):
<br />
class Write<br />
{<br />
public void write()<br />
{<br />
Console.Writeline();<br />
}<br />
}<br />
<br />
class app<br />
{<br />
Write w = new write();<br />
execute e = new execute(w);<br />
}<br />
<br />
class execute<br />
{<br />
object a;<br />
public execute(object o)<br />
{<br />
a = o;<br />
}<br />
<br />
public void main()<br />
{<br />
a.write();<br />
}<br />
}<br />
<br />
|
|
|
|
|
2 options.
1) Cast before calling method:
public void main()
{
((Write)a).Write();
}
2) Take correct typed input
class execute
{
Write a;
public execute(Write o)
{
a = o;
}
}
|
|
|
|
|
Thank you for answering. But what if I don't know the correct type? For example, I want to make class execute receive another object that also has a "write" method. Using cast I would have to make another class. I wanted to make this execute class generic enough so it would receive any object and execute its write method.
-- modified at 11:42 Tuesday 11th April, 2006
|
|
|
|