3
* @brief Support for MFC (Windows) .
4
* @author Yves Piguet. Copyright 2007-2008, Yves Piguet
8
* Here is how to support links in a CRichEditView (assuming the subclass name
9
* is S and the control id is ID):
10
* - Enable links in method S::OnCreate, e.g. with
12
* GetRichEditCtrl().SetEventMask(GetRichEditCtrl().GetEventMask() | ENM_LINK);
14
* - Add the following protected method prototype in the header file:
16
* afx_msg void OnEnLink(NMHDR* pNMHDR, LRESULT* pResult);
18
* - Add the following method definition to CRichEditView's subclass (you can write
19
* your own NMEMFCLinkFun function if you want to process links in a special way):
21
* void S::OnEnLink(NMHDR* pNMHDR, LRESULT* pResult)
23
* NMEMFCEnLink(pNMHDR, pResult, NMEMFCLinkFunURL);
26
* - Add the following line between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP:
28
* ON_NOTIFY(EN_LINK, ID, OnEnLink)
30
* - call NMEMFCSetRichText with argument link set to TRUE
32
* You should replace ON_NOTIFY with ON_NOTIFY_RANGE and define
33
* S::OnEnLinkRange(UINT id, NMHDR* pNMHDR, LRESULT* pResult) if you have to
34
* handle multiple CRichEditView controls with one method.
45
/** Callback to handle link clicks.
46
@param[in] link raw link, as in NME source text, without leading and
47
trailing spaces (null-terminated string)
48
@param[in,out] data data value specific to the callback
50
typedef void (*NMEMFCLinkFun)(NMEConstText link, void *data);
52
/** Replace selection in a CRichEditCtrl with NME text converted
54
@param[in,out] c MFC rich text control
55
@param[in] input text with NME markup
56
@param[in] inputLength length of input, or negative if input is
58
@param[in] replaceSel if TRUE, replace selection, else replace whole text
59
@param[in] plainTextCharFormat character format of plain text (if NULL, use
60
default character format of c)
61
@param[in] links TRUE to enable links, else FALSE
63
void NMEMFCSetRichText(CRichEditCtrl &c,
64
char const *input, int inputLength = -1,
65
bool replaceSel = FALSE,
66
CHARFORMAT const *plainTextCharFormat = NULL,
69
/** Replace selection in a CRichEditCtrl with NME text converted
71
@param[in,out] c MFC rich text control
72
@param[in] input text as UCS-16 with NME markup
73
@param[in] inputLength length of input, or negative if input is
75
@param[in] replaceSel if TRUE, replace selection, else replace whole text
76
@param[in] plainTextCharFormat character format of plain text (if NULL, use
77
default character format of c)
78
@param[in] links TRUE to enable links, else FALSE
80
void NMEMFCSetRichText(CRichEditCtrl &c,
81
WCHAR const *input, int inputLength = -1,
82
bool replaceSel = FALSE,
83
CHARFORMAT const *plainTextCharFormat = NULL,
86
/** Handle links (should be called when an EN_LINK notification is received).
87
@param[in] pNMHDR notification message
88
@param[out] pResult result code
89
@param[in] linkFun callback which handles link clicks
90
@param[in] linkFunData value passed to linkFun
92
void NMEMFCEnLink(NMHDR const *pNMHDR, LRESULT* pResult,
93
NMEMFCLinkFun linkFun, void *linkFunData = NULL);
95
/** NMEMFCLinkFun callback to let Windows process URL (can be used as is
96
or called from a user-written callback which recognizes other kinds of
98
@param[in] link raw URL, as in NME source text, without leading and
99
trailing spaces (null-terminated string)
100
@param[in,out] data not used
102
void NMEMFCLinkFunURL(NMEConstText link, void *data = NULL);