Locked Set working area, anyone please?

All Replies

  • Wednesday, January 17, 2007 2:37 PM
    Moderator
     
     Answered

    The following is a macro that uses the environment event "OnSTartupCompleted" to set the screen location...this sample sets the main VS window to the bounds of the primary screen...you can set MyScreen to which ever screen you want



    Option
    Strict Off
    Option
    Explicit Off
    Imports
    System

    Imports EnvDTE

    Imports EnvDTE80

    Imports System.Diagnostics

    Imports System.Windows.forms

    Imports System.Drawing

    Public Module EnvironmentEvents
    #
    Region "Automatically generated code, do not modify"

    'Automatically generated code, do not modify
    'Event Sources Begin

    <System.ContextStaticAttribute()> Public WithEvents DTEEvents As EnvDTE.DTEEvents
    <System.ContextStaticAttribute()>
    Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
    <System.ContextStaticAttribute()>
    Public WithEvents WindowEvents As EnvDTE.WindowEvents
    <System.ContextStaticAttribute()>
    Public WithEvents TaskListEvents As EnvDTE.TaskListEvents
    <System.ContextStaticAttribute()>
    Public WithEvents FindEvents As EnvDTE.FindEvents
    <System.ContextStaticAttribute()>
    Public WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents
    <System.ContextStaticAttribute()>
    Public WithEvents SelectionEvents As EnvDTE.SelectionEvents
    <System.ContextStaticAttribute()>
    Public WithEvents SolutionItemsEvents As EnvDTE.ProjectItemsEvents
    <System.ContextStaticAttribute()>
    Public WithEvents MiscFilesEvents As EnvDTE.ProjectItemsEvents
    <System.ContextStaticAttribute()>
    Public WithEvents DebuggerEvents As EnvDTE.DebuggerEvents

    'Event Sources End
    'End of automatically generated code

    #End Region

    Public Sub SetScreen()
    Dim MyScreen As Screen = Screen.PrimaryScreen
    Dim rect As Rectangle = MyScreen.Bounds
    DTE.MainWindow.Left = rect.Left
    DTE.MainWindow.Top = rect.Top

    DTE.MainWindow.Height = rect.Height
    DTE.MainWindow.Width = rect.Width

    End Sub


    Private Sub DTEEvents_OnStartupComplete() Handles DTEEvents.OnStartupComplete
    SetScreen()
    End Sub
    End
    Module

     

  • Friday, July 20, 2012 3:13 PM
     
      Has Code

    Hi, I came accross this thread while looking around, and tried out the code, however the interpreter gives me the error: "Reference to a non-shared member requires an object reference.", at the lines:

            DTE.MainWindow.Left = rect.Left
            DTE.MainWindow.Top = rect.Top
            DTE.MainWindow.Height = rect.Height
            DTE.MainWindow.Width = rect.Width

    The section "DTE.MainWin" on each line is highlited as having the error.

    Any help?

    Thanks
    Aaron


    • Edited by AaronMcH Friday, July 20, 2012 3:14 PM
    •  
  • Friday, July 20, 2012 8:10 PM
     
     

    I don't know where you execute your code. The code you're referring to is meant to be executed as a macro. There it should work because DTE is declared as 

       Public DTE As EnvDTE80.DTE2

    inside the module MyMacros._ApplicationObjects


    Armin

  • Sunday, July 22, 2012 3:41 PM
     
     

    Hi, thanks for the reply.

    I'm just excicuting it in a form of it's own to test it.  Not sure how the proper way to implement this code would be.

    Thanks
    Aaron

  • Sunday, July 22, 2012 4:18 PM
     
     
    Outside a macro, which develoment environment do you want to refer to if your Form runs on a client's machine?

    Armin

  • Sunday, July 22, 2012 7:18 PM
     
     
    I'm using Visual Studio 2010
  • Sunday, July 22, 2012 7:48 PM
     
     
    I'm using Visual Studio 2010

    LOL  :-) yes, thanks, but I didn't meant which version. What I wanted to say: If there is no VS installed (no matter which version) or not running on the machine on which the app is running, which development environment do you want to refer to? I mean the process you see in the task manager as devenv.exe.

    You are just referring to DTE as if there was a DTE. What if not? You must first declare a variable of that type, then assign something, then you can use it. That something is an instance of the develoment environment. To use it via automation call CreateObject. I do not elaborate on this yet as I'm not sure if you even want this.

    Or you must write a macro in which DTE is already declared (as stated in my first message) because it refers to the running instance of the IDE in which the macro code is running.


    Armin


  • Sunday, July 22, 2012 7:51 PM