none
custom event RRS feed

All replies

  • Hi,
    What are your trying to do or what do you mean by custom?

    If you are trying to fire a custom event in your custom control, assuming this wpf, then you can include a RaiseEvent in
    your Provider member method to raise the custom event.

    An example,
    In this example the custom control's AutomationPeer inherits from is IInvokeProvider. For this provider you are
    required to implement an Invoke method. So in the AutomationPeer I have a method,

    public void Invoke()
    
            {
    
                RoutedEventArgs newEventArgs = new RoutedEventArgs(CustomControl.CustomEvent);
    
    
    
                MyOwner.RaiseEvent(newEventArgs);
    
            }
    
    
    If you want to execute some custom code based on a uia event then you could,

    Declare a new AutomationEventHandler passing in the method you want to execute. The use Automation.AddAutomationEventHandler 
    passing in your new eventhandler. This may be applied to a varied element scope. For example all nodes in a treeview.

    AutomationEventHandler CustomEventHandler = new AutomationEventHandler(OnEventRaised);
    
            
    
    //add pattern.event example
    
    Automation.AddAutomationEventHandler(InvokePattern.InvokedEvent, aUIAElement, 
    TreeScope.Element, CustomEventHandler); //add UIAElement.event example Automation.AddAutomationEventHandler(AutomationElement.MenuOpenedEvent,
    AutomationElement.RootElement, TreeScope.Descendants, CustomEventHandler); public void OnEventRaised(object element, AutomationEventArgs args)
    { AutomationElement _element = element as AutomationElement; //do whatever you like }
    Hopefully this helps, but if it is not what you asking then providing an example scenario may help
    Wednesday, April 8, 2009 11:57 AM
  • Hi,

    I write a serverside provider for a third-party grid.
    for this i had encapsulate this control in a atl-compositecontrol.

    now i've "access" (over my atl control) to the code of the third-party.
    i catch a event named "BeforeRowColChange" witch is raised before the active cell in the grid changed.
    now i want want to raise a event named like "HeyTheActiveCellCahnged" with some argument like the current row and column.
    How can ich rais such an event. Oh i don't use wpf i use win32 atl.

    thanks
    Wednesday, April 8, 2009 12:33 PM
  • As you're using ATL, you're aware that UIAutomation requires at least .NET 3.0 framework? If you are not deploying the .NET framework or do not expect users to have it installed then you may want to go down the MSAA route instead, which use IAccessible.

    Wednesday, April 8, 2009 1:37 PM
  • hi

    yes i'm using atl and it works fine.

    Wednesday, April 8, 2009 1:44 PM
  • Hi

    so how can i raise a custom event ?
    Tuesday, April 14, 2009 7:20 AM
  • You are wanting to raise a an event witihn a custom control. So as per my first reply you need to implement either,

     - a UIA server provider, if you have access to the source code of your custom control. So for a grid look at at IGridProvider, IGridItemProvider & if you want to manipulate the grid, ITransformProvider 
    http://msdn.microsoft.com/en-us/library/system.windows.automation.provider.igridprovider.aspx

     - a client-side UIA provider, if you do not have access to the custom controls source code.
    http://msdn.microsoft.com/en-us/library/ms753274.aspx
    Tuesday, April 14, 2009 10:34 AM