Click here to Skip to main content
15,917,964 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: Usage of reference Pin
Richard MacCutchan29-Mar-11 3:22
mveRichard MacCutchan29-Mar-11 3:22 
GeneralRe: Usage of reference Pin
Krishnakumartg29-Mar-11 6:12
Krishnakumartg29-Mar-11 6:12 
GeneralRe: Usage of reference Pin
Richard MacCutchan29-Mar-11 6:25
mveRichard MacCutchan29-Mar-11 6:25 
GeneralRe: Usage of reference Pin
Krishnakumartg29-Mar-11 6:30
Krishnakumartg29-Mar-11 6:30 
GeneralRe: Usage of reference Pin
Richard MacCutchan29-Mar-11 6:54
mveRichard MacCutchan29-Mar-11 6:54 
QuestionWhy more than one picture added into .doc file can't be seen but single can? [modified] Pin
whiteclouds24-Mar-11 21:47
whiteclouds24-Mar-11 21:47 
QuestionHow to replace a '%' character in CComBSTR with "%%" Pin
narayanagvs23-Mar-11 0:31
narayanagvs23-Mar-11 0:31 
AnswerRe: How to replace a '%' character in CComBSTR with "%%" [modified] Pin
Cool_Dev24-Mar-11 2:18
Cool_Dev24-Mar-11 2:18 
CComBstr class doesn't have a method to replace a sub-string with another or to insert another string in specified position. All you can do is, get BSTR which is wrapped in CComBSTR class ( either by m_str member or by operator BSTR). You need to copy this to another CComBSTR. You may use its Append() method or overloaded += operators for ease.

CComBSTR str("here%are%percentages%");
CComBSTR newstr;

WCHAR split[] = L"%";
WCHAR* pos  = wcstok(str.m_str, split);
while(0 != pos) {
  newstr.Append(pos);
  newstr.Append(L"%%");

  pos  = wcstok(NULL, split);
}


NOTE:
I would like to remind that BSTR data type has preceding header components, and the final string is terminated with double null characters. This is how system allocates memory for BSTR. There can be embedded single null characters in BSTR string data. In that case, wcslen() and wcstok() functions won't work as expected. Use CComBSTR::Length() or SysStringLen() to get length of string. You may need to examine each character in string till you find two continuous '\0' characters. During this, whenever you find a '%' add an additional '%' more tho the new string. Hmmm | :|


Unicode support is completely ensured. Smile | :)

modified on Thursday, March 24, 2011 9:09 AM

GeneralRe: How to replace a '%' character in CComBSTR with "%%" Pin
barneyman22-Apr-11 0:08
barneyman22-Apr-11 0:08 
RantRe: How to replace a '%' character in CComBSTR with "%%" Pin
Cool_Dev22-Apr-11 0:41
Cool_Dev22-Apr-11 0:41 
GeneralRe: How to replace a '%' character in CComBSTR with "%%" Pin
barneyman22-Apr-11 0:50
barneyman22-Apr-11 0:50 
Questionget focus on ActiveX control in MFC Dialog Pin
MrKBA22-Mar-11 0:01
MrKBA22-Mar-11 0:01 
Questionaccessing ActiveX array Pin
opti99921-Mar-11 23:33
opti99921-Mar-11 23:33 
AnswerRe: accessing ActiveX array Pin
Michael Dunn22-Mar-11 20:47
sitebuilderMichael Dunn22-Mar-11 20:47 
QuestionSinging COM Object Pin
Anders Molin21-Mar-11 2:31
professionalAnders Molin21-Mar-11 2:31 
AnswerRe: Singing COM Object Pin
Michael Dunn22-Mar-11 20:51
sitebuilderMichael Dunn22-Mar-11 20:51 
GeneralRe: Singing COM Object Pin
Anders Molin23-Mar-11 8:12
professionalAnders Molin23-Mar-11 8:12 
QuestionCreate my COM object from JScript Pin
Anders Molin21-Mar-11 2:29
professionalAnders Molin21-Mar-11 2:29 
QuestionHow to disable/enable the button on CommandBar in add-in application? Pin
whiteclouds17-Mar-11 22:13
whiteclouds17-Mar-11 22:13 
QuestionHow to get IDOK / IDCANCEL command message from an non-modal dialog set as client in CFrameWindowImpl? Pin
Philipp Kursawe11-Mar-11 2:46
Philipp Kursawe11-Mar-11 2:46 
QuestionRe: How to get IDOK / IDCANCEL command message from an non-modal dialog set as client in CFrameWindowImpl? [modified] Pin
Cool_Dev11-Mar-11 3:20
Cool_Dev11-Mar-11 3:20 
AnswerRe: How to get IDOK / IDCANCEL command message from an non-modal dialog set as client in CFrameWindowImpl? Pin
Alain Rist11-Mar-11 9:47
Alain Rist11-Mar-11 9:47 
GeneralRe: How to get IDOK / IDCANCEL command message from an non-modal dialog set as client in CFrameWindowImpl? Pin
Philipp Kursawe17-Mar-11 0:24
Philipp Kursawe17-Mar-11 0:24 
GeneralRe: How to get IDOK / IDCANCEL command message from an non-modal dialog set as client in CFrameWindowImpl? Pin
Alain Rist17-Mar-11 9:49
Alain Rist17-Mar-11 9:49 
QuestionUsing CContainedWindowT in a base class causes assert in conrete class Pin
Philipp Kursawe10-Mar-11 20:39
Philipp Kursawe10-Mar-11 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.