Capturing CommandBar Events in VB Add-Ins Montana

This code sample shows how to capture all the events from your command-bars in a Visual Basic Add-In using only one declared event handler.

Local Companies

Computer Port
406-883-6237
314 First Street East Suite 202
Polson, MT
Fiserv
(406) 443-6198
44 W 6th Ave Ste 100
Helena, MT
Ims Racing
(406) 252-7210
848 Main St
Billings, MT
Design Services
(406) 586-2674
2100 Fairway Dr
Bozeman, MT
Montana Gbs
(406) 541-2323
126 E Broadway St
Missoula, MT
Click Here Designs, LLC
406-883-6237
314 First Street East Suite 202
Polson, MT
Ims
(406) 727-5600
2300 12th Ave S
Great Falls, MT
Mastertrack Software
(406) 538-5800
942 Maiden Rd
Lewistown, MT
Isc Distributors
(406) 586-3105
101 E Mendenhall St
Bozeman, MT
Synesis 7
(406) 496-6400
220 N Alaska St
Butte, MT

provided by: 
Originally published at Internet.com


Author: Toby

It seems like all VBIDE.CommandBarEvents (Visual Basic Command Bar buttons) which you need to catch should be declared separately. For example, if you want to get particular event from Save button. You should do it something like this (And this example returns only one buttons click event):

This is written in VB help files

private withevents ce as CommandBarEvents ' Sub Test() Dim c as CommandBarControl set c = Application.VBE.CommandBars("Menu Bar").Controls(2) set ce = Application.VBE.Events.CommandBarEvents(c) End Sub ' private Sub ce_Click(byval CommandBarControl as Object, Handled as Boolean, CancelDefault as Boolean) ' Put event-handling code here End Sub '

So I made simple class for hooking these events. This class captures the events for every buttons click event.

How this works

This class ctlCmdEvent can act both as ParentClass and ChildClass.

SetEvents method collects all CommandBarControls and creates a new ChildClass for each control. This ChildClass is able to get its control event (Click). ChildClass directs the event back to ParentClass which rises event back to the first user object.
...

Read article at Internet.com site

Featured Local Company

Click Here Designs, LLC

406-883-6237
314 First Street East Suite 202
Polson, MT
http://www.clickheredesigns.com/

Click Here Designs, LLC has been creating professional websites from Polson since 1997. Our extensive portfolio is available on our website. We offer complete web development services, including search engine optimization, web site maintenance, and complete webmaster services. When in doubtClick Here.

Related Articles
- Interacting with .NET WinForms, Part 2 Montana
We conclude our tutorial on working with Windows Forms in Microsoft.NET. Here, we'll examine some of the important GUI Controls and their application in C#.
- JavaBean Proxies Montana
- QueryDef - a complete implementation of a dynamic recordset Montana
- Interacting with .NET WinForms, Part 1 Montana
Related Articles
- Interacting with .NET WinForms, Part 2 Montana
We conclude our tutorial on working with Windows Forms in Microsoft.NET. Here, we'll examine some of the important GUI Controls and their application in C#.
- JavaBean Proxies Montana
- QueryDef - a complete implementation of a dynamic recordset Montana
- Interacting with .NET WinForms, Part 1 Montana

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML