He,YuanHui —— 业精于勤荒于嬉,行成于思毁于随

如果你喜欢一个事,又有这样的才干,那就把整个人都投入进去,就要象一把刀直扎下去直到刀柄一样,不要问为什么,也不要管会碰到什么。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在系统弹出对话框中往往带有Information、Question、Warnning、Error等系统图标,由于这些图标是系统自带的,所以可以为我们自己程序所用。

System.Drawing命名空间中有一个SystemIcons类,以静态属性方式提供了使用系统图标的便捷途径:

Public Properties

  Name Description
Public property Static Application Gets an Icon object that contains the default application icon (WIN32: IDI_APPLICATION).
Public property Static Asterisk Gets an Icon object that contains the system asterisk icon (WIN32: IDI_ASTERISK).
Public property Static Error Gets an Icon object that contains the system error icon (WIN32: IDI_ERROR).
Public property Static Exclamation Gets an Icon object that contains the system exclamation icon (WIN32: IDI_EXCLAMATION).
Public property Static Hand Gets an Icon object that contains the system hand icon (WIN32: IDI_HAND).
Public property Static Information Gets an Icon object that contains the system information icon (WIN32: IDI_INFORMATION).
Public property Static Question Gets an Icon object that contains the system question icon (WIN32: IDI_QUESTION).
Public property Static Warning Gets an Icon object that contains the system warning icon (WIN32: IDI_WARNING).
Public property Static WinLogo Gets an Icon object that contains the Windows logo icon (WIN32: IDI_WINLOGO).

 

需要注意的是,它是属于System.Drawing命名空间的,就是说它是GDI+的函数。

要在WPF中使用系统图标也是一件非常困难的事,微软提供了WPF的矢量绘图系统,可是它与传统的GDI、GDI+之间的转换并不是很全面和便利,要为WPF中的Image控件的Source指定图片数据源,你需要使用System.Windows.Interop下的Imaging来做转换:

Icon icon = System.Drawing.SystemIcons.Information;

BitmapSource source1 = Imaging.CreateBitmapSourceFromHIcon(icon.Handle,new Int32Rect(0,0,32,32), BitmapSizeOptions.FromWidth(32));

 

 

posted on 2008-09-16 21:46  He,YuanHui  阅读(3417)  评论(0编辑  收藏  举报

Add to Google