Listing 1: simphtml.hpp Interface to SimpleHTMLDisplay
#ifndef SIMPLE_HTML_DISPLAY #define SIMPLE_HTML_DISPLAY #include "richedit.h" class SimpleHTMLDisplay { struct SimpleHTML_UrlNode { SimpleHTML_UrlNode *shu_lpNext; TCHAR shu_tchURL[1]; }; HWND shd_hwndEdit; SimpleHTML_UrlNode *shd_lpFirstURL; int shd_iRichEditVersion; LONG shd_lpfnOrigProc; void PrintText(LPTSTR lpszStr); DWORD AddLink(LPTSTR lpszLink); BOOL HandleFont(LPTSTR lpszTag,CHARFORMAT2 *lpCF); LPTSTR RetrieveURL(ENLINK *lpLink); void HighlightURL(ENLINK *lpLink,BOOL fState); static LRESULT CALLBACK SubProc(HWND,UINT,WPARAM,LPARAM); inline int hexcharval(TCHAR c) { return (c>=TEXT('0') && c<=TEXT('9'))?c-TEXT('0'): (c>=TEXT('a') && c<=TEXT('f'))?c-TEXT('a')+10: (c>=TEXT('A') && c<=TEXT('F'))?c-TEXT('A')+10:-1; } ~SimpleHTMLDisplay(); public: SimpleHTMLDisplay(HWND hWnd); }; #define SHDMSG_GETURL WM_APP+1 #define SHDMSG_HIGHLIGHTURL WM_APP+2 #define URL_NORMALCOLOR (COLORREF)0x00ff0101 #define URL_CLICKCOLOR (COLORREF)0x00800180 #endif //End of File