pub fn bind_raw_event_handler<F>(
handle: &ControlHandle,
handler_id: UINT_PTR,
f: F,
) -> Result<RawEventHandler, NwgError>Expand description
Set a window subclass the uses the process_raw_events function of NWG.
The subclass is only applied to the control itself and NOT the children.
When assigning multiple callback to the same control, a different id must be specified for each call
or otherwise, the old callback will be replaced by the new one. See Label::hook_background_color for example.
Error:
- If the event handler with the same ID is already bound, this function will return an Error. The
has_raw_handlermethod can be used to check this.
Panic:
- If the
handleparameter is not a window-like control - If the
handler_idparameter is <= 0xFFFF
use native_windows_gui as nwg;
fn bind_raw_handler(window: &nwg::Window) -> nwg::RawEventHandler {
const WM_MOVE: u32 = 3287542; // Not the actual value, but who cares?
let handler_id = 0x10000; // handler ids equal or smaller than 0xFFFF are reserved by NWG
nwg::bind_raw_event_handler(&window.handle, handler_id, move |_hwnd, msg, _w, _l| {
if msg == WM_MOVE {
println!("MOVING!");
}
None
}).unwrap()
}