I am receiving a EM_CHARFORMAT message in my message handler when SetFont() is called on my custom control. But when I change the data in the CHARFORMAT structure pointed to in the LPARAM, it isn't being used.
void CMyRichEdit::OnProtected(NMHDR* pNMHDR, LRESULT* pResult)
{
ENPROTECTED* pEP = (ENPROTECTED*)pNMHDR;
*pResult = 1;
switch(pEP->msg)
{
case EM_SETCHARFORMAT:
{
CHARFORMAT *cf = reinterpret_cast<CHARFORMAT *>(pEP->lParam);
cf->dwEffects |= (CFE_PROTECTED | CFE_ITALIC);
cf->dwMask |= (CFM_PROTECTED | CFM_ITALIC);
*pResult = 0;
}
break;
The MSDN docs say only if the lParam value changes is it used over the original... but here lParam is a pointer to an object. How can I allocate a new object without the memory leaking?