|
Hi
I'm trying to run g++ using process.start, but it fails to wait for it to exit. what need I do?
cheers
|
|
|
|
|
thepersonof wrote:
I'm trying to run g++ using process.start, but it fails to wait for it to exit. what need I do?
Have you tried Process.WaitForExit[^]?
|
|
|
|
|
thanks
atm i'm using:
ProcessStartInfo oStartInfo = new ProcessStartInfo();
oStartInfo.FileName = dir+"g++.exe";
oStartInfo.CreateNoWindow = true;
oStartInfo.UseShellExecute = false;
oStartInfo.Arguments = ".......";
Process p1 = Process.Start(oStartInfo);
p1.WaitForExit();
cheers
|
|
|
|
|
Since you're hiding the window and not using ShellExecute, you have no way of knowing if the app actually launched properly. Some applications don't tolerate NoWindow and/or must be executed using the Shell.
Also, some applications will start with their own "wrapper", where you launch one .EXE and it in turn, launches a second one to do the actual work while the one you launched quits.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks, the same thing happens, though, even when they are not used.
cheers
|
|
|
|
|
Ok I'm new to Windows development. I have a project that has 2 forms. A button on form1 opens an instance of form2. Form2 has a textbox that receives some data. I try to make that data available to form1. I have tried several things but keep running into problems. What is the proper way of making data inputted on different forms available to all forms?
|
|
|
|
|
Hi,
The best way is probably to have form 2 raise an event, whose argument will contain that piece of data you are trying to transfer. Then you will have form 1 subscribe to that event.
Hope that helps,
Yigal
|
|
|
|
|
This event stuff may be overkill unless you want the first form to display live updates of what is going on on the second form. Also, it would be a bit of a mess to onroll all the changes if the user ended up clicking "cancel" after a lot of changes.
More likely, you just want the same kind of behavior you get with the OpenFileDialog, SaveFileDialog, FontDialog, etc. In that case, you just add some public properties to your second form that can be initialized and retrieved from the first. You'll probably care about whether the user clicked "ok" or "cancel" on the second form, so you'll probably want to use the DialogResult stuff. (unless your second form has some other idiom, like those dialogs that only have a "close" button).
Hopefully this is enough info to get you started. This question is asked so often, I was thinking of writing a little article to describe a couple ways to do it simply, as well as the more advanced event method mentioned above. Or probably there is already an introductory forms article that covers it...
Matt Gerrans
|
|
|
|
|
Yes, this is what I want to do. I have been looking at events and they seem to be more for errors or events rather than passing data. I could not find an article just questions so if you have time a simple example would be great.
|
|
|
|
|
Here's a minimal example, without validation, etc.
Snippet from the main form (extraneous stuff omitted):
class MainForm : Form
{
private string chosenPizza = "Pepperoni";
private bool cheesy = true;
private void buttonChooseNewPizza_Click(object sender, EventArgs e)
{
PizzaOrderForm orderForm = new PizzaOrderForm();
orderForm.PizzaType = chosenPizza;
orderForm.Cheesy = cheesy;
DialogResult answer = orderForm.ShowDialog(this);
if (answer == DialogResult.OK)
{
chosenPizza = orderForm.PizzaType;
cheesy = orderForm.Cheesy;
labelOrderStatus.Text = "Your " + chosenPizza + " pizza with" +
(cheesy ? "" : "out") +
" cheese is coming right up!";
}
}
}
And from the sub-dialog form:
partial class PizzaOrderForm : Form
{
public PizzaOrderForm()
{
InitializeComponent();
}
private string pizzaType;
public string PizzaType
{
get
{
return pizzaType;
}
set
{
switch (value.ToLower())
{
case "pepperoni":
case "hawaiian":
case "vegetarian":
pizzaType = value;
break;
default:
throw new ArgumentOutOfRangeException(string.Format("Sorry, {0} pizza is not on the menu.", value ));
}
}
}
private bool cheesy = true;
public bool Cheesy
{
get
{
return cheesy;
}
set
{
cheesy = value;
}
}
private void PizzaOrderForm_Load(object sender, EventArgs e)
{
textBoxPizza.Text = PizzaType;
checkBoxCheese.Checked = Cheesy;
}
private void buttonOK_Click(object sender, EventArgs e)
{
PizzaType = textBoxPizza.Text;
Cheesy = checkBoxCheese.Checked;
}
}
Also, the OK and Cancel button's DialogResult properties should be set accordingly.
(If you're using .NET 1.0 or before, don't be confounded by the partial class, it just lets the form designer do all its code generation in a separate file).
Matt Gerrans
|
|
|
|
|
Do one thing Take a Global Module and Decalre a variable which is of type public. and Assign the Textbox value to that .U can access that Variables value from any form.
Deepak
|
|
|
|
|
Please don't do this, for your own sake. It may seem simple and clean at first, but you will surely regret it as your app grows.
Even the solution I gave above is not ideal; the data should probably be encapsulated in some objects, which could be passed from one form to the other (not by events, but in the same way I did with individual variables).
Matt Gerrans
|
|
|
|
|
Hi guys,
I have created a Visual Studio setup project, and when I build it I get a .msi installer file. Does anyone know how to create a single .exe installer file, or how to convert a .msi file to an .exe file that can be downloaded? Thanks.
|
|
|
|
|
Why don't you want an .MSI?
|
|
|
|
|
Hi,
I have nothing against .msi files... I'm just wondering why every file I download off the web is .exe and never .msi, and if there is any advantage to using .exe. What do people use to create an .exe file?
Yigal
|
|
|
|
|
Hi,
When I create a context menu with C#, only the left button can select entries in the menu (AFTER the menu has been invoked by a right click). Does anyone know how to enable selection using the right button, like the way it is in most Windows applications?
Thanks.
|
|
|
|
|
I have found out why this happens: The way the context menu works depends on which control it's attached to. For example, when the context menu is attached to a text box, the various context menu click events are only invoked when the left mouse button is clicked; when the context menu is attached to a RichTextBox clicking any mouse button on a context menu selection works. Other controls I've tried: Panel, Label and Form, behave like a text box (only left button works).
Can anyone explain this inconsistency?
Yigal
|
|
|
|
|
I guess this question has been asked before, but I could not find any solution for it so here it is again:
How can I download gif-file from internet (URL) (using C# code)?
I want to use this function in a Pocket PC program that I am currently writing.
Thanks in advance!
Frank, Norway
|
|
|
|
|
have you attempted
Bitmap bm = new Bitmap(@"http://<absolute address="" of="" picture="">.gif");
|
|
|
|
|
you can do that?~?~!
/\ |_ E X E GG
|
|
|
|
|
It did not work.
I am trying to convert the "Threaded WebDownload class with Progress Call-backs" project to a SmartDevice project. It is working fine on the PC but it crashes when I run the application on the PPC (WM 2003). It seems to crash when this statment is excecuted :
DownloadThread dl = new DownloadThread();
I don't know why.
|
|
|
|
|
I have a string that contains some text. I want to check if the text can be converted into an integer. At the moment my code looks like this:
bool isInt = true;
try
{
int intValue = int.Parse(stringValue);
}
catch(Exception e)
{
isInt = false;
}
At the end of the code isInt will contain whether the string value can be converted to an int or not.
Is there a better way to do this? I don't like having to catch an exception when I expect that many string values will not be convertable to an int. It seems very inefficient.
|
|
|
|
|
It's the most secure way to convert a string to an int.
Why don't you put just all assignments into one single try-catch block?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Greeeg wrote:
Why don't you put just all assignments into one single try-catch block?
I don't want to convert it. This is part of some validation code. I just want to see if it is possible to convert it.
|
|
|
|
|
Since someone voted my previous reply a 3 I can only guess that I didn't explain myself very well.
I don't have multiple assignments. I only want to check one value and I only want to check if it is possible to convert it to an integer. I do not want to do an actual conversion.
If further explanation is needed, I'll be happy to explain more.
|
|
|
|