我无法在D:
的任何地方找到这个看似简单问题的答案我想检测窗体/窗口是否已被聚焦,以便我只能闪烁窗口如果没有聚焦,这里是代码的一部分:
If Me.Focused = False Then ' Doesn't work D: please fix
Dim flash As New FLASHWINFO
flash.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash) '/// size of structure in bytes
flash.hwnd = MyBase.Handle '/// Handle to the window to be flashed
flash.dwFlags = FLASHW_ALL '/// to flash both the caption bar + the tray
flash.uCount = 5 '/// the number of flashes
flash.dwTimeout = 1000 '/// speed of flashes in MilliSeconds ( can be left out )
'/// flash the window you have specified the handle for...
FlashWindowEx(flash)
End If
有一种简单的方法可以使这项工作吗?
答案 0 :(得分:0)
Private Sub Form1_LostFocus(sender As Object, e As System.EventArgs) Handles Me.LostFocus
Dim flash As New FLASHWINFO
flash.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash) '/// size of structure in bytes
flash.hwnd = MyBase.Handle '/// Handle to the window to be flashed
flash.dwFlags = FLASHW_ALL '/// to flash both the caption bar + the tray
flash.uCount = 5 '/// the number of flashes
flash.dwTimeout = 1000 '/// speed of flashes in MilliSeconds ( can be left out )
'/// flash the window you have specified the handle for...
FlashWindowEx(flash)
End Sub