Trace a CString
-
I have few methods, in a CDocument class, which read from IHTMLElement get_tagName.
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); AfxMessageBox(sTempTagName); SysFreeString(bstrTagName); }
which show in MessageBox html tags: input, div, span, and so on ... if I try
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); TRACE("%s\\n", sTempTagName); SysFreeString(bstrTagName); }
I have in my debug window the first letter of every read tag: i d s and no entire html tag ... why in MessageBox I see whole word, but in TRACE macro I don't ?
-
I have few methods, in a CDocument class, which read from IHTMLElement get_tagName.
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); AfxMessageBox(sTempTagName); SysFreeString(bstrTagName); }
which show in MessageBox html tags: input, div, span, and so on ... if I try
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); TRACE("%s\\n", sTempTagName); SysFreeString(bstrTagName); }
I have in my debug window the first letter of every read tag: i d s and no entire html tag ... why in MessageBox I see whole word, but in TRACE macro I don't ?
-
I have few methods, in a CDocument class, which read from IHTMLElement get_tagName.
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); AfxMessageBox(sTempTagName); SysFreeString(bstrTagName); }
which show in MessageBox html tags: input, div, span, and so on ... if I try
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); TRACE("%s\\n", sTempTagName); SysFreeString(bstrTagName); }
I have in my debug window the first letter of every read tag: i d s and no entire html tag ... why in MessageBox I see whole word, but in TRACE macro I don't ?
You may need to add
,s
or,u
to the variable being watched in the Watch window."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
You may need to add
,s
or,u
to the variable being watched in the Watch window."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
I have few methods, in a CDocument class, which read from IHTMLElement get_tagName.
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); AfxMessageBox(sTempTagName); SysFreeString(bstrTagName); }
which show in MessageBox html tags: input, div, span, and so on ... if I try
BSTR bstrTagName; CString sTempTagName; if (! FAILED(pElem->get\_tagName(&bstrTagName))) { sTempTagName = bstrTagName; sTempTagName.MakeLower(); TRACE("%s\\n", sTempTagName); SysFreeString(bstrTagName); }
I have in my debug window the first letter of every read tag: i d s and no entire html tag ... why in MessageBox I see whole word, but in TRACE macro I don't ?
You are calling the
TRACE
macro with achar*
format string but pass aCString
which iswchar_t*
with Unicode builds. Use one of these:// Use the _T() macro
TRACE(_T("%s\n"), sTempTagName.GetString());// Pass type of string in format
#ifdef _UNICODE
TRACE("%ls\n"), sTempTagName.GetString());
#else
TRACE("%hs\n"), sTempTagName.GetString());
#endif// Use TRACEn which is inserting the _T() macro
TRACE1("%s\n", sTempTagName.GetString());Note also that I have used
GetString()
instead of the implicitCString LPCTSTR
operator. -
In watch window I can see the variables with their values normally, the problem is when I want to see them with TRACE macro, in my debug window ...
_Flaviu wrote:
the problem is when I want to see them with TRACE macro, in my debug window ...
Try
%S
instead of%s
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
_Flaviu wrote:
the problem is when I want to see them with TRACE macro, in my debug window ...
Try
%S
instead of%s
."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
Thanks - I've been looking for a few days for this solution. Works a treat