Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

VS Commands in Dialog Windows

$
0
0

Hello,

I'm writing a Visual Studio package that has a custom editor, which provided data grid (or table) based editing. Adding and removing lines is done by executing correspondingcustom Visual Studio commands. These commands are bound to keyboard gestures andmay be remapped by the user (from the Keyboard options dialog).

Now I would like to do something that is a bit unorthodox in Visual Studio: I want to use thesame commands within a Modal Dialog Window, so that if the user remaps the command to other key stroke combinations, it will reflect in the dialog window.

I used the technique described here to accomplish this. The following describes how it works in my code:

Initialization stage:

  1. I instantiate an IOleCommandTarget implementation. I'll name it here "MyCommandTarget".
  2. Register "MyCommandTarget" as priority command target  (RegisterPriorityCommandTarget(0, MyCommandTarget, out cookie))
  3. Register an event handler on ComponentDispatcher.ThreadFilterMessage to override WPF message processing.

When pressing an accelerator key:

  1. The message is first captured by the ThreadFilterMessage handler.
  2. -- The handler uses IvsFilterKeys2.TranslateAcceleratorEx(...) to translate and execute the command like so:
int res = filterKeys.TranslateAcceleratorEx(
   new Microsoft.VisualStudio.OLE.Interop.MSG[] {oleMSG},
   (uint)(__VSTRANSACCELEXFLAGS.VSTAEXF_AllowModalState),
   1 /*scope count*/,
   new Guid[1] { typeof(RepositoryEditorFactory).GUID },
   out cmdGuid,
   out cmdId,
   out fTranslated,
   out fStartsMultiKeyChord);
  1. -- The 'QueryStatus' method of MyCommandTarget is executed, sets the command toenabled and returns VSConstants.S_OK.
  2. -- The QueryStatus method of the editor pane is executed and it changes the status of the command to 'Disabled' (because indeed, on the editor pane it should be disabled...).

The last step breaks the operation. I can't make the command run in the dialog window, unless I enable it on the editor pane.

Is there an inherent way to prevent the system from querying the command status on the editor pane by stopping the command propagation somehow, or by turning a flag on?


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>