Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the .NET equivalent of the win32 "ShowWindow"?

Status
Not open for further replies.

maxpower1

Programmer
Jul 29, 2001
488
US
I am writing a menuing application that starts up other applications as seperate processes. If the user selects an application that is already running, I want that application to be displayed and become the active one on the desktop. When I start the application up, I maintain a process object. So I can get the MainWindowHandle for the process. In VB6.0, I could pass this handle to ShowWindow to get the desired results. So how do I do it with VB .NET?

Thanks
 
Define handles As IntPtr. Use the Win API using Declare statements as you did in VB6. Remember that LONG on the API is INTEGER in VB.NET. I've successfully used the Named Pipes APIs in VB.Net using As IntPtr for handles. Get a blank line in your code. Enter "Declare" without the quotes then press F1 for help. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
According to API Guide, the .NET equivalent for show window is: System.Windows.Forms.Form.ShowDialog

Here's an example:

Imports System
Imports System.Windows.Forms
Imports System.Drawing
Public Module modmain
Sub Main()
'The KPD-Team 2001
'URL: 'E-Mail: KPDTeam@Allapi.net
Dim theForm as MainForm = new MainForm()
theForm.Size = new Size(500, 350)
theForm.Text = "Visual Basic.NET"
theForm.ShowDialog()
End Sub
End Module
Public Class MainForm
Inherits Form
Protected Overrides Sub OnPaint(e as PaintEventArgs)
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawLine(new Pen(Color.Blue), 0, 0, Me.ClientSize.Width, Me.ClientSize.Height)
End Sub
End Class
 
Ponerse.

That will not display a window belonging to another application which the .Net Application started.
"starts up other applications as seperate processes... want that application to be displayed and become the active one on the desktop" Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Following JohnYingling's suggestion, I was able to make the call to the ShowWindow function. Unfortunately it didn't work the way I expected. The best results I could get was using a value of 1 (which is SW_SHOWNORMAL). In that case if the application that was running was maximized or minimized, it was resized and became the active window. If the application that was running was already being displayed normal, it does not become the active window.

P.S. - I was the one that made the initial posting, but I didn't realize I was still logged in as the person who showed me about Tek-Tips.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top