Share via


CmdWnd: Issue IDE Command in a Command Window

The CmdWnd add-in sample creates a command window into which you can enter three types of commands:

CmdWnd commands

You can display a list of the CmdWnd commands by typing a question mark (?) in the command window. Note that several CmdWnd commands start the debugger.

IDE commands

Any command issued in the command window that is not a CmdWnd command will next be evaluated as an IDE command. Any command that you see in the Commands list in the Keyboard tab of the Customize dialog box, which is accessed from the Tools menu, can be issued in the command window to access the functionality of the menu option. An example of such a command is NewText. Another useful one is DebugBreak. Note that case is sensitive here.

MS-DOS commands

Any command issued in the command window that is neither a CmdWnd command nor an IDE command will next be evaluated as a command issued from an MS-DOS prompt.

The CmdWnd add-in sample shows how to create a modeless dialog box add-in. Add-ins are normally required to be modal dialog boxes. One problem encountered in making a modeless add-in is that some keystrokes get translated and sent to msdev.exe and the add-in’s dialog box does not receive them. This is particularly dangerous since keys like DEL are in this list. This sample shows how to create an add-in in two basic pieces: a stub add-in, and an exe that opens a dialog box. This results in a modeless dialog box for msdev.exe.

To build the sample

  1. Click the link at the beginning of this topic to download the sample files.

  2. In Visual C++, open the project file cmdwnd.dsw.

  3. Choose an appropriate configuration (Win32 Release is best if you plan to use this add-in).

  4. Make the All project the active project.

  5. Click Rebuild All from the Build menu.

This project builds a proxy stub, called devcmd.dll, and is built in the msdevcmdstubs subproject. There is one other subproject called the _interface project; this project facilitates the build process and must be built first. If you change devcmd.idl, rebuild _interface.

To run the add-in

  1. From the Tools menu, click Customize.

  2. Click the Add-ins and Macro Files tab.

  3. Select the cmdstub.dll file or browse for it. See Tips for Using Add-ins.

    Visual C++ will load the add-in. When you close the Customize dialog box, CmdWnd’s toolbar will appear.

  4. Run the CmdWnd add-in by either:

    • Running msdevcmd.exe. msdevcmd.exe finds the first msdev.exe that you are running and uses it.

    • Clicking the toolbar button (the preferred method, especially if you sometimes run more than one msdev.exe). The proxy stub ensures that the add-in uses the correct msdev.exe process.