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