|
Hi Guys
I am relative new to Visual Studio... I'm about to do some calculations on my data and I was wondering if anybody can tell me the difference between choosing a Windows application or Console application when starting a project and what is the difference. Seems to me, to be easier to implement my algorithms in a console, because it is possible to get the data output in the commando-prompt (don't know how to do this in an application) and later on when designing the GUI I could change it over to an application, is this possible..?
Thanks in advance
AL
|
|
|
|
|
Not good design. That was applicable if the GUI would take a lot of programming, but now in C# all you usually do is drag/drop.
you want to display your output. It could be as easy as:
MessageBox.Show(MyOutputString);
or
MessageBox.Show(MyOutputInt.ToString());
Another way is to show it in a TextBox control:
MyTextBox.Text = MyOutputString;
You usually make a consol application when you don't need a user interface. e.g. a command line tool. If you will need a user interface, you should start a windows application from the beginning. If you don't know how to make a user interface in C#, learning it would be as easy as reading a comic book. Either grab a book, or screw thing up yourself with the designer till you get it right -I don't think it would be that way-. You can even download some free video tutorials on that from the net.
Regards
|
|
|
|
|
ComCoderCsharp wrote: Windows application or Console application
There is no major difference apart from the fact that in a Console application the console is displayed. In a windows one you can write stuff to the console (standard input / output / error) but nothing will be displayed or read.
ComCoderCsharp wrote: Seems to me, to be easier to implement my algorithms in a console
It doesn't really matter, displaying the data initially might be easier with a console.
ComCoderCsharp wrote: (don't know how to do this in an application)
The simplest solution would be to drop a textbox onto the form and append data to that using the TextBox.AppendText method.
ComCoderCsharp wrote: later on when designing the GUI I could change it over to an application, is this possible..?
Yes, just open the property pages and change the output type to Windows Application rather than console, all this does is change a command-line option when calling the C# compiler.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
A Console Application shows the console window while a Windows Application does not.
Both a Console Application and a Windows Application can open forms - so you could always use a console application and output logging information on the console (if you don't like Debug.WriteLine). Unlike forms, the console window content will be visible even if your application is not responding.
For the release builds, you could then just switch to a Windows Application.
|
|
|
|
|
This really cleared things up - I think I will use an application and view tha data in a gui box
all the best
Al
|
|
|
|
|
I have File-Exit Menu. In this menu I want to invoke FormClosingEvent. Please tell me how can call that event from From File-Exit Menu. I dont know what to write in enum CloseReason.
<br />
private void FileExit_Click(object sender, EventArgs e)<br />
{<br />
<br />
}<br />
<br />
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)<br />
{<br />
<br />
if (dirty == true)<br />
{<br />
DialogResult res = SaveDialog();<br />
if (res == DialogResult.Yes)<br />
{<br />
SaveFile();<br />
e.Cancel = false;<br />
}<br />
if (res == DialogResult.No)<br />
{<br />
<br />
e.Cancel = false;<br />
}<br />
if (res == DialogResult.Cancel)<br />
{<br />
e.Cancel = true;<br />
<br />
}<br />
<br />
}<br />
}<br />
<br />
|
|
|
|
|
Call Close method of your main form.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Thank u.
FormClosedEventArgs ev = new FormClosedEventArgs(/*??? */);
MainForm_FormClosed(sender, ev);
Please tell me how can i call? What to write in argument, wat to write in CloseReason?
|
|
|
|
|
try one of these:
myMainForm.Close();
Close(); // inside main form class
Application.Exit();
Luc Pattyn
|
|
|
|
|
oooh very thanks.
I am still new with C# after 2 months
|
|
|
|
|
Just call Close on your File Exit handler. It will try to close the form, raising the Closing event in the process. If nothing cancels the closing, then you get the Closed event.
You don't have to call your Closing event handler manually.
|
|
|
|
|
I think you can send the win32AI message "WM_CLOSE" when the button is clicked like a function in win32 SDK "SendMessage()" function:
like this:
// define
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("User32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
const int WM_LBUTTONDOWN = 0x201;
const int WM_LBUTTONUP = 0x0202;
// sample, u should use spy++ to find windows class name and control class name
IntPtr hwndWin = FindWindow("TfrmMain", "window title");
if (hwndWin.Equals(IntPtr.Zero) == false)
{
IntPtr hwndBtn = FindWindowEx(hwndWin, IntPtr.Zero, "TButton", "control text");
if (hwndBtn.Equals(IntPtr.Zero) == false)
{
SendMessage(hwndBtn, WM_LBUTTONDOWN, IntPtr.Zero, IntPtr.Zero);
SendMessage(hwndBtn, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
}
}
|
|
|
|
|
Hi everyone!
I have questions ...
How can i search treeNodes in an treeView using treeNode.Name property?
How can i highlight resultant nodes?
Please need some idea. Thanks.
|
|
|
|
|
h@s@n wrote: How can i search treeNodes in an treeView using treeNode.Name property?
You'd have to go through all nodes recursively.
h@s@n wrote: How can i highlight resultant nodes?
Call TreeNode.Select(), or TreeNode.Selected = true
Regards
|
|
|
|
|
Hi all,
I'd like to know how you make your application to support localizationand if you prefer to work with resources files and its namespace or you prefer to work with external xml files and tools (like gettext, ...). Why have you chosen your way?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Marc Soleda wrote: if you prefer to work with resources files
Yes.
Marc Soleda wrote: Why have you chosen your way?
1- It's more generic.
2- Mthods and classes are built-in.
3- Has a lot of documentaion. You'll know easily when you screw up
4- Most important => It takes less to code and maintain.
Regards
|
|
|
|
|
Hi,
you can also, enable islocalizable property,
then simply select language,
then type necassary text,
save it,
vs will create a localize res.
you can also see it in the debug folder as a dll..
Cheers.
http://mp3-album.blogspot.com
|
|
|
|
|
hi
In my case i have diferent user with diffrentent language preference. So as per user's login language id is comming from db.
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("langID");
Then i am having a .resx file for common messages. And for each .aspx page i have .aspx.[langID].resx file.
And some code to get data from this .resx file like
System.Resources.ResourceManager temp = new System.Resources.ResourceManager("namespace address", typeof(Resources).Assembly);
This way we donot need a thridparty tool and maintenace is quit easy.
|
|
|
|
|
1 private void AddPlugin(Assembly pluginAssembly) {
2
3 //Loop through all the Types found in the assembly
4 foreach (Type pluginType in pluginAssembly.GetTypes()) {
5 //Only look at public and non-abstract types
6 if (pluginType.IsPublic && !pluginType.IsAbstract) {
7 Type typeInterface = null;
8 try {
9 //Gets a type object of the interface we need the plugins to match
10 typeInterface = pluginType.GetInterface("IPlugin", true);
11 }
12 catch (Exception) { }
13
14 //Make sure the interface we want to use actually exists
15 if (typeInterface1 != null) {
16 //Create a new available plugin instance
17 T newPlugin =
18 (T)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
19
20 availablePlugins.Add(newPlugin);
21 }
22 }
23 }
24 }
Here's a method I've got in a generic PluginManager class with parameter T.
It adds a plugin of the right type to a list of available plugins.
The problem I've got is in line 10. Instead of "IPlugin" (The parent interface of the different interfaces for plugins (IParser, ISolution, etc.), something like "T" should be used.
Unfortunatly I couldn't find out how to get the name of the parameter T as a string.
ToString and casting doesn't work on the generic parameter.
Is there any way of getting the right string ("IParser", "ISolution", etc.) depending on the chosen parameter T?
|
|
|
|
|
Try looking at the methods in pluginType which have generic in them, e.g. you might want to try pluginType.GetGenericParameters (I think it's called that anyway).
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
I found a solution, but I'm not quite happy with it.
I simply pass the string I need to the constructor, when I create an instance of the class.
Thanks for the help
I'll check it out, it might be the cleaner way of accessing the string I need.
|
|
|
|
|
Hi all,
I create a second form on my main form like this.
private void btnEntryForm_Click(object sender, EventArgs e)
{
EntryForm frm = new EntryForm();
frm.Show();
}
Then I want my second form behave like any other control. That means when I
resize, move, minimize or maximize,etc. the main form I want my second form keep its location on the main form same and follow all the other events, like an ordinary control on the main form. How ?
Thanks in advance
Muharrem
-- modified at 13:19 Sunday 17th December, 2006
|
|
|
|
|
Hi
I advice you to write a inherited class from windows.form class,
then add any property in that class.
even you can add eventhandlers
or use predefined eventhandlers
like;
form_resized += new EventHandler...
you can handle them from your parent form that is your class
hope it helps.
Cheers.
|
|
|
|
|
using toggled value with in the column like stop and start when clicking start stop should be hide and again when clicking stop then start should be hide so i have tried this using div but could not get result so anybody has suffering from such kinds of troubled and have solution then give me the hints i will be appreciates for u.
hikbnet
|
|
|
|
|
I don't know how to set a program to start at startup.
Help.
Vasildb
|
|
|
|