C#实现窗口任务栏闪烁代码如下

本文介绍了一个使用 C# 进行窗口闪烁的方法。通过调用 user32.dll 中的 FlashWindow 函数,可以实现对指定窗口的手柄进行操作,设置其闪烁状态。此功能常用于提醒用户注意特定的窗口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

引自:http://www.csharpwin.com/csharpspace/9129r2514.shtml

 

using System.Runtime.InteropServices;
--------------------------
[DllImport("user32.dll")]
public static extern bool FlashWindow(
IntPtr hWnd, // handle to window
bool bInvert // flash status
);
----------------------------------
FlashWindow(handle,true);//闪烁

''' ''' Element的方式闪烁图元 ''' ''' 选中图元的geometry ''' 选中图元的geometry类型 ''' 该方式就是先加一个element,然后再将之删除,这种方法经过扩展,还可以用于三维闪烁 Sub FlashGeoByElement(ByVal pActiveView As IActiveView, ByVal pGeo As IGeometry, ByVal pGeoType As esriGeometryType) Dim pElement As IElement = Nothing Dim pColor As IColor = New RgbColor pColor.RGB = RGB(255, 0, 0) Select Case pGeoType Case esriGeometryType.esriGeometryPoint Dim pMarSymbol As IMarkerSymbol = New SimpleMarkerSymbol pMarSymbol.Color = pColor pMarSymbol.Size = 10 pElement = New MarkerElement pElement.Geometry = pGeo CType(pElement, IMarkerElement).Symbol = pMarSymbol Case esriGeometryType.esriGeometryPolyline Dim pLineSymbol As ISimpleLineSymbol = New SimpleLineSymbol pLineSymbol.Color = pColor pLineSymbol.Width = 3 pElement = New LineElement pElement.Geometry = pGeo CType(pElement, ILineElement).Symbol = pLineSymbol Case esriGeometryType.esriGeometryPolygon Dim pSimpleFillSymbol As IFillSymbol = New SimpleFillSymbol pSimpleFillSymbol.Outline.Width = 0 pSimpleFillSymbol.Color = pColor pElement = New PolygonElement pElement.Geometry = pGeo CType(pElement, IFillShapeElement).Symbol = pSimpleFillSymbol End Select Dim pG As IGraphicsContainer = pActiveView If pElement IsNot Nothing Then pG.AddElement(pElement, 0) pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing) pActiveView.ScreenDisplay.UpdateWindow() System.Threading.Thread.Sleep(300) pG.DeleteElement(pElement) pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing) End If End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值