2013-05-05 113 views

回答

0

我不認爲WPF提供了一種僅禁用最小化按鈕。你可以做的是禁用完整的標題欄併爲自己創建一個自定義標題欄。檢查this了。

6

您可能需要在這裏使用PInvoke。基本上你要導入調用SetWindowLong和GetWindowLong功能,並設置相應的標誌來贏得API窗口中使用它的句柄(HWND)

private const int GWL_STYLE = -16; 
private const int WS_MINIMIZE = -131073; 
[DllImport("user32.dll", SetLastError = true)] 
private static extern int GetWindowLong(IntPtr hWnd, int nIndex); 
[DllImport("user32.dll")] 
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); 

private static void CanMinimize(Window w) 
{ 
    var hwnd = new WindowInteropHelper(w).Handle; 
    long value = GetWindowLong(hwnd, GWL_STYLE); 
    SetWindowLong(hwnd, GWL_STYLE, (int)(value & ~WS_MINIMIZE)); 
} 
相關問題