// OutLookRichEdit.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "OutLookRichEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutLookRichEdit
/*---------------------------------------------------------------
Function name : COutLookRichEdit::COutLookRichEdit
Description :
Return type :
Author : Madhu B Nair
Type :
Created on : 6/10/02
Contact (MailID) : madhu_na@hotmail.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
COutLookRichEdit::COutLookRichEdit()
{
m_hLinkCursor = AfxGetApp()->LoadCursor (IDC_LINK); //Should have the hand cursor in resource
//If this lines shows build-error then
//please import the hand cursor, and rename it with IDC_LINK
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::~COutLookRichEdit
Description :
Return type :
Author : Madhu B Nair
Type :
Created on : 6/10/02
Contact (MailID) : madhu_na@hotmail.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
COutLookRichEdit::~COutLookRichEdit()
{
if(!m_lsLinks.IsEmpty ())
{
m_lsLinks.RemoveAll();
}
}
BEGIN_MESSAGE_MAP(COutLookRichEdit, CRichEditCtrl)
//{{AFX_MSG_MAP(COutLookRichEdit)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutLookRichEdit message handlers
/*---------------------------------------------------------------
Function name : COutLookRichEdit::SetRTF
Description :
Return type : void
Argument : CString sRTF
Author : Jeremy Iverson
Type :
Created on : March 18, 1999
Contact (MailID) : jeremy@devpointsoftware.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
void COutLookRichEdit::SetRTF(CString sRTF)
{
// Put the RTF string sRTF into the rich edit control.
// Read the text in
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = CBStreamIn;
es.dwCookie = (DWORD) &sRTF;
StreamIn(SF_RTF, es); // Do it.
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::CBStreamIn
Description : Callback function to stream an RTF string into the rich edit control.
Return type : DWORD CALLBACK
Argument : DWORD dwCookie
Argument : LPBYTE pbBuff
Argument : LONG cb
Argument : LONG *pcb
Author : Zafir Anjum
Type :
Created on :
Contact (MailID) :
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
DWORD CALLBACK COutLookRichEdit::CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
// We insert the rich text here.
/*
This function taken from CodeGuru.com
http://www.codeguru.com/richedit/rtf_string_streamin.shtml
Zafir Anjum
*/
CString *pstr = (CString *) dwCookie;
if (pstr->GetLength() < cb)
{
*pcb = pstr->GetLength();
memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
pstr->Empty();
}
else
{
*pcb = cb;
memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
*pstr = pstr->Right(pstr->GetLength() - cb);
}
return 0;
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::CBStreamOut
Description : Callback function to stream the RTF string out of the rich edit control.
Return type : DWORD CALLBACK
Argument : DWORD dwCookie
Argument : LPBYTE pbBuff
Argument : LONG cb
Argument : LONG *pcb
Author : Zafir Anjum
Type :
Created on :
Contact (MailID) :
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
DWORD CALLBACK COutLookRichEdit::CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
// Address of our string var is in psEntry
CString *psEntry = (CString*) dwCookie;
CString tmpEntry = _T("");
tmpEntry = (CString) pbBuff;
// And write it!!!
*psEntry += tmpEntry.Left(cb);
return 0;
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::GetCharFormat
Description :
Return type : CHARFORMAT
Argument : DWORD dwMask
Author : Jeremy Iverson
Type :
Created on : March 18, 1999
Contact (MailID) : jeremy@devpointsoftware.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
CHARFORMAT COutLookRichEdit::GetCharFormat(DWORD dwMask)
{
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = dwMask;
GetSelectionCharFormat(cf);
return cf;
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::SetCharStyle
Description :
Return type : void
Argument : int MASK
Argument : int STYLE
Argument : int nStart
Argument : int nEnd
Author : Madhu B Nair
Type :
Created on : 6/10/02
Contact (MailID) : madhu_na@hotmail.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
void COutLookRichEdit::SetCharStyle(int MASK, int STYLE, int nStart, int nEnd)
{
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
//cf.dwMask = MASK;
GetSelectionCharFormat(cf);
if (cf.dwMask & MASK) // selection is all the same
{
cf.dwEffects ^= STYLE;
}
else
{
cf.dwEffects |= STYLE;
}
cf.dwMask = MASK;
SetSelectionCharFormat(cf);
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::GetParagraphFormat
Description :
Return type : PARAFORMAT
Author : Jeremy Iverson
Type :
Created on : March 18, 1999
Contact (MailID) : jeremy@devpointsoftware.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
PARAFORMAT COutLookRichEdit::GetParagraphFormat()
{
PARAFORMAT pf;
pf.cbSize = sizeof(PARAFORMAT);
pf.dwMask = PFM_ALIGNMENT | PFM_NUMBERING;
GetParaFormat(pf);
return pf;
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::CBEnumFonts
Description :
Return type : BOOL CALLBACK
Argument : LPLOGFONT lplf
Argument : LPTEXTMETRIC lptm
Argument : DWORD dwType
Argument : LPARAM lpData
Author : Madhu B Nair
Type :
Created on : 6/10/02
Contact (MailID) : madhu_na@hotmail.com
Modified by :
Modified on :
Contact (MailID) :
---------------------------------------------------------------*/
BOOL CALLBACK COutLookRichEdit::CBEnumFonts(LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData)
{
if (dwType == TRUETYPE_FONTTYPE)
{
((CStringArray *) lpData)->Add( lplf->lfFaceName );
}
return true;
}
/*---------------------------------------------------------------
Function name : COutLookRichEdit::OnMouseMove
Description :
Return type : void
Argument : UINT nFlags
Argument : CPoint point
Author : Madhu B Nair
Type