Geographic Information Systems Asked by Pilgrim on February 15, 2021
I’m implementing the interfaz ICustomizationFilter, and using the event ‘OnCustomizationEvent’ of this way:
public sealed partial class eManager : Extension, ICustomizationFilter
{
public bool OnCustomizationEvent(esriCustomizationEvent custEventType, object comObject)
{
Debug.Write("------------> cust event type:" + custEventType);
if (custEventType == esriCustomizationEvent.esriCEInvokeCommand)
{
if (comObject.ToString() != "Toolbar")
{
if (comObject as ICommandItem != null)
{
ICommandItem loButton = (ICommandItem)comObject;
MessageBox.Show("button: " + loButton.Name);
}
else if (comObject as ICommandBar != null)
{
ICommandBar loToolbar = (ICommandBar)comObject;
MessageBox.Show("bar: " + loToolbar.ToString());
}
else
{
MessageBox.Show("Error casting comObject");
return true;
}
}
}
return false;
}
}
I need get the id or name of toolbar added.
The event is firing, but I can’t cast the comObject when it’s a toolbar. It Only
cast when a button fires the event.
How can I get the toolbar’s data when it fires the event?
This is a partial answer, in that I have not use this method for toolbars but for esris commands (buttons). Each ESRI command and toolbar has a unique name and UID Rather than trying to use the comObject, find the command name and PUID I am using the ICustomizationfilter to intercept a user click. Along the way I can get the command_name and UID. In VB.Net
If custEventType = ESRI.ArcGIS.Framework.esriCustomizationEvent.esriCEInvokeCommand Then
' My reading is that esriCEInvokeCommand always has eventCtx as a command item
If TypeOf eventCtx Is ICommandItem Then
Dim pCommandItem As ICommandItem
Dim CommandName As String
Dim pUID As UID
' get the command item, its name and UID
pCommandItem = TryCast(eventCtx, ESRI.ArcGIS.Framework.ICommandItem)
' test for nothing if you want
CommandName = pCommandItem.Name
pUID = pCommandItem.ID
Also check out the use of the ICommandBars interface with the find method. This is an old link but may give you a start. ICommandBars Interface
Answered by TazAstroSpacial on February 15, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP