Compartilhar via


Watching Variables and Expressions (Windows CE 5.0)

Send Feedback

Use the Watch window to do the following:

  • Specify variables and expressions you want to watch while debugging your application
  • Modify the value of a variable in the Watch window.

The Watch window contains four tabs: Watch1, Watch2, Watch3, and Watch4.

Each tab displays a user-specified list of variables and expressions in a spreadsheet field.

You can group variables you want to watch onto the same tab. For example, you could put variables related to a specific window on one tab and variables related to a dialog box on another tab. You could watch the first tab when debugging the window and the second tab when debugging the dialog box.

If you add an array, an object, or a structure variable to the Watch window, plus (+) or minus (–) boxes appear in the Name column. You can use these boxes to expand or collapse your view of the variable.

If the value of a variable appears in red, it indicates that the value has recently changed. Only the last value to change appears in red.

Red is the default color. To change the color,

  1. From the Tools menu, choose Options.
  2. Choose the Format tab.
  3. In the Colors box, select a highlight item; for example, Value Highlight.
  4. In the Foreground box, choose a new color and then choose OK.

If the variable is an object, a reference, or a C++ pointer to an object, the Watch window expands the variable to show the most important data at the top level.

For example, suppose you had the following C++ object:

CString String  =   {...}
char *   m_pchData =0x7ffdf000 "abc"
   int          m_nDataLength=4
   int          m_nAllocLength=1244628

The Watch window displays the following:

String  =   {"abc"}

If the variable is a reference or a C++ pointer to an object, the Watch window downcasts the reference or pointer.

The Watch window also adds an extra member to the expanded object. This extra member, which looks like another base class, indicates the derived subclass.

For example, if a variable that is declared as a C++ pointer to CObject really points to a CComboBox, the Watch window recognizes this and adds an extra member so you can access the CComboBox members.

The Watch window displays values in their default format. You can use formatting characters to change the display format.

The following example shows the command used to specify a hexadecimal value x as a Unicode character.

x,su 

In addition to global variables of the current process, you can also review global variables of any module that is loaded, if you qualify the name with the context operator.

For example, no matter what the current process is, you can examine the ProcArray structure in the kernel by typing a command in a Watch window.

The following code example shows an example of this command.

{,,nk.exe}ProcArray 

You can review a module by casting a thread address. If you want to look at the thread structure for the Shell.exe process from the Processes command output, you can type a command in the Watch window.

The following code example shows this, assuming the process address is 0:0x08cbe0a5.

(PTHREAD)0:0x08cbe0a5c 

The Watch window does not display variable type information. You can view information for a variable type by using the window's property page.

See Also

Viewing the Value of a Variable or Expression or the Contents of a Register in the Watch Window | Viewing the Value of a Variable or Expression or the Contents of a Register by Using QuickWatch | Character Formatting of Watch Variables

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.