Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / January 2007

Tip: Looking for answers? Try searching our database.

add-in window placement?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike M - 18 Jan 2007 04:01 GMT
In VC6 this macro worked;

sub Application_DocumentOpen(theDocument)
theDocument.ActiveWindow.Height = 1000
theDocument.ActiveWindow.Width = 680
theDocument.ActiveWindow.top = 0
theDocument.ActiveWindow.left = 0
end sub

Now I'm trying to do the same thing in VS2005 with;

Public Class EventsClass
    Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
    Private Sub DocumentOpened(ByVal Document As EnvDTE.Document)
Handles DocumentEvents.DocumentOpened
        'MsgBox("Hello")
        Document.ActiveWindow.Top = 0
        Document.ActiveWindow.Left = 0
    End Sub

End Class

I get the event registered ok (confirmed with the Hello msg) but the
window is placed at the usual cascaded placement (not using tabs).

What am I missing?

Thanks,
Mike
Mike M - 20 Jan 2007 19:54 GMT
I'll elaborate a little.

As an exercise in learning a little VS2005 add-in coding, I'm trying to
port some of the macro/add-in's I was  using in Visual Studio 6.0 (yes,
that's the last MS compiler I've used till recently buying VS2005).

As an 'ole c++ slinger one I've always liked is having the ability to
issue a Ctrl-key to switch between .h and .cpp files (I also prefer
using the keyboard rather than the mouse when ever possible). So I got
that one working in a VS2005 VB add-in prettily quickly, though I am
using the Documents.open method which is verboten according to the Help.
I'm wondering if it may cause problems biut so far so good.

The other macro I liked in VC6 was one that would open the .h files on
the left and the .cpp's on the right. The one I included in the previous
post with

sub Application_DocumentOpen(theDocument)
theDocument.ActiveWindow.top = 0
theDocument.ActiveWindow.left = 0

So now in VS2005 I have 2 choices, either use the tabbed documents or
multiple documents. I like the tabs ok, but I'd like to control which
tab a doc is opened into (without having to 1st select the desired tab
by clicking on it). I'd like open the .h on the left tab group and the
.cpp on the right tab group. That is assuming I have two vertical tab
groups.

I see no mention of anything about the document tabs/groups in the
add-in apis. Am I missing it? Short of that then that leaves me with
using "Multiple documents" instead of "Tabbed Documents" and trying to
get an add-in to place .h's on the left and .cpp's on the right.

So my first stab at it looks like this;

Public Sub OnConnection(...
[snip]
        objEventsClass = New EventsClass()
        objEventsClass.DocumentEvents =
_applicationObject.Events.DocumentEvents
End Sub
Public Class EventsClass
    Dim _applicationObject As DTE2
    Public Sub New()
    End Sub
    Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
    Private Sub DocumentEvents_DocumentOpened(ByVal Document As
EnvDTE.Document)     Handles DocumentEvents.DocumentOpened
        MsgBox("Opened")
        Document.ActiveWindow.Height = 100
        Document.ActiveWindow.Top = 0
End Sub

So as I said in the previous post when I dblclick on a .h or .cpp file
in a project the MsgBox is invoked but my Height & Top assignments are
seemingly ignored.

I suppose since the Document is passed to the event handler ByVal I'm
not going to be able to change it's height/top this way.

Is there any way to do this? Is there another way to get write access to
the Document.ActiveWindow.Height/Top/Width/Left properties in the
DocumentOpened or WindowCreated events? Or is there some other way to do
this? Is there some other way to get a handle on the Document which
would allow write access?

One last question. I've been working through the Help examples in VB.
Then I tried creating an C++ addin with the addin wizard. How do you
regeister event handlers in C++? I see no examples of it. And I see no
api's that look like a c++ register event handler. The 1st c++ addin I
created was a CLR. I'll be trying out a C++ ATL addin next.

First thing I started typing was the what I thought would be the c++
equivalent to what I had in VB;
Public Sub OnConnection(...
VB: objEventsClass.DocumentEvents = _applicationObject.Events.DocumentEvents

C++:
Void MyAddin::Connect::OnConnection(...
_events = gcnew EventsClass();
_events->_DocumentEvents =    _applicationObject->Events->DocumentEvents;

but that doesn't even compile and once I thought about it doesn't make
sense in C++ afaik.

So, I appreciate any clues anyone has to offer. Thanks,
Mike

> In VC6 this macro worked;
>
[quoted text clipped - 25 lines]
> Thanks,
> Mike

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.