473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How launch app from within code?

How do I launch, say, Microsoft Word from within a C# Win app? Word should
launch exterior to my app, of course. Is it easy to set size and position
of where Word window will be placed?

Thanks,
Ron
Jun 28 '06 #1
6 5189
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word should
launch exterior to my app, of course. Is it easy to set size and position
of where Word window will be placed?

Thanks,
Ron


Jun 28 '06 #2
This was exactly what I needed John.. thanks.

Any chance you can tell me how to control the X, Y position of where it
appears on the screen (and size of window)?

Thanks,
Ron

"John Duval" <Jo********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word
should
launch exterior to my app, of course. Is it easy to set size and
position
of where Word window will be placed?

Thanks,
Ron

Jun 28 '06 #3
"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
This was exactly what I needed John.. thanks.

Any chance you can tell me how to control the X, Y position of where it
appears on the screen (and size of window)?
You might need P/Invoke... although I don't see a managed version, the
STARTUPINFO structure used by Win32 CreateProcess has

dwX
If dwFlags specifies STARTF_USEPOSITION, this member is the x offset of the
upper left corner of a window if a new window is created, in pixels.
Otherwise, this member is ignored.
The offset is from the upper left corner of the screen. For GUI processes,
the specified position is used the first time the new process calls
CreateWindow to create an overlapped window if the x parameter of
CreateWindow is CW_USEDEFAULT.
dwY
If dwFlags specifies STARTF_USEPOSITION, this member is the y offset of the
upper left corner of a window if a new window is created, in pixels.
Otherwise, this member is ignored.
The offset is from the upper left corner of the screen. For GUI processes,
the specified position is used the first time the new process calls
CreateWindow to create an overlapped window if the y parameter of
CreateWindow is CW_USEDEFAULT.
dwXSize
If dwFlags specifies STARTF_USESIZE, this member is the width of the window
if a new window is created, in pixels. Otherwise, this member is ignored.
For GUI processes, this is used only the first time the new process calls
CreateWindow to create an overlapped window if the nWidth parameter of
CreateWindow is CW_USEDEFAULT.
dwYSize
If dwFlags specifies STARTF_USESIZE, this member is the height of the window
if a new window is created, in pixels. Otherwise, this member is ignored.
For GUI processes, this is used only the first time the new process calls
CreateWindow to create an overlapped window if the nHeight parameter of
CreateWindow is CW_USEDEFAULT.

Thanks,
Ron

"John Duval" <Jo********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word
should
launch exterior to my app, of course. Is it easy to set size and
position
of where Word window will be placed?

Thanks,
Ron


Jun 28 '06 #4

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
This was exactly what I needed John.. thanks.

Any chance you can tell me how to control the X, Y position of where it
appears on the screen (and size of window)?
Or use Process.WaitForInputIdle, Process.MainWindowHandle, and
SetWindowPos... might be necessary for apps that don't respect their startup
parameters.

Thanks,
Ron

"John Duval" <Jo********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word
should
launch exterior to my app, of course. Is it easy to set size and
position
of where Word window will be placed?

Thanks,
Ron


Jun 28 '06 #5
Ben,

Could you show me at all what that code would look like? I would greatly
appreciate it.

Thanks,
Ron
"Ben Voigt" <rb*@nospam.nospam> wrote in message
news:OW**************@TK2MSFTNGP03.phx.gbl...

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
This was exactly what I needed John.. thanks.

Any chance you can tell me how to control the X, Y position of where it
appears on the screen (and size of window)?


Or use Process.WaitForInputIdle, Process.MainWindowHandle, and
SetWindowPos... might be necessary for apps that don't respect their
startup parameters.

Thanks,
Ron

"John Duval" <Jo********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word
should
launch exterior to my app, of course. Is it easy to set size and
position
of where Word window will be placed?

Thanks,
Ron



Jun 28 '06 #6
Hi Ronald,
You might want to look at SetWindowPos. Something like this:

[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int X, int Y, int cx, int cy, uint uFlags);
private const int HWND_TOP = 0;

[STAThread]
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start();

SetWindowPos(p.MainWindowHandle, (IntPtr)HWND_TOP, 100, 100, 400, 400,
0);
}

Ronald S. Cook wrote:
This was exactly what I needed John.. thanks.

Any chance you can tell me how to control the X, Y position of where it
appears on the screen (and size of window)?

Thanks,
Ron

"John Duval" <Jo********@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
Process.Start() will do the trick. There is a "WindowStyle" enum that
lets you control the initial window state somewhat:

Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft
Office\Office\winword.exe";
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
p.Start();
Ronald S. Cook wrote:
How do I launch, say, Microsoft Word from within a C# Win app? Word
should
launch exterior to my app, of course. Is it easy to set size and
position
of where Word window will be placed?

Thanks,
Ron


Jun 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kendal Goodrich | last post by:
In the setup project I am trying to create, I am wanting to search to see if DirectX 8 is installed on the local machine. I figured the best way to determine would be a registry key search, so I...
10
by: scott | last post by:
From an asp page, i'm trying to auto-open a pop-up page if something exists. I can do this within access via vba using below code. Anyone know how I could modify the below js to auto-lauch from...
5
by: GrantS | last post by:
Hi I am trying to use ShellExecute to launch an application to display a certain file. The variation on the theme is that I need to be able to specify the application to launch and not simply...
4
by: Joe | last post by:
I created a CustomAction for this but I don't think I have it in the right place. I tried both Install and Commit but neither allow it to get to the final screen. Are there any examples of this...
0
by: psmukilan | last post by:
Can any one guide me how to launch the installed application immediatley after the Finished screen button clicked. Once the user clicks the finished screen "Close" button, i need to launch the...
1
by: sylsau | last post by:
Hello, I wrote a JAVA program which uses the JAVA API JDOM 1.0 (of this site www.jdom.org) I put the archive jdom.jar in the directory /usr/share/java/jdom.jar and I added this path in the...
4
by: Patrick Dugan | last post by:
I am trying to launch a vbscript from within vb.net (vs2005) The script itself requires a parameter of a filename to process. I have tried: Dim P As Process =...
1
by: Ad | last post by:
It it possible to launch a windows form from within internet explorer? I need to keep this form on top of anything else, for which i can use the TopMost property of the form to achieve. Thanks
5
by: cooltoriz | last post by:
Hello there, I am not asking how to impersonate a process within C# windows application. I already know that, in C# v2.0, you can easily achieve it using ProcessStartInfo. You can run a process...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.