|
The other application has to be designed for such interaction. You can force interaction, but there is no consitent way to do that because you have to trick the application into interacting with your application.
There are ways of getting properties of windows (e.g. controls), for example, the Text property of the TextBox control that Notepad (I assume) is using. However, it has been a few years since I did any C++ and I don't enough to be able to work out how it might be done any more.
The Command window might be easier to deal with as the application is just interacting with StdIn, StdOut and StdErr and these can be redirected. See the System.Diagnostics.Process[^] class
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
I was thinking of something in Diagnostics.Process thanks
|
|
|
|
|
Hello,
I am stuck with an error: An object reference is required for the nonstatic field, method, or property
the code that is causing the problem:
-class Form1
private static DiscoveryProcess DPform;
public static bool DiscoveryProcessInstance = false;
public static void DiscoveryProcess()
{
if (DiscoveryProcessInstance == false)
{
DPform = new DiscoveryProcess();
DPform.Show();
DiscoveryProcessInstance = true;
-ERROR- toolStripStatusLabel1.Visible = true; // System.Windows.Forms.ToolStripStatusLabel
}
else
DPform.WindowState = FormWindowState.Normal;
}
situation:
Form1 is the mainform, from there I start a new Windows form, Form2. When the operation are done on that Form2, I call the following code to start another Windows form DPform
-class Form2
Form1.DiscoveryProcess(); //starts DPform
this.Close(); // closes Form2
Now what I want to accomplish with that is that i can close the form Form2 (I don't need it anymore) without closing DPform and that only one single window form can be created. But what i want to do is set a toolStripStatusLabel on Form1 to visible.
Can someone point me into a direction of how to manipulate the toolStripStatusLabel on another form? Or is my approach of calling new window forms from Form1 not correct?
Thanks in advance.
-- modified at 8:06 Sunday 18th December, 2005
|
|
|
|
|
Did you try running the code under a debugger? Assuming you're using VS .NET, hit F5 and then try the operation that caused the exception. The debugger should point you to the exact line that resulted in the problem.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Sorry, something missed out:
the error occures on this line:
toolStripStatusLabel1.Visible = true; // System.Windows.Forms.ToolStripStatusLabel
|
|
|
|
|
It simply means that toolStripStatusLabel1 is not static, while the function DiscoveryProcess is. You need to declare the Label also as a static member.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
How can I do that? Can you help me out with this?
Thanks
|
|
|
|
|
I guess you're new to C# programming? The static[^] keyword is used to indicate that a member variable belongs to the type itself, rather than to every instance of the type.
In your case, you'd need to change
Label toolStripStatusLabel1;
to
static Label toolStripStatusLabel1;
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
That is correct, but the problem that I have is this.
I make a new clean static ToolStripStatusLabel.
public static System.Windows.Forms.ToolStripStatusLabel testLabel;
This new ToolStripStatusLabel must be added to the
System.Windows.Forms.StatusStrip statusStrip1;
So I do
try
{
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { testLabel });
}
catch (Exception) // needed to catch the System.ArgumentNullException
{ }
Than when I change the section that gave the error to:
public static void DiscoveryProcess()
{
if (DiscoveryProcessInstance == false)
{
DPform = new DiscoveryProcess();
DPform.Show();
DiscoveryProcessInstance = true;
//statusDiscoveryProcess.Visible = true;
testLabel.Image = global::RDXstudio.Properties.Resources.Processor;
testLabel.Name = "statusDiscoveryProcess";
testLabel.Size = new System.Drawing.Size(161, 16);
testLabel.Text = "Discovery Process running...";
testLabel.Visible = true;
}
else
DPform.WindowState = FormWindowState.Normal;
}
It still causes the application to crash with a System.NullReferenceException
I think I am not able to do that.
Is there another way of calling my forms without the static?
Form1 calls Form2, Form2 calls DPform and Form2 close itself, DPform continue...
Thanks in advance.
|
|
|
|
|
You really need to pick up the basics of C# first. The statement
public static System.Windows.Forms.ToolStripStatusLabel testLabel;
does not create a ToolStripStatusLabel object. You have to do
public static System.Windows.Forms.ToolStripStatusLabel testLabel = new System.Windows.Forms.ToolStripStatusLabel();
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Great man!
I think that I am terrible confused out here. That did the trick.
|
|
|
|
|
He can't run the code, as it's a compiler error message.
---
b { font-weight: normal; }
|
|
|
|
|
You're right, , I read "object reference" and immediately decided the OP got a NullReferenceException.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
You can't access the controls of the form wihtout a reference to the form object.
---
b { font-weight: normal; }
|
|
|
|
|
Hi.
I want to make a setup for my application that automatically and in background installs .Net Framework 2 with my application.
Can you help me, please?
Best wishes
|
|
|
|
|
How i can convert user define structure into byte array,or tell me how can i send struct through socket?
|
|
|
|
|
Use Binary Serilazation.
The only trick here is that the "other side" needs to know the class\struct structure (both must use the same dll describing the class\struct).
there is a good example on the MSDN help.
Gilad.
|
|
|
|
|
Make your structures as Serializable.
[Serializable]
struct Person
{
public string name;
public int age;
};
Use binary serialization/deserialization to convert your structures to byte array and vise versa
DevIntelligence.com - My blog for .Net Developers
|
|
|
|
|
Hi,
Can someone simply explain the usage and benefit of delegate with a simple example please?
Thanks
|
|
|
|
|
|
My program is about image processing for vets. We added the ability to send email using the built in .NET stuff, and the biggest client complaint is that they don't know if it sent or not, as it's not in their outbox. What I want to do is send the mail, by whatever means I don't care, and then if Outlook is present on the machine, stuff the message into the outbox, if it's not present, look for Outlook Express and do the same. What I don't want is to be tied to any version of Outlook, I want it to work for any version, and not require any version to be installed. I've looked through MSDN, but found nothing of value. I appreciate any suggestions.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I guess it would be tough to do it from managed code, as you'd need the interop DLLs for interacting with the outlook COM objects and I don't know of interop DLLs for one version of Outlook will work with another.
How about writing a MC++ library that directly uses COM to do the job? That way, you can easily check for the CLSIDs and create the right COM objects.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
remember that different versions of ms office (i.e Office XP Pro, Office XP Small Business edition) will have different CLSIDs. In the outlook object model there is a method that will tell you which version of outlook is installed. If you want i can give you an implementation of how I had setup to send emails via outlook through my application. I dont know if the same is possible via Outlook Express.
|
|
|
|
|
Christian Graus wrote: as it's not in their outbox.
I assume you mean, sent items rather than outbox?
Outlook programming is fraught with difficulties due to all the protection added due to the spate of worms that misused its wonderful application model. Things get worse when dealing with Outlook Express as it doesn't have an object model or support MapiEx.
Back in the day, I used to use MapiEx to interact with Outlook. This was in non-managed C++. You may be better off looking to see if MAPI will give you what you need.
A good starting point for Outlook related programming is http://www.outlookcode.com/[^]
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Well, I had to solve a part of this problem about two years ago and it wasn't easy! As the poster below says it requires Extended MAPI if you want to bypass Outlook's Security model (if this doesn't matter then simple MAPI is OK). I also had the added complication of having to initiate the sending from 16-bit client applications.
What I found was that there was no simple example anywhere that provided the solution. I had to combine bits from a sample application from the book, Inside MAPI, plus MSDN code snippets, plus newsgroup snippets, plus trial and error. Then I had to solve the:
"works on my machine but not on yours"
"works in debug but not release"
issues.
Kevin
|
|
|
|