// find a window with title "Untitled"
let mut hw: Option<HWND> = None;
EnumWindows(|hwnd: HWND| -> bool {
let text = hwnd.GetWindowText().unwrap();
if text == "" || text == "Default IME" || text == "MSCTFIME UI" {
return true;
}
if text == "Untitled" {
let h = unsafe { hwnd.raw_copy() };
hw = Some(h)
}
println!("HWND: {}, {}", hwnd, text);
true
})
.unwrap();
which errors with cannot assign to `hw`, as it is a captured variable in a `Fn` closure
(I did patch winsafe for that to work)
Is it safe to use FnMut as a callback here?
If yes, can EnumWindows be defined with FnMut callback?
If it can, should it be?
I'm trying to do something like
which errors with
cannot assign to `hw`, as it is a captured variable in a `Fn` closure
(I did patchwinsafe
for that to work)Is it safe to use
FnMut
as a callback here? If yes, canEnumWindows
be defined withFnMut
callback? If it can, should it be?