gpt4 book ai didi

c# - showdialog 重新聚焦效果自定义调用

转载 作者:行者123 更新时间:2023-11-30 22:28:07 29 4
gpt4 key购买 nike

有没有办法让窗体闪烁,就像失去焦点时的 ShowDialog?

当您在 Windows 窗体上调用 ShowDialog 并尝试另一个操作时,窗体会闪烁几秒钟然后聚焦。

有没有办法以自定义方式调用闪烁 Action ?

最佳答案

试试这个。

    [DllImport("user32.dll")]
private static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);

[StructLayout(LayoutKind.Sequential)]
private struct FLASHWINFO {
public UInt32 cbSize;
public IntPtr hwnd;
public FLASHW dwFlags;
public UInt32 uCount;
public Int32 dwTimeout;
}

[Flags]
private enum FLASHW: int {
// stop flashing
FLASHW_STOP = 0x00,
// flash the window title
FLASHW_CAPTION = 0x01,
// flash the taskbar button
FLASHW_TRAY = 0x02,
// flash the window title and the taskbar button
FLASHW_ALL = 0x03,
// flash continuously
FLASHW_TIMER = 0x04,
// flash until the window comes to the foreground
FLASHW_TIMERNOFG = 0x0c,
}

public static void FlashWindow(IWin32Window form, int count) {
FLASHWINFO pwfi = new FLASHWINFO();
pwfi.cbSize = (uint)Marshal.SizeOf(pwfi);
pwfi.dwFlags = FLASHW.FLASHW_ALL;
pwfi.dwTimeout = 0;
pwfi.hwnd = form.Handle;
pwfi.uCount = (uint)count;
FlashWindowEx(ref pwfi);
}

根据您的需要扩展它。

关于c# - showdialog 重新聚焦效果自定义调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10938899/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com