|
The Microsoft Tools for Office give you the ability to interact with Office.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I generally use this method to update buttons cross-thread, but ToolStripButtons don't have the InvokeRequired property.
delegate void UpdateStartDelegate(bool newState);
private void updateStartButton(bool newState)
{
if (startButton.InvokeRequired) // is cross-thread update
Invoke(new UpdateStartDelegate(updateStartButton), new object[] { newState });
else
startButton.Enabled = newState;
}
Is there an easy way to do the same thing with a ToolStripButton?
|
|
|
|
|
((Control)btn).InvokeRequired
only two letters away from being an asset
|
|
|
|
|
All ToolStripItems (suach as ToolStripButton) are only of type Component. They don't inherit from Control.
Regards.
|
|
|
|
|
You're correct, my mistake
only two letters away from being an asset
|
|
|
|
|
use a synchronous calls using a timer
|
|
|
|
|
I apologize for posting on an old thread, but I had the exact same question, and there did not seem to be an answer to this one. Someone mentioned using a timer, but my cross-thread could take several seconds, several minutes, or several hours.
I think I came up with an answer, so for future searchers I decided to post. I would test the ToolStrip that contained the button. This code seems to work to enable a toolstripbutton when a thread is done.
public void Enable()<br />
{<br />
if (toolStrip.InvokeRequired)<br />
{<br />
EnableButtonCallback d = new EnableButtonCallback(Enable);<br />
toolStrip.Invoke(d, new object[] { });<br />
}<br />
else<br />
{<br />
button.Enabled = true;<br />
}<br />
}
|
|
|
|
|
Hi,
I am designing a paint brush type program…..for drawing area where I can draw something then I used pictureBox…..like as
Pen p = new Pen(Color.Red, 5);
g = pictureBox2.CreateGraphics();
g.DrawEllipse(p, e.X, e.Y, 5, 7);
in this program I can draw anything but when I want to save this drawing by the help of this command: pictureBox2.Image.Save(saveFileDialog1.FileName);
then an error occur : “NullReferenceExpection was unhandled !”
“Object reference not set to an instance of an object.”
I need your help………can anybody solve my problem
Thanks
|
|
|
|
|
I'm guessing that Image is null. From what I remember if you want to save what's been drawn you need to do it another way, can't remember off the top of my head.
|
|
|
|
|
I am constantly amazed at what people do with picture boxes.
zeeShan anSari wrote: g = pictureBox2.CreateGraphics();
This does one thing and one thing only. It allows you to draw something temporary on top of a picture box. What it plainly does not do, is change the image inside the picture box. You should never do this, unless you're drawing a rubber band ( something you want to lose ). If your form is invalidated, what you drew will be lost.
What you need to do, is create an actual image, draw on it, and put it into the picture box. As someone else said, Image defaults to null, you did not change it, it is still null.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
solution is here:
Bitmap bmp = new Bitmap(pictureBox2.Width, pictureBox2.Height);
Graphics g = Graphics.FromImage(bmp);
Pen p = new Pen(Color.Red, 5);
g.DrawEllipse(p, e.X, e.Y, 5, 7);
pictureBox2.Image = bmp;
|
|
|
|
|
Can anybody send me the solution how to get Max value from a nodelist in C#. 4002-9568-F47910C94602}</CreatedBy>
<EffDate offset="">3/1/2007</EffDate>
<Effective offset="">3/19/2007 9:43:57 AM</Effective>
<Expiration />
<Id>{1A1678C9-8E9F-4779-B794-BB8B9B44067B}</Id>
<Modified />
<ParentId>{153EB717-9DB0-4DEC-9951-F38E0A6F8800}</ParentId>
<PolicyTermPremium offset="1405.00">0</PolicyTermPremium>
<Process offset="">3/1/2007</Process>
<ProRatedChangePremium offset="1405.00">-1104.33</ProRatedChangePremium>
<Status offset="">Cancelled</Status>
<SuppressPrint />
<TotalProRatedChangePremium offset="1405.00">300.67</
TotalProRatedChangePremium>
<Type offset="">Pro-rate</Type>
<UnitNumber>3</UnitNumber>
<VersionedId>{1A1678C9-8E9F-4779-B794-BB8B9B44067B}</VersionedId>
file:///C|/Documents%20and%20Settings/mdowdy/Desktop/Packaging/Interfaces/PolicyCancel.xml (56 of 57)4/17/2007 1:52:18 PM
file:///C|/Documents%20and%20Settings/mdowdy/Desktop/Packaging/Interfaces/PolicyCancel.xml
</Transaction>
</Policy>
Since <UnitNumber>3</UnitNumber> it is maximum my <Action offset="">Cancel</Action> and
<Status offset="">Cancelled</Status> tells me that my Transaction is Cancelled.I need this "Cancelled" word.
|
|
|
|
|
You got so wrapped up in providing more info than we might look at, that you forgot to ask your question...
|
|
|
|
|
yes,My Question is how I get the combination of Action and Status based on the max UnitNumber.
I need the cancelled or this sort of string from the Action and Status.
|
|
|
|
|
You keep asking these specific XML questions, and the answer to all of them, appears to be Xpath. Go to the w3 website, or any other site with XPath tutorials, and work through them.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Unless you only need this once, or that's the only thing you're going to need from this, I'd personally build an XML serializable model so you can deserialize your XML to objects and work with them. Then your model can provide anything from the data. You could use the abominable XSD.exe or something like Skeleton Crew[^] to build your model from your sample XML.
I'd tend to use this approach anyway (I love XML serialization), but if you only need one piece of info or you only need to look at files once then maybe XPath would be quickest.
|
|
|
|
|
Hi,
I'm trying to get the Assembly objects which are used by a particular executable, but I'm getting a FileNotFoundException when I try to load referenced assemblies.
public static void ProcessAssembly(string filename)
{
Assembly assembly = Assembly.LoadFrom(filename);
AssemblyName[] names = assembly.GetReferencedAssemblies();
foreach (AssemblyName name in names)
{
Assembly referenced = Assembly.Load(name);
ProcessReferencedAssembly(referenced);
}
}
The reason the Exception occurs is obviously because the referenced assembly is in the same folder as the assembly we're looking at, and not the executing assembly.
My question is, in general, how can I get the Assembly for these? The only (unreliable) way of doing this I can think of is to use the AssemblyName to guess the filename of the Assembly (e.g. add ".dll").
Thanks in advance!
|
|
|
|
|
Have you checked to see what name is output? Whether it is looking in the right place?
|
|
|
|
|
Yes, the message I get is:
{"Could not load file or assembly 'ReferencedAssembly, Version=1.0.2537.32659, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.":"ReferencedAssembly, Version=1.0.2537.32659, Culture=neutral, PublicKeyToken=null"} , which is less than helpful!
The Exception also had the following in the FusionLog property, which shows it's just trying to guess the filename itself:
LOG: Attempting download of new URL file:LOG: Attempting download of new URL file:LOG: Attempting download of new URL file:LOG: Attempting download of new URL file: Sorry I've changed the names of the assemblies for privacy reasons.
The actual location of the assembly would be F:\OtherApp\ReferencedAssembly.DLL
Let me know if I'm not being clear.
|
|
|
|
|
Not sure exactly what is happening because I just ran a simple mockup and it worked fine. Are you using something like satellite dlls?
|
|
|
|
|
No I'm not, can't think of anything I've done out of the ordinary.
To be clear the assemblies are as follows:
F:\MyAppPath\MyApp.exe - Executing Assembly (with sample code in original post)
F:\OtherApp\OtherApp.exe - The path to this is passed into the example method
F:\OtherApp\ReferencedAssembly.dll - Exception retrieving this Assembly.
I've tried this on a few assemblies now, and get the same thing each time. Needless to say it successfully creates the Assemblies for System , etc.
|
|
|
|
|
Does the InnerException yield any info? Permissions?
Sorry without seeing more code, I'm running out of ideas.
Hang on, are the assemblies authored by yourself / team or are they third part components?
|
|
|
|
|
Unfortunately inner exception is null.
To reproduce it you really do only need the sample code being called in its own assembly, and another 2 assemblies in a different folder, one referencing the other (making sure it actually is referenced, (i.e. create an instance of an object from the referenced assembly.. if you don't actually use it, it doesn't seem to count).
Think I might just end up trying to manually find the file, if I get the exception.
|
|
|
|
|
Odd, that's a similar setup to what I used (I'm in the middle of writing a program and just inserted the code).
|
|
|
|