Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add In

Posted on 1998-07-15
3
Medium Priority
?
350 Views
Last Modified: 2008-02-01
I would like to be able to enable and disable commandbar controls based on which window in the VB IDE is active (i.e. the codepane window) but I don't know of any objects which 'listen' for these events.
0
Comment
Question by:markmcc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
tomook earned 300 total points
ID: 1465811
VB5 Add-Ins can do what you want. I assume you can create an Add-In from the New Project menu. Assuming you use the default template, go to the class "Connection" and put these two lines in the Declarations section:

Public WithEvents mVBComponentEvents As VBComponentsEvents
Public WithEvents mVBProjEvents As VBProjectsEvents

Near the top of IDTExtensibility_OnConnection, after the line
    Set VBInstance = VBInst
add:
    Set mVBProjEvents = VBInstance.Events.VBProjectsEvents
    If Not (VBInstance.ActiveVBProject Is Nothing) Then
        Set mVBComponentEvents = VBInstance.Events.VBComponentsEvents(VBInstance.ActiveVBProject)
    End If

Then add the following event handlers:
Private Sub mVBComponentEvents_ItemActivated(ByVal VBComponent As VBIDE.VBComponent)
    ' This is probably where you want to do your command bar manipulations.
    ' Check out the CommandBars property of the variable VBInstance.
    MsgBox "Activated component " & VBComponent.Name
End Sub

Private Sub mVBComponentEvents_ItemAdded(ByVal VBComponent As VBIDE.VBComponent)
    MsgBox "Added component " & VBComponent.Name
End Sub

Private Sub mVBComponentEvents_ItemReloaded(ByVal VBComponent As VBIDE.VBComponent)
    MsgBox "Reloaded component " & VBComponent.Name
End Sub

Private Sub mVBComponentEvents_ItemRemoved(ByVal VBComponent As VBIDE.VBComponent)
    MsgBox "Removed component " & VBComponent.Name
End Sub

Private Sub mVBComponentEvents_ItemRenamed(ByVal VBComponent As VBIDE.VBComponent, ByVal OldName As String)
    MsgBox "Renamed component " & OldName & " to " & VBComponent.Name
End Sub

Private Sub mVBComponentEvents_ItemSelected(ByVal VBComponent As VBIDE.VBComponent)
    MsgBox "Selected component " & VBComponent.Name
End Sub

Private Sub mVBProjEvents_ItemActivated(ByVal VBProject As VBIDE.VBProject)
    Set mVBComponentEvents = VBInstance.Events.VBComponentsEvents(VBProject)
End Sub

Private Sub mVBProjEvents_ItemAdded(ByVal VBProject As VBIDE.VBProject)
    Set mVBComponentEvents = VBInstance.Events.VBComponentsEvents(VBProject)
End Sub

Private Sub mVBProjEvents_ItemRemoved(ByVal VBProject As VBIDE.VBProject)
    Set mVBComponentEvents = VBInstance.Events.VBComponentsEvents(VBProject)
End Sub

Private Sub mVBProjEvents_ItemRenamed(ByVal VBProject As VBIDE.VBProject, ByVal OldName As String)
    Set mVBComponentEvents = VBInstance.Events.VBComponentsEvents(VBProject)
End Sub

The code here just pops up message boxes, but you can just as well manipulate command bars.
0
 

Author Comment

by:markmcc
ID: 1465812
I wanted to know which windows (codepane, property, toolbar, immediate, etc.) in the VB IDE was active not the components (forms, modules, classes etc).  I've found out that VB doesn't provide hooks in these events.  One way to do this, however, is to place a timer control on a form and use the ActiveWindow property of the VBE object.
0
 
LVL 4

Expert Comment

by:tomook
ID: 1465813
It looks like the VB team did not think anyone would want to know that. Good luck. Do you mind my asking what this is for?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question