在系統彈出對話方塊中往往帶有Information、Question、Warnning、Error等系統表徵圖,由於這些表徵圖是系統內建的,所以可以為我們自己程式所用。
System.Drawing命名空間中有一個SystemIcons類,以靜態屬性方式提供了使用系統表徵圖的便捷途徑:
Public Properties
|
Name |
Description |
|
Application |
Gets an Icon object that contains the default application icon (WIN32: IDI_APPLICATION). |
|
Asterisk |
Gets an Icon object that contains the system asterisk icon (WIN32: IDI_ASTERISK). |
|
Error |
Gets an Icon object that contains the system error icon (WIN32: IDI_ERROR). |
|
Exclamation |
Gets an Icon object that contains the system exclamation icon (WIN32: IDI_EXCLAMATION). |
|
Hand |
Gets an Icon object that contains the system hand icon (WIN32: IDI_HAND). |
|
Information |
Gets an Icon object that contains the system information icon (WIN32: IDI_INFORMATION). |
|
Question |
Gets an Icon object that contains the system question icon (WIN32: IDI_QUESTION). |
|
Warning |
Gets an Icon object that contains the system warning icon (WIN32: IDI_WARNING). |
|
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));