Click here to Skip to main content
15,885,365 members
Articles / Desktop Programming / MFC

Exile 1.8 - The Password Manager

Rate me:
Please Sign up or sign in to vote.
4.57/5 (51 votes)
6 Mar 20058 min read 255.2K   7.4K   111  
Yet another password manager.
/********************************************************************
	Created:	20/3/2004, 20:43
	File name: 	D:\Projects\Exile\statichyperlinkex.cpp
	File path:	D:\Projects\Exile
	File base:	statichyperlinkex
	File ext:	cpp
	Author:		Gogolev Anton
*********************************************************************/


// statichyperlinkex.cpp : implementation file
//

#include "stdafx.h"
#include "statichyperlinkex.h"
#include <windows.h>
//#include <winuser.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CStaticHyperlinkEx

CStaticHyperlinkEx::CStaticHyperlinkEx()
{
	m_hCursor = NULL;
	m_crText = RGB(0, 0, 192);
}

CStaticHyperlinkEx::~CStaticHyperlinkEx()
{
}


BEGIN_MESSAGE_MAP(CStaticHyperlinkEx, CStatic)
	//{{AFX_MSG_MAP(CStaticHyperlinkEx)
	ON_WM_CTLCOLOR_REFLECT()
	ON_WM_NCHITTEST()
	ON_WM_SETCURSOR()
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStaticHyperlinkEx message handlers

HBRUSH CStaticHyperlinkEx::CtlColor(CDC* pDC, UINT nCtlColor) 
{
	// This control has to be underlined and has to have blue color
	HBRUSH hBrush = NULL;
	
	if(nCtlColor == CTLCOLOR_STATIC)
	{
		if((GetStyle() & 0xFF) <= SS_RIGHT)
		{
			if(!((HFONT)m_fnFont))
			{
				LOGFONT lf;

				GetFont()->GetObject(sizeof(lf), &lf);
				lf.lfWeight = FW_BOLD;
				lf.lfUnderline = TRUE;

				m_fnFont.CreateFontIndirect(&lf);
			}

			pDC->SelectObject(&m_fnFont);
			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(m_crText);

			hBrush = (HBRUSH)::CreateSolidBrush(::GetSysColor(COLOR_BTNFACE));
		}
	}

	return hBrush;
}

UINT CStaticHyperlinkEx::OnNcHitTest(CPoint point)
{
	return HTCLIENT;
}

BOOL CStaticHyperlinkEx::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT nMessage)
{
	if(m_hCursor == NULL) 
	{
		m_hCursor = LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND));
			::SetCursor(m_hCursor);
	} // if

	if(m_hCursor)
	{
		::SetCursor(m_hCursor);
	} // if

	return (m_hCursor != NULL);
}
void CStaticHyperlinkEx::OnRButtonDown(UINT nFlags, CPoint point) 
{
	::SendMessage(GetParent()->GetSafeHwnd(), SHLE_RBUTTONDOWN, GetDlgCtrlID(), 0);	
	CStatic::OnRButtonDown(nFlags, point);
}

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
I'll think about it later on...

Comments and Discussions