pub fn bind_event_handler<F>(handle: &ControlHandle, parent_handle: &ControlHandle, f: F) -> EventHandler
    where F: Fn(Event, EventData, ControlHandle) -> () + 'static
{
    let hwnd = handle.hwnd().expect("Cannot bind control with an handle of type");
    let parent_hwnd = parent_handle.hwnd().expect("Cannot bind control with an handle of type");
    
    let callback: Rc<Callback> = Rc::new(f);
    let parent_callback = callback.clone();

    let callback_box: Box<*const Callback> = Box::new(Rc::into_raw(callback));
    let callback_box_parent: Box<*const Callback> = Box::new(Rc::into_raw(parent_callback));

    let callback_ptr: *mut *const Callback = Box::into_raw(callback_box);
    let callback_ptr_parent: *mut *const Callback = Box::into_raw(callback_box_parent);

    let callback_fn: SUBCLASSPROC = Some(process_events);
    let subclass_id = EVENT_HANDLER_ID.fetch_add(1, Ordering::SeqCst);
    let handler = EventHandler {
        handles: vec![hwnd, parent_hwnd],
        id: callback_fn,
        subclass_id,
    };

    unsafe {
        SetWindowSubclass(hwnd, callback_fn, subclass_id, callback_ptr as UINT_PTR);
        SetWindowSubclass(parent_hwnd, callback_fn, subclass_id, callback_ptr_parent as UINT_PTR);
    }

    handler
}
/**
Hook the window subclass with the default event dispatcher.
The hook is applied to the control and its parent. All common controls send their events to their parent.

Arguments:
    - handle: Handle to the main control to hook
    - parent_handle: Parent to the main control.
    - f: User event callback

Returns a `EventHandler` that can be passed to `unbind_event_handler` to remove the callbacks.

*/
Hook the window subclass with the default event dispatcher.
The hook is applied to the control and its parent. All common controls send their events to their parent.

Handle to the main control to hook
parent_handle: Parent to the main control.
f: User event callback

Returns a `EventHandler` that can be passed to `unbind_event_handler` to remove the callbacks.
Hook the window subclass with the default event dispatcher . The hook is applied to the control and its parent . All common controls send their events to their parent . Handle to the main control to hook parent_handle : Parent to the main control . f : User event callback Returns a ` EventHandler ` that can be passed to ` unbind_event_handler ` to remove the callbacks .
pub fn bind_event_handler<F>(handle: &ControlHandle, parent_handle: &ControlHandle, f: F) -> EventHandler
    where F: Fn(Event, EventData, ControlHandle) -> () + 'static
{
    let hwnd = handle.hwnd().expect("Cannot bind control with an handle of type");
    let parent_hwnd = parent_handle.hwnd().expect("Cannot bind control with an handle of type");
    let callback: Rc<Callback> = Rc::new(f);
    let parent_callback = callback.clone();
    let callback_box: Box<*const Callback> = Box::new(Rc::into_raw(callback));
    let callback_box_parent: Box<*const Callback> = Box::new(Rc::into_raw(parent_callback));
    let callback_ptr: *mut *const Callback = Box::into_raw(callback_box);
    let callback_ptr_parent: *mut *const Callback = Box::into_raw(callback_box_parent);
    let callback_fn: SUBCLASSPROC = Some(process_events);
    let subclass_id = EVENT_HANDLER_ID.fetch_add(1, Ordering::SeqCst);
    let handler = EventHandler {
        handles: vec![hwnd, parent_hwnd],
        id: callback_fn,
        subclass_id,
    };
    unsafe {
        SetWindowSubclass(hwnd, callback_fn, subclass_id, callback_ptr as UINT_PTR);
        SetWindowSubclass(parent_hwnd, callback_fn, subclass_id, callback_ptr_parent as UINT_PTR);
    }
    handler
}
pub fn bind_event_handler < F > ( handle : & ControlHandle , parent_handle : & ControlHandle , f : F ) -> EventHandler where F : Fn ( Event , EventData , ControlHandle ) -> ( ) + ' static { let hwnd = handle . hwnd ( ) . expect ( " " ) ; let parent_hwnd = parent_handle . hwnd ( ) . expect ( " " ) ; let callback : Rc < Callback > = Rc :: new ( f ) ; let parent_callback = callback . clone ( ) ; let callback_box : Box < * const Callback > = Box :: new ( Rc :: into_raw ( callback ) ) ; let callback_box_parent : Box < * const Callback > = Box :: new ( Rc :: into_raw ( parent_callback ) ) ; let callback_ptr : * mut * const Callback = Box :: into_raw ( callback_box ) ; let callback_ptr_parent : * mut * const Callback = Box :: into_raw ( callback_box_parent ) ; let callback_fn : SUBCLASSPROC = Some ( process_events ) ; let subclass_id = EVENT_HANDLER_ID . fetch_add ( 1 , Ordering :: SeqCst ) ; let handler = EventHandler { handles : vec ! [ hwnd parent_hwnd ] , id : callback_fn , subclass_id , } ; unsafe { SetWindowSubclass ( hwnd , callback_fn , subclass_id , callback_ptr as UINT_PTR ) ; SetWindowSubclass ( parent_hwnd , callback_fn , subclass_id , callback_ptr_parent as UINT_PTR ) ; } handler }
Hook the window subclass with the default event dispatcher.
Hook the window subclass with the default event dispatcher .
handle
&ControlHandle
parent_handle
&ControlHandle
f
F