Click here to Skip to main content
13,146,934 members (61,946 online)
Click here to Skip to main content


43 bookmarked
Posted 14 Jun 2004

XHTMLTipOfTheDay - HTML Tip of the Day Dialog

, 14 Jun 2004
XHTMLTipOfTheDay is a Tip of the Day dialog that displays HTML and has forward and back buttons.
// XHTMLStatic.h  Version 1.2
// This software is released into the public domain.  You are free to use it
// in any way you like, except that you may not sell this source code.
// This software is provided "as is" with no expressed or implied warranty.
// I accept no liability for any damage or loss of business that this software
// may cause.


#include "XNamedColors.h"

// CXHTMLStatic window

	HWND	hWnd;			// HWND of window to receive message
	UINT	uMessage;		// message sent to parent
	WPARAM	wParam;			// user defined data returned in wParam parameter
	TCHAR *	pszCommand;		// string that ties this entry to HTML hyperlink

	TCHAR *	pszName;		// string entered in HTML - e.g., " "
	TCHAR	cCode;			// code generated by XHTMLStatic
	TCHAR	cSymbol;		// character symbol displayed

class CXHTMLStatic : public CStatic
// Construction
	virtual ~CXHTMLStatic();
	void Init();

// Attributes
	virtual COLORREF SetBkColor(COLORREF rgb) 
		COLORREF oldrgb = m_crBackGround;
		m_crBackGround = rgb;
		return oldrgb;
	virtual COLORREF SetBkColor(LPCTSTR lpszColor) 
		CXNamedColors nc(lpszColor);
		COLORREF oldrgb = m_crBackGround;
		m_crBackGround = nc.GetRGB();
		return oldrgb;
	COLORREF GetBkColor() const { return m_crBackGround; }

	virtual COLORREF SetTextColor(COLORREF rgb) 
		COLORREF oldrgb = m_crText;
		m_crText = rgb;
		return oldrgb;
	virtual COLORREF SetTextColor(LPCTSTR lpszColor) 
		CXNamedColors nc(lpszColor);
		COLORREF oldrgb = m_crText;
		m_crText = nc.GetRGB();
		return oldrgb;
	COLORREF GetTextColor() const { return m_crText; }
	void SetMargins(int nLeftMargin, int nRightMargin)
		m_nLeftMargin = nLeftMargin;
		m_nRightMargin = nRightMargin;
	void SetAppCommands(XHTMLSTATIC_APP_COMMAND * paAppCommands, int nAppCommands)
		if (m_paAppCommands)
			delete [] m_paAppCommands;
		m_paAppCommands = NULL;

		m_nAppCommands = 0;

		if (paAppCommands && (nAppCommands > 0))
			m_paAppCommands = new XHTMLSTATIC_APP_COMMAND[nAppCommands];
			memcpy(m_paAppCommands, paAppCommands, 
				sizeof(XHTMLSTATIC_APP_COMMAND) * nAppCommands);
			m_nAppCommands = nAppCommands;
	void SetLogFont(const LOGFONT * pLogFont)
		memcpy(&m_lf, pLogFont, sizeof(m_lf));
		m_bLogFont = TRUE;
	void SetWindowText(LPCTSTR lpszString);

// Overrides
	// ClassWizard generated virtual function overrides
	virtual void PreSubclassWindow();

// Implementation
	int		FormatText(HDC hdc, LPCTSTR lpszText, RECT * pRect, int nInitialXOffset);
	TCHAR	GetCharEntity(TCHAR cCode);
	CString	GetNextWord(TCHAR **ppText, BOOL *pbReturnSeen);
	LONG	GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
	BOOL	GotoURL(LPCTSTR url, int showcmd);
	void	InitCharEntities();
	BOOL	IsBlank(LPCTSTR lpszText);
	BOOL	ProcessAppCommand(LPCTSTR lpszCommand);

	COLORREF		m_crBackGround;
	COLORREF		m_crText;
	LOGFONT			m_lf;
	BOOL			m_bLogFont;
	BOOL			m_bUnderline;
	BOOL			m_bBold;
	BOOL			m_bItalic;
	BOOL			m_bStrikeThrough;
	BOOL			m_bSubscript;
	BOOL			m_bSuperscript;
	BOOL			m_bHorizontalRule;
	int				m_nHorizontalRuleSize;
	CFont			m_font;
	BOOL			m_bInAnchor;
	CPtrArray		m_AnchorRectPtrs;
	CStringArray	m_AnchorUrls;
	BOOL			m_bHyperlinkTimer;
	BOOL			m_bOnHyperlink;
	HCURSOR			m_hLinkCursor;
	HCURSOR			m_hPrevCursor;
	int				m_nLeftMargin, m_nRightMargin;
	int				m_yStart;
	BOOL			m_bGeneratedText;
	int				m_nAppCommands;
	static XHTMLSTATIC_CHAR_ENTITIES	m_aCharEntities[];

	// Generated message map functions
	afx_msg void OnPaint();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	afx_msg void OnDestroy();
	afx_msg void OnClicked();



// Microsoft Visual C++ will insert additional declarations immediately before the previous line.


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

For consulting and custom software development, please see

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 14 Jun 2004
Article Copyright 2004 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid