2009-06-14 77 views

回答

4

這是通過使用Vista DWM(桌面窗口管理器)API進行互操作完成的。

例如,導入這些功能:

[DllImport("dwmapi.dll")] 
static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMargins); 


[StructLayout(LayoutKind.Sequential)] 
struct Margins 
{ 
    public int cxLeftWidth; 
    public int cxRightWidth; 
    public int cyTopHeight; 
    public int cyBottomHeight; 
} 

然後你就可以使用這個從窗口頂部的「拆」玻璃下到客戶區:

GlassMargins.Top = 40; 
GlassMargins.Left = 0; 
GlassMargins.Right = 0; 
GlassMargins.Bottom = 0; 

DwmExtendFrameIntoClientArea(this.Handle, ref GlassMargins); 

從這裏,您可以繼續做其他事情,比如在玻璃上繪製文本或圖像,或者將控件放在上面,比如Office 2007風格的應用程序按鈕。

2

使用DWM合成Vista Aero中的玻璃窗口邊界。這是一個OS級功能。如果您在Vista上運行應用程序,則應該免費獲得玻璃邊框。

如果你想擴展玻璃效果到客戶區,使用DwmExtendFrameIntoClientArea,這是Internet Explorer中是如何做的它的工具欄中即可。我懷疑你必須編寫互操作來自己調用這個本地函數(或者檢查http://pinvoke.net)。