@@ -26,6 +26,7 @@ public class ArgumentInfo
2626
2727 // CONSIDER: Revisit UI Automation Threading: http://msdn.microsoft.com/en-us/library/windows/desktop/ee671692(v=vs.85).aspx
2828 // And this threading sample using tlbimp version of Windows 7 native UIA: http://code.msdn.microsoft.com/Windows-7-UI-Automation-6390614a/sourcecode?fileId=21469&pathId=715901329
29+ // NOTE: TrackFocus example shows how to do a window 'natively'.
2930 class IntelliSenseDisplay : IDisposable
3031 {
3132
@@ -42,7 +43,8 @@ class IntelliSenseDisplay : IDisposable
4243 // Need to make these late ...?
4344 ToolTipForm _descriptionToolTip ;
4445 ToolTipForm _argumentsToolTip ;
45- IntPtr _mainWindow ;
46+ IntPtr _formulaEditWindow ;
47+ IntPtr _functionListWindow ;
4648
4749 public IntelliSenseDisplay ( SynchronizationContext syncContextMain , UIMonitor uiMonitor )
4850 {
@@ -121,23 +123,25 @@ void StateUpdate(object sender, UIStateUpdate update)
121123 switch ( update . Update )
122124 {
123125 case UIStateUpdate . UpdateType . FormulaEditStart :
124- UpdateMainWindow ( ( update . NewState as UIState . FormulaEdit ) . MainWindow ) ;
126+ UpdateFormulaEditWindow ( ( update . NewState as UIState . FormulaEdit ) . FormulaEditWindow ) ;
125127 FormulaEditStart ( ) ;
126128 break ;
127129 case UIStateUpdate . UpdateType . FormulaEditMove :
128130 var fem = ( UIState . FormulaEdit ) update . NewState ;
129131 FormulaEditMove ( fem . EditWindowBounds , fem . ExcelTooltipBounds ) ;
130132 break ;
131- case UIStateUpdate . UpdateType . FormulaEditMainWindowChange :
132- UpdateMainWindow ( ( update . NewState as UIState . FormulaEdit ) . MainWindow ) ;
133+ case UIStateUpdate . UpdateType . FormulaEditWindowChange :
134+ UpdateFormulaEditWindow ( ( update . NewState as UIState . FormulaEdit ) . FormulaEditWindow ) ;
133135 break ;
134136 case UIStateUpdate . UpdateType . FormulaEditTextChange :
135137 var fetc = ( UIState . FormulaEdit ) update . NewState ;
136138 FormulaEditTextChange ( fetc . FormulaPrefix , fetc . EditWindowBounds , fetc . ExcelTooltipBounds ) ;
137139 break ;
138140 case UIStateUpdate . UpdateType . FunctionListShow :
139- FunctionListShow ( ) ;
140141 var fls = ( UIState . FunctionList ) update . NewState ;
142+ // TODO: TEMP
143+ _functionListWindow = fls . FunctionListWindow ;
144+ FunctionListShow ( ) ;
141145 FunctionListSelectedItemChange ( fls . SelectedItemText , fls . SelectedItemBounds ) ;
142146 break ;
143147 case UIStateUpdate . UpdateType . FunctionListMove :
@@ -155,7 +159,7 @@ void StateUpdate(object sender, UIStateUpdate update)
155159 FormulaEditEnd ( ) ;
156160 break ;
157161 case UIStateUpdate . UpdateType . SelectDataSourceShow :
158- case UIStateUpdate . UpdateType . SelectDataSourceMainWindowChange :
162+ case UIStateUpdate . UpdateType . SelectDataSourceWindowChange :
159163 case UIStateUpdate . UpdateType . SelectDataSourceHide :
160164 // We ignore these
161165 break ;
@@ -165,23 +169,26 @@ void StateUpdate(object sender, UIStateUpdate update)
165169 }
166170
167171 // Runs on the main thread
168- void UpdateMainWindow ( IntPtr mainWindow )
172+ void UpdateFormulaEditWindow ( IntPtr formulaEditWindow )
169173 {
170- if ( _mainWindow != mainWindow )
174+ if ( _formulaEditWindow != formulaEditWindow )
171175 {
172- _mainWindow = mainWindow ;
173- if ( _descriptionToolTip != null || _argumentsToolTip != null )
176+ _formulaEditWindow = formulaEditWindow ;
177+ if ( _argumentsToolTip != null )
174178 {
175- if ( _descriptionToolTip != null )
176- {
177- _descriptionToolTip . Dispose ( ) ;
178- _descriptionToolTip = new ToolTipForm ( _mainWindow ) ;
179- }
180- if ( _argumentsToolTip != null )
181- {
182- _argumentsToolTip . Dispose ( ) ;
183- _argumentsToolTip = new ToolTipForm ( _mainWindow ) ;
184- }
179+ _argumentsToolTip . OwnerHandle = _formulaEditWindow ;
180+ }
181+ }
182+ }
183+
184+ void UpdateFunctionListWindow ( IntPtr functionListWindow )
185+ {
186+ if ( _functionListWindow != functionListWindow )
187+ {
188+ _functionListWindow = functionListWindow ;
189+ if ( _descriptionToolTip != null )
190+ {
191+ _descriptionToolTip . OwnerHandle = _functionListWindow ;
185192 }
186193 }
187194 }
@@ -191,16 +198,16 @@ void FormulaEditStart()
191198 {
192199 Debug . Print ( $ "IntelliSenseDisplay - FormulaEditStart") ;
193200 if ( _argumentsToolTip == null )
194- _argumentsToolTip = new ToolTipForm ( _mainWindow ) ;
201+ _argumentsToolTip = new ToolTipForm ( _formulaEditWindow ) ;
195202 }
196203
197204 // Runs on the main thread
198205 void FormulaEditEnd ( )
199206 {
200207 Debug . Print ( $ "IntelliSenseDisplay - FormulaEditEnd") ;
201- // _argumentsToolTip.Hide();
202- _argumentsToolTip . Dispose ( ) ;
203- _argumentsToolTip = null ;
208+ _argumentsToolTip . Hide ( ) ;
209+ // _argumentsToolTip.Dispose();
210+ // _argumentsToolTip = null;
204211 }
205212
206213 // Runs on the main thread
@@ -231,9 +238,9 @@ void FormulaEditTextChange(string formulaPrefix, Rect editWindowBounds, Rect exc
231238 }
232239
233240 // All other paths, we just clear the box
234- // _argumentsToolTip.Hide();
235- _argumentsToolTip . Dispose ( ) ;
236- _argumentsToolTip = null ;
241+ _argumentsToolTip . Hide ( ) ;
242+ // _argumentsToolTip.Dispose();
243+ // _argumentsToolTip = null;
237244 }
238245
239246
@@ -242,16 +249,16 @@ void FunctionListShow()
242249 {
243250 Debug . Print ( $ "IntelliSenseDisplay - FunctionListShow") ;
244251 if ( _descriptionToolTip == null )
245- _descriptionToolTip = new ToolTipForm ( _mainWindow ) ;
252+ _descriptionToolTip = new ToolTipForm ( _functionListWindow ) ;
246253 }
247254
248255 // Runs on the main thread
249256 void FunctionListHide ( )
250257 {
251258 Debug . Print ( $ "IntelliSenseDisplay - FunctionListHide") ;
252- // _descriptionToolTip.Hide();
253- _descriptionToolTip . Dispose ( ) ;
254- _descriptionToolTip = null ;
259+ _descriptionToolTip . Hide ( ) ;
260+ // _descriptionToolTip.Dispose();
261+ // _descriptionToolTip = null;
255262 }
256263
257264 // Runs on the main thread
0 commit comments