|
Now, take a deep breath: what you are about to hear is not an insult. Everyone here was a beginner ... once.
Your question suggests, to me, that you are very new to programming, and pretty confused about what a Windows Form Application is.
A Console Application and a Windows Forms Application are totally different.
Yes, a Console is a "window," and it's the only run-time surface/canvas/window the user can interact with. It has a built-in processing loop read-evaluate-print triggered by your hitting the Enter key.
A Windows Form Application has (typically, by default) a Main Window, and the programmer can create as many other Windows (Forms) as they wish. Closing the Main Window will close all the other open Forms. Each Form, when it has focus, gets connected to the Windows message-pump that sends it keystrokes, mouse-actions, etc. Which Control on a given Form "receives" these messages will vary depending on the Control, and the context.
Sometimes people get confused because in a Windows Forms Application, you can cause text output to be written to the 'Output window in Visual Studio by using code like this:
Console.WriteLine("current value: {0}", currentValue);
There's a good free book, "DotNet Zero" by Charles Petzold you can download here: [^].
Once you have gotten an initial mastery of the Console Application, I suggest you get a book on Windows Forms; I think the (older, but still good) books by Jesse Liberty and Matthew McDonald are excellent.
cheers, Bill
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
So you cannot use the same "words" to write both a console and forms app.. Not only are you forced into the new language C#, but sub languages as well
|
|
|
|
|
Why would you want to? The two application types are totally different and always have been. Before .NET (C#, VB.NET etc.) there was pure Windows, which was still different from console apps.
|
|
|
|
|
Yes, you can. A windows app is a console-app. It will write in both applications to the same destionation; stdout.
Anything else?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Sounds like ORT might be back
|
|
|
|
|
|
The use of English in the later posts would point at ORT...he has a certain "style".
Hopefully, this time he will refrain from the shrooms or whatever (or not post when using them)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I have worked on Linking outlook with asp .net application ie sendind the appointment request from asp .net application i.e web to outlook . I got correct response also now want that response I am getting from Outlook To be sent as mail to the person requesting meeting after the accept/reject/tentative and update the status in Asp .net application .
|
|
|
|
|
If you're using Office Interop from ASP.NET, you should read the following Microsoft knowledgebase article:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
Aside from installing Office on the server, there are various hoops you'll have to jump through to stand any chance of getting it working. And even if you do, there's no guarantee that it won't suddenly stop working for no obvious reason at some point in the future.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Under that article is a forum, similar to this, where you can ask questions about said article.
I'd recommend you also explain "what" doesn't work, what your expected and actual results, or, in case of an error, the complete exception-message.
Otherwise, there'd be no way to help beyond asking basic questions like "is Google Earth installed", did it start, did SetParent fail, what?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using EARTHLib;
using UnityEngine;
using System.Resources;
namespace simulation
{
public partial class Frmexe : Form
{
[DllImport("user32.dll")]
private static extern int SetParent(
int hWndChild,
int hWndParent);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(
int hWnd,
int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(
int hWnd,
int hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
[DllImport("user32.dll")]
private static extern int SendMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
private const int HWND_TOP = 0x0;
private const int WM_COMMAND = 0x0112;
private const int WM_QT_PAINT = 0xC2DC;
private const int WM_PAINT = 0x000F;
private const int WM_SIZE = 0x0005;
private const int SWP_FRAMECHANGED = 0x0020;
private EARTHLib.ApplicationGE ge = null;
public Frmexe()
{
InitializeComponent();
ge = new ApplicationGE();
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
ShowWindowAsync(ge.GetMainHwnd(), 0);
SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32());
ResizeGoogleControl();
}
private void Frmexe_Resize(object sender, EventArgs e)
{
ResizeGoogleControl();
}
private void ResizeGoogleControl()
{
try
{
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
}
catch { }
}
private void Frmexe_FormClosing(object sender, FormClosingEventArgs e)
{
System.Diagnostics.Process[] ge = System.Diagnostics.Process.GetProcessesByName("googleearth");
ge[0].Kill();
}
modified 27-May-16 10:29am.
|
|
|
|
|
You can't; the example shows how to embed a running executable, not how to manipulate its data - it is not loaded as a COM-component (there might not be one) which would allow manipulation of its elements.
You'll find examples on how to add markers in their documentation[^], along with a warning that the API will be gone by the end of this year.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
google earth appilication can show without appication border example minimize,restoredown and close in winform?
|
|
|
|
|
Yes; you'd need to send a (windows) message to the GE application that sets the border. Most examples on embedding a running executable show how to do so.
Example here[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
If you have an issue with the content of a CodeProject article then you should use the forum at the end of the article. However, I note that the author has not been active for some years so it is unlikely that you will get a response..
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using EARTHLib;
using UnityEngine;
using System.Resources;
namespace simulation
{
public partial class Frmexe : Form
{
[DllImport("user32.dll")]
private static extern int SetParent(
int hWndChild,
int hWndParent);
[DllImport("user32.dll")]
private static extern bool ShowWindowAsync(
int hWnd,
int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(
int hWnd,
int hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
[DllImport("user32.dll")]
private static extern int SendMessage(
int hWnd,
uint Msg,
int wParam,
int lParam);
private const int HWND_TOP = 0x0;
private const int WM_COMMAND = 0x0112;
private const int WM_QT_PAINT = 0xC2DC;
private const int WM_PAINT = 0x000F;
private const int WM_SIZE = 0x0005;
private const int SWP_FRAMECHANGED = 0x0020;
private EARTHLib.ApplicationGE ge = null;
public Frmexe()
{
InitializeComponent();
ge = new ApplicationGE();
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
ShowWindowAsync(ge.GetMainHwnd(), 0);
SetParent(ge.GetRenderHwnd(), this.Handle.ToInt32());
ResizeGoogleControl();
}
private void Frmexe_Resize(object sender, EventArgs e)
{
ResizeGoogleControl();
}
private void ResizeGoogleControl()
{
try
{
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_PAINT, 0);
PostMessage(ge.GetMainHwnd(), WM_QT_PAINT, 0, 0);
SetWindowPos(ge.GetRenderHwnd(), HWND_TOP, 0, 0, (int)this.Width,
(int)this.Height-50, SWP_FRAMECHANGED);
SendMessage(ge.GetMainHwnd(), WM_COMMAND, WM_SIZE, 0);
}
catch { }
}
private void Frmexe_FormClosing(object sender, FormClosingEventArgs e)
{
System.Diagnostics.Process[] ge = System.Diagnostics.Process.GetProcessesByName("googleearth");
ge[0].Kill();
}
modified 27-May-16 10:30am.
|
|
|
|
|
You aren't reading what they have told you. Ask your question at the end of the article.
This space for rent
|
|
|
|
|
Hello there. We take the example of Bubble Sort Algo.
Time Complexity
Best O(n)
Worst O(n^2)
Space Complexity
Worst O(1)
Let us suppose a simple array contains 25 elements. What does above information mean and how should I visualize it?? Thanks for clearing some basics.
|
|
|
|
|
|
This has nothing to do with C#. You would be better off asking in the Algorithms forum[^].
This space for rent
|
|
|
|
|
Django_Untaken wrote: Let us suppose a simple array contains 25 elements. What does above information mean It will be useless.
|
|
|
|
|
I am running an exe through commandline and getting following output.
C:\Users\sysadmin>C:\Users\sysadmin\Desktop\New_folder\Setup\PatchInstaller.exe --mode=silent
C:\Users\sysadmin Begin Setup
UI mode: Silent
Error : Another instance running, Only a single instance can be run at a time.
Exit Code: 11
i am running this through System.daignostics.process.
My issue is PatchInstaller.exe calling another process and the output of that nested process is what is visible with cmd. but the same result and exit code i am not able to get through Process object of PatchInstaller.exe.
Is there any way of getting output of process running within process?
Following is the code i have tired...
string command = @"C:\Users\sysadmin\Desktop\Setup\PatchInstaller.exe";
string result = string.Empty;
Exitcode = 0;
try
{
Exitcode = 0;
System.Diagnostics.ProcessStartInfo procStartInfo = new ProcessStartInfo();
procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command + " --mode=silent);
System.Diagnostics.Process proc = new Process();
// The following commands are needed to redirect the standard output.
//This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.ErrorDialog = false;
procStartInfo.UseShellExecute = false;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
if (!string.IsNullOrEmpty(domain) && !string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pwd))
{
procStartInfo.Domain = domain;
procStartInfo.UserName = user;
System.Security.SecureString ss = new System.Security.SecureString();
foreach (char c in pwd) { ss.AppendChar(c); }
procStartInfo.Password = ss;
}
// Now we create a process, assign its ProcessStartInfo and start it
proc = System.Diagnostics.Process.Start(procStartInfo);
proc.ErrorDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs errorLine)
{
if (errorLine.Data != null) result += "error:" + errorLine.Data + "\r\n";
};
proc.OutputDataReceived += delegate(object sender, System.Diagnostics.DataReceivedEventArgs outputLine)
{
if (outputLine.Data != null) result += outputLine.Data + "\r\n";
};
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
Process[] pname = Process.GetProcessesByName("AdobePatchInstaller");
Process[] processlist = Process.GetProcesses();
foreach (Process theprocess in processlist)
{
Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}
proc.WaitForExit();
}
catch (Exception ex)
{
throw (ex);
}
return result;
modified 26-May-16 6:06am.
|
|
|
|
|
Hi,
I have created an application that sits in the system tray on each PC, which collects system information using WMI and stores it in an SQL DB. I would like to be able to send commands to this application to invoke functions within the application. For example, I could send a shutdown command which when received would fire off a shutdown routine. I would like to be able to send messages to the end user which would fire off a procedure to display that message in a message box.
I was thinking of using the TCP listener class to have the application listen on a specified port, which I could then connect to, and send commands. I would appreciate it if somebody could advise me as to whether this is the right approach or is there an alternative way.
Thanks in advance
Neil (100% human)
modified 26-May-16 4:08am.
|
|
|
|
|
Message Closed
modified 26-May-16 8:59am.
|
|
|
|
|