How can I set the text in the titlebar of System.Diagnostics.Process.Start 
Author Message
 How can I set the text in the titlebar of System.Diagnostics.Process.Start

VB.NET 2003 beta.

I'm using System.Diagnostics.Process.Start to launch some Win32 console
apps. The text used in the title bar of the resulting window is the path and
name
of the app.

I would like to change that to something friendlier and shorter.

I found the 'get' title text but not a 'set'.

Thanks in advance for pointers/suggestions.

Heinz



Sat, 27 Aug 2005 06:26:00 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
Hello Heinz,

I think the native API - SetWindowText is helpful. You may import it by
using DllImport and pass the new process's MainWindowHandle to the
function. This is a sample code:

using System.Runtime.InteropServices;

[DllImport("User32")]
static extern private bool SetWindowText(IntPtr hWnd, string lpString);

Process p = Process.Start(pInfo);
System.Threading.Thread.Sleep(500); // Wait for the new window showing
SetWindowText(p.MainWindowHandle, "Hello");

I hope this is helpful.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2003 Microsoft Corporation. All rights
reserved.
--------------------

    Subject: How can I set the text in the titlebar of
System.Diagnostics.Process.Start
    Date: Mon, 10 Mar 2003 14:26:00 -0800
    Lines: 17
    X-Priority: 3
    X-MSMail-Priority: Normal
    X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

    Newsgroups: microsoft.public.dotnet.languages.vb
    NNTP-Posting-Host: router.bytedesigns.com 208.181.117.251
    Path: cpmsftngxa06!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    Xref: cpmsftngxa06 microsoft.public.dotnet.languages.vb:95253
    X-Tomcat-NG: microsoft.public.dotnet.languages.vb

    VB.NET 2003 beta.

    I'm using System.Diagnostics.Process.Start to launch some Win32 console
    apps. The text used in the title bar of the resulting window is the
path and
    name
    of the app.

    I would like to change that to something friendlier and shorter.

    I found the 'get' title text but not a 'set'.

    Thanks in advance for pointers/suggestions.

    Heinz



Sat, 27 Aug 2005 11:31:20 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
And for those VBeans:

<DllImport("User32")> _
Public Function SetWindowText(hWnd As IntPtr, lpString As String) As Boolean
End Function

Dim p As Process = Process.Start(pInfo)
System.Threading.Thread.Sleep(500)
SetWindowText(p.MainWindowHandle, "Hello")

--
==============================================
Happy To Help,
Tom Spink

http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day

Quote:
> Hello Heinz,

> I think the native API - SetWindowText is helpful. You may import it by
> using DllImport and pass the new process's MainWindowHandle to the
> function. This is a sample code:

> using System.Runtime.InteropServices;

> [DllImport("User32")]
> static extern private bool SetWindowText(IntPtr hWnd, string lpString);

> Process p = Process.Start(pInfo);
> System.Threading.Thread.Sleep(500); // Wait for the new window showing
> SetWindowText(p.MainWindowHandle, "Hello");

> I hope this is helpful.

> Best regards,

> Lion Shi [MSFT]
> MCSE, MCSD
> Microsoft Support Engineer

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use.  2003 Microsoft Corporation. All rights
> reserved.
> --------------------

>     Subject: How can I set the text in the titlebar of
> System.Diagnostics.Process.Start
>     Date: Mon, 10 Mar 2003 14:26:00 -0800
>     Lines: 17
>     X-Priority: 3
>     X-MSMail-Priority: Normal
>     X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
>     X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106

>     Newsgroups: microsoft.public.dotnet.languages.vb
>     NNTP-Posting-Host: router.bytedesigns.com 208.181.117.251
>     Path: cpmsftngxa06!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
>     Xref: cpmsftngxa06 microsoft.public.dotnet.languages.vb:95253
>     X-Tomcat-NG: microsoft.public.dotnet.languages.vb

>     VB.NET 2003 beta.

>     I'm using System.Diagnostics.Process.Start to launch some Win32
console
>     apps. The text used in the title bar of the resulting window is the
> path and
>     name
>     of the app.

>     I would like to change that to something friendlier and shorter.

>     I found the 'get' title text but not a 'set'.

>     Thanks in advance for pointers/suggestions.

>     Heinz



Sat, 27 Aug 2005 21:01:31 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
Thanks Lion and Tom.

As I'm using VB, this is what I've tried:
<DllImport("user32")> _

Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As
String) As Boolean

End Function

I get a "Type 'DllImport' note defined" error so I'm assuming I missed
something.

Tried to dig into the docs too to see what I may be missing re the DllImport
but no luck so I'm back for more help. What did I miss (as a newbie to .NET
and in programming catch-up mode)?

Thanks in advance

Heinz



Quote:
> And for those VBeans:

> <DllImport("User32")> _
> Public Function SetWindowText(hWnd As IntPtr, lpString As String) As
Boolean
> End Function

> Dim p As Process = Process.Start(pInfo)
> System.Threading.Thread.Sleep(500)
> SetWindowText(p.MainWindowHandle, "Hello")

> --
> ==============================================
> Happy To Help,
> Tom Spink

<snip>


Sun, 28 Aug 2005 00:41:13 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
All you have to do is put an Imports statement at the top of your code:

Imports System.Runtime.InteropServices

--
==============================================
Happy To Help,
Tom Spink

http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

Please respond to the newsgroups, so all can benefit.

One day

Quote:
> Thanks Lion and Tom.

> As I'm using VB, this is what I've tried:
> <DllImport("user32")> _

> Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As
> String) As Boolean

> End Function

> I get a "Type 'DllImport' note defined" error so I'm assuming I missed
> something.

> Tried to dig into the docs too to see what I may be missing re the
DllImport
> but no luck so I'm back for more help. What did I miss (as a newbie to
.NET
> and in programming catch-up mode)?

> Thanks in advance

> Heinz



> > And for those VBeans:

> > <DllImport("User32")> _
> > Public Function SetWindowText(hWnd As IntPtr, lpString As String) As
> Boolean
> > End Function

> > Dim p As Process = Process.Start(pInfo)
> > System.Threading.Thread.Sleep(500)
> > SetWindowText(p.MainWindowHandle, "Hello")

> > --
> > ==============================================
> > Happy To Help,
> > Tom Spink

> <snip>



Sun, 28 Aug 2005 01:14:35 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
Either add this line to the Top of the Class ( I hope that's just Wrapping
adding that blank line before the Function):
    Imports System.Runtime.InteropServices

or declare your API the Old VB Classic style:
    Public Declare Function SetWindowText Lib "User32" (ByVal hwnd as
IntPtr, ByVal lpString as String) As Boolean


Quote:
> Thanks Lion and Tom.

> As I'm using VB, this is what I've tried:
> <DllImport("user32")> _

> Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As
> String) As Boolean

> End Function

> I get a "Type 'DllImport' note defined" error so I'm assuming I missed
> something.

> Tried to dig into the docs too to see what I may be missing re the
DllImport
> but no luck so I'm back for more help. What did I miss (as a newbie to
.NET
> and in programming catch-up mode)?

> Thanks in advance

> Heinz



> > And for those VBeans:

> > <DllImport("User32")> _
> > Public Function SetWindowText(hWnd As IntPtr, lpString As String) As
> Boolean
> > End Function

> > Dim p As Process = Process.Start(pInfo)
> > System.Threading.Thread.Sleep(500)
> > SetWindowText(p.MainWindowHandle, "Hello")

> > --
> > ==============================================
> > Happy To Help,
> > Tom Spink

> <snip>



Sun, 28 Aug 2005 01:18:27 GMT  
 How can I set the text in the titlebar of System.Diagnostics.Process.Start
THANK YOU
Went back to the docs to dig more after I posted and found it too. Thanks
for confirming I did right (for a change).

and it works too :-))

Thanks again, to all.


Quote:
> All you have to do is put an Imports statement at the top of your code:

> Imports System.Runtime.InteropServices

> --
> ==============================================
> Happy To Help,
> Tom Spink

> http://dotnetx.betasafe.com >> VB, VB.NET, C#, C++ Code

> Please respond to the newsgroups, so all can benefit.

> One day


> > Thanks Lion and Tom.

> > As I'm using VB, this is what I've tried:
> > <DllImport("user32")> _

> > Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As
> > String) As Boolean

> > End Function

> > I get a "Type 'DllImport' note defined" error so I'm assuming I missed
> > something.

> > Tried to dig into the docs too to see what I may be missing re the
> DllImport
> > but no luck so I'm back for more help. What did I miss (as a newbie to
> .NET
> > and in programming catch-up mode)?

> > Thanks in advance

> > Heinz



> > > And for those VBeans:

> > > <DllImport("User32")> _
> > > Public Function SetWindowText(hWnd As IntPtr, lpString As String) As
> > Boolean
> > > End Function

> > > Dim p As Process = Process.Start(pInfo)
> > > System.Threading.Thread.Sleep(500)
> > > SetWindowText(p.MainWindowHandle, "Hello")

> > > --
> > > ==============================================
> > > Happy To Help,
> > > Tom Spink

> > <snip>



Sun, 28 Aug 2005 01:38:28 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. System.Diagnostics.Process.Start()

2. Invoking System.Diagnostics.Process.Start

3. System.Diagnostics.Process.Start

4. System.Diagnostics.Process.Exited event not firing

5. Using the System.Diagnostic.Process class

6. System.Diagnostics.Process

7. System.Diagnostics.Process class HELP PLEASE

8. System.Diagnostics.Process.Start("C:\")

9. Solution for Setting the Windows-NT-System-Default-Printer (without any dialog)

10. simple questions (CDONTS/carCount/scriptname/sort)

11. password char in System.Web.UI.WebControls.TextBox

12. System.Drawing.Text.InstalledFontCollection

 

 
Powered by phpBB® Forum Software