![]() |
|
QA: How to turn off messages sent by MFC to Debug window?
By Alexander Shargin, April 25, 2001.
QuestionI use TRACE command to output debug information to Debug window of eVC. But it's hard to find my own debug messages since Debug window is flooded by messages from MFC. How can I turn these off? AnswerAll debug messages sent by MFC are controlled by a global variable afxTraceFlags. MFC debug messages are devided into several categories. Each category has its own flag in afxTraceFlags. If a flag of some category is set, messages of this category will appear in the Debug window. Trace flags are defined in afxwin.h: afxTraceFlags variable is available in Debug builds only. It's initialized at the very beginning of your program's execution. In the desktop version of MFC afxTraceFlags is initialized from Windows registry. Visual Studio 6.0 has a handy utility called MFC tracer, which allows the user to edit trace flags in registry. Using MFC tracer one can choose debug messages, which he wants to receive. But on CE afxTraceFlags is always initialized by 8: If you refer to the enumeration listed above you will see that 8 is actually a traceCmdRouting flag. That's why MFC constantly pumps messages like "SENDING command id XXXX to YYYY target" to Debug window. To suppress these messages or turn on messages from some other category you have to modify afxTraceFlags variable. You can do it in your InitInstance function, e. g.: Note #ifdef/#endif pair of macros. Since afxTraceFlags is only available in Debug builds you have to exclude any operations on it from Release build. Related resources:DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||