Is there any way to find out if a given window in Windows 7/10 is in the "expanding" or "minimizing" state?
The bottom line is that if desktop effects are turned on (Aero in Windows 7), windows have a certain animation when minimized and maximized. However, if you click on the minimized window in the task bar and immediately call IsWindowVisible()
on this window, Win32API will tell us that the window is already open, but in fact it will be visible only after N milliseconds (when the deployment animation ends).
I tried to find an API that would allow to learn about such things, but, unfortunately, I did not find solutions.
PS: I know that you can put global hooks
(and write DLL-ku, which put handlers
) on such actions
, but this is too heavy and inelegant hack work.
UPD. Unfortunately, I did not find a complete solution to the original problem. So at the moment I just use workaround - for the necessary time I turn off animation effects (and only them), creating a temporary object that restores animations on the destructor (if they were previously enabled by the user).
pub struct AnimationDisabler { info: ANIMATIONINFO, } pub fn disable_animation() -> Option<AnimationDisabler> { let mut animation_info = ANIMATIONINFO { cbSize: mem::size_of::<ANIMATIONINFO>() as UINT, iMinAnimate: 0 }; unsafe { SystemParametersInfoW(SPI_GETANIMATION, mem::size_of::<ANIMATIONINFO>() as UINT, &mut animation_info as LPANIMATIONINFO as LPVOID, 0) }; // Animation is disabled already if animation_info.iMinAnimate == 0 { return None } let mut animation_disabled = ANIMATIONINFO { cbSize: mem::size_of::<ANIMATIONINFO>() as UINT, iMinAnimate: 0 }; unsafe { SystemParametersInfoW(SPI_SETANIMATION, mem::size_of::<ANIMATIONINFO>() as UINT, &mut animation_disabled as LPANIMATIONINFO as LPVOID, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE) }; return Some(AnimationDisabler { info: animation_info }); } impl Drop for AnimationDisabler { fn drop(&mut self) { unsafe { SystemParametersInfoW(SPI_SETANIMATION, mem::size_of::<ANIMATIONINFO>() as UINT, &mut self.info as LPANIMATIONINFO as LPVOID, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE) }; } }