2012-07-03 41 views

回答

3

那篇文章的評論:

的SaveFileDialogWithEncoding例子是巨大的。但是,外觀和感覺是「舊式」 - 換句話說,按鈕和控件沒有新的「XP外觀」(即圓角按鈕等)。這可能是OPENFILENAME結構中某個字段的標誌設置,我正在研究這個問題。我只是想知道你(或其他人)是否有解決這個問題的見解。

,然後自答:

沒關係 - 它了。之前實例化形式對象,你需要調用Application.EnableVisualStyles()像這樣:

[STAThread] 
static void Main() 
{ 
    Application.EnableVisualStyles(); 
    Application.Run(new Form1()); 
} 
+0

哎呀,我忽略了評論。非常感謝您指出! –

1

LarsTech的解決辦法似乎在大多數情況下工作,但似乎不Office加載項。在這裏執行EnableThemingInScope描述爲in this Microsoft article,並使用它與下面的代碼有所幫助。

using(new EnableThemingInScope(true)) 
{ 
    if (!GetSaveFileName(ref ofn)) 
    { 
     int ret=CommDlgExtendedError(); 

     if (ret!=0) 
     { 
      throw new ApplicationException("Couldn't show file open dialog - " + ret.ToString()); 
     } 

     return DialogResult.Cancel; 
    } 
} 
相關問題