Solved

Add In

Posted on 1998-07-15
3
330 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 100 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 101
Microsoft Access combo box help 2 57
Exit a vb6 apps when a calling it apps closes 15 61
VB6 - Convert HH:MM into Decimal 8 75
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 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