2016-07-15 24 views
1

我已經創建了一個Outlook插件,並在這裏添加自定義taskpane它自動調整不同屏幕上的Outlook自Taskpane自動

private void ThisAddIn_Startup(object sender, System.EventArgs e) 
     { 
      taskpane = this.CustomTaskPanes.Add(new UCMaster(), "Summit Service Management"); 
      UserControl ucmaster = taskpane.Control; 
      eh = new ElementHost { Child = new WPFUCMaster(new WPFUCLogin()) }; 
      eh.Dock = DockStyle.Fill; 
      eh.AutoSize = true; 
      ucmaster.Controls.Add(eh); 
      taskpane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight; 
      taskpane.DockPositionRestrict = Office.MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange; 
      taskpane.Width = 460; 
      taskPaneWidth = taskpane.Width; 
      taskPaneHeight = taskpane.Height; 
      ucmaster.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right);   
      ucmaster.AutoSizeMode = AutoSizeMode.GrowAndShrink; 
      ucmaster.AutoSize = true; 
      int h = ucmaster.Height; 
      int w = ucmaster.Width; 
      initialAddinInstance = this; 
      ucmaster.BringToFront(); 
     } 

IM根據我的屏幕尺寸和它在尋找妥善解決硬編碼taskpane寬度。

但是,在不同的屏幕,我觀察像任務窗格正在壓縮或以任何其他方式。

我的問題是我如何可以根據當前的系統屏幕分辨率和尺寸按字母順序更改任務窗格寬度?

回答

1

對於容器控件「AutoScaleMode」應該是Inherit,對於Leaf控件它應該是Font。 試試這個: ucmaster.AutoScaleMode = AutoScaleMode.Inherit; 和 使您的孩子用戶控制到: ucChild.AutoScaleMode = AutoScaleMode.Font;