Page 1 of 1

Trap window on which the event got fired -in case of common

Posted: Mon Feb 14, 2005 10:58
by krithigal
I am using a common event handler for a set of listboxes for onselectionchanged event. If I need to identify the listbox for which this event got fired from the eventhandler funtion using EventArgs, how do I do it.



Pl let me know with a code snippet.

Your help will be appreciated.
thanks in advance
krithiga

Re: Trap window on which the event got fired -in case of co

Posted: Mon Feb 14, 2005 12:39
by CrazyEddie
cast the args to a WindowEventArgs and look at the window field (casting to Listbox if required).

Code: Select all

bool myHandler(const EventArgs& args)
{
    Window* wnd = static_cast<const WindowEventArgs&>(args).window;

    Listbox* listbox = static_cast<Listbox*>(wnd);

    // Do something useful...
}


There was a post a few days ago about casting the args object passed to event handlers.

CE.