Thought I'd share this here in case anyone else needed it or knows a better way to minimize the IDE when you run code, since there doesn't seem to be an option (in VS 2010/VB) to do this.Code:Public Class Form1 Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing #If DEBUG Then Dim Pr() As Process = Process.GetProcesses For Each P As Process In Pr If P.MainWindowTitle.Contains(My.Application.Info.AssemblyName) Then Dim hwnd As IntPtr = P.MainWindowHandle ShowWindow(hwnd, 9) Exit For End If Next #End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load #If DEBUG Then Dim Pr() As Process = Process.GetProcesses For Each P As Process In Pr If P.MainWindowTitle.Contains(My.Application.Info.AssemblyName) Then Dim hwnd As IntPtr = P.MainWindowHandle ShowWindow(hwnd, 6) Exit For End If Next #End If End Sub Declare Function ShowWindow Lib "User32.dll" (ByVal hwnd As IntPtr, ByVal nCmdShow As UInteger) As Boolean End Class
Originally asked on MSDN here.




Reply With Quote