Results 1 to 3 of 3

Thread: Minimize IDE on Code Run (F5)

  1. #1

    Thread Starter
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Resolved Minimize IDE on Code Run (F5)

    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
    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.

    Originally asked on MSDN here.
    Last edited by Edgemeal; Aug 15th, 2010 at 06:33 PM.

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: Minimize IDE on Code Run (F5)

    I was looking for this and found this also

    1. Please open Macro IDE by menu Tools / Macro / Macro IDE.

    2. In MyMacros project, open EnvironmentEvents file

    3. Add following code:

    Code:
      Private Sub DebuggerEvents_OnEnterDesignMode(ByVal Reason As EnvDTE.dbgEventReason) Handles DebuggerEvents.OnEnterDesignMode
        DTE.MainWindow.WindowState = vsWindowState.vsWindowStateMaximize
      End Sub
    
    
      Private Sub DebuggerEvents_OnEnterRunMode(ByVal Reason As EnvDTE.dbgEventReason) Handles DebuggerEvents.OnEnterRunMode
        DTE.MainWindow.WindowState = vsWindowState.vsWindowStateMinimize
      End Sub

  3. #3
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Minimize IDE on Code Run (F5)

    You may want to modify the OnEnterRunMode method to not minimize when you're stepping through. A simple If statement can handle that.

    Code:
            If Reason = dbgEventReason.dbgEventReasonGo Then
                DTE.MainWindow.WindowState = vsWindowState.vsWindowStateMinimize
            End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width