File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
Source/ExcelDna.IntelliSense Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ void InitializeOptions()
5353 {
5454 Logger . Display . Verbose ( "InitializeOptions" ) ;
5555 string listSeparator = "," ;
56+ string standardFontName = "Calibri" ;
57+ double standardFontSize = 11.0 ;
5658 object result ;
5759 if ( XlCallInt . TryExcel ( XlCallInt . xlfGetWorkspace , out result , 37 ) == XlCallInt . XlReturn . XlReturnSuccess )
5860 {
@@ -65,6 +67,20 @@ void InitializeOptions()
6567 }
6668 FormulaParser . ListSeparator = listSeparator [ 0 ] ;
6769 _argumentSeparator = listSeparator + " " ;
70+
71+ if ( XlCallInt . TryExcel ( XlCallInt . xlfGetWorkspace , out result , 56 ) == XlCallInt . XlReturn . XlReturnSuccess )
72+ {
73+ // Standard Font Name
74+ standardFontName = ( string ) result ;
75+ Logger . Initialization . Verbose ( $ "InitializeOptions - Set StandardFontName to { standardFontName } ") ;
76+ }
77+ if ( XlCallInt . TryExcel ( XlCallInt . xlfGetWorkspace , out result , 57 ) == XlCallInt . XlReturn . XlReturnSuccess )
78+ {
79+ // Standard Font Size
80+ standardFontSize = ( double ) result ;
81+ Logger . Initialization . Verbose ( $ "InitializeOptions - Set StandardFontSize to { standardFontSize } ") ;
82+ }
83+ ToolTipForm . SetStandardFont ( standardFontName , standardFontSize ) ;
6884 }
6985
7086 // TODO: Still not sure how to delete / unregister...
Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ class ToolTipForm : Form
4040 Dictionary < FontStyle , Font > _fonts ;
4141 ToolTip tipDna ;
4242
43+ static Font s_standardFont ;
44+
4345 public ToolTipForm ( IntPtr hwndOwner )
4446 {
4547 Debug . Assert ( hwndOwner != IntPtr . Zero ) ;
@@ -180,13 +182,12 @@ public IntPtr OwnerHandle
180182 }
181183
182184 // TODO: Move or clean up or something...
183- Font StandardFont = new Font ( "Calibri" , 11 ) ;
184185 int MeasureFormulaStringWidth ( string formulaString )
185186 {
186187 if ( string . IsNullOrEmpty ( formulaString ) )
187188 return 0 ;
188189
189- var size = TextRenderer . MeasureText ( formulaString , StandardFont ) ;
190+ var size = TextRenderer . MeasureText ( formulaString , s_standardFont ) ;
190191 return size . Width ;
191192 }
192193
@@ -461,7 +462,12 @@ void InitializeComponent()
461462 this . ResumeLayout ( false ) ;
462463
463464 }
464-
465+
466+ internal static void SetStandardFont ( string standardFontName , double standardFontSize )
467+ {
468+ s_standardFont = new Font ( standardFontName , ( float ) standardFontSize ) ;
469+ }
470+
465471 class Win32Window : IWin32Window
466472 {
467473 public IntPtr Handle
You can’t perform that action at this time.
0 commit comments