Crypt Library Demo 1.00
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

CHyperlinkStatic Class Reference

#include <HyperlinkStatic.h>

List of all members.

Public Member Functions

 CHyperlinkStatic ()
virtual ~CHyperlinkStatic ()
void SetHyperlink (CString strHyperlink)
void SetCaption (CString strCaption)

Protected Member Functions

virtual void PreSubclassWindow ()
afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
afx_msg void OnPaint ()
afx_msg void OnDestroy ()
afx_msg void OnMouseMove (UINT nFlags, CPoint point)
afx_msg LRESULT OnMouseLeave (WPARAM wParam, LPARAM lParam)

Private Member Functions

void CreateFont ()
void GetCaptionSize ()
bool InCaptionRange (CPoint &point)

Private Attributes

CString _strCaption
CString _strHyperlink
CFont _fontCaption
CSize _sizeCaption
bool _bCreateFont
bool _bMouseInControl
bool _bGetCaptionSize
HCURSOR _hHandCursor
HCURSOR _hArrowCursor

Detailed Description

Definition at line 17 of file HyperlinkStatic.h.


Constructor & Destructor Documentation

CHyperlinkStatic::CHyperlinkStatic ( )

Definition at line 16 of file HyperlinkStatic.cpp.

{
    _strCaption = _strHyperlink = _T("");    
    _bMouseInControl = _bCreateFont = _bGetCaptionSize = false;

    _hHandCursor = ::LoadCursor(0, MAKEINTRESOURCE(IDC_HAND));
    _hArrowCursor = ::LoadCursor(0, MAKEINTRESOURCE(IDC_ARROW));
}
CHyperlinkStatic::~CHyperlinkStatic ( ) [virtual]

Definition at line 25 of file HyperlinkStatic.cpp.

{
}

Member Function Documentation

void CHyperlinkStatic::CreateFont ( ) [private]

Definition at line 116 of file HyperlinkStatic.cpp.

{
    CFont* pFontParent = GetParent()->GetFont();    
    if ( pFontParent ) {
        LOGFONT lf;
        pFontParent->GetObject(sizeof(lf), &lf);
        lf.lfUnderline = TRUE;      
        _fontCaption.CreateFontIndirect(&lf);
        _bCreateFont = true;
    }
}

Here is the caller graph for this function:

void CHyperlinkStatic::GetCaptionSize ( ) [private]

Definition at line 128 of file HyperlinkStatic.cpp.

{
    if (( _bGetCaptionSize == false ) && ( _bCreateFont )) {
        CClientDC dc(this);
        CFont *pOldFont = dc.SelectObject(&_fontCaption);
        _sizeCaption = dc.GetTextExtent(_strCaption);
        dc.SelectObject(pOldFont);
        _bGetCaptionSize = true;
    }
}

Here is the caller graph for this function:

bool CHyperlinkStatic::InCaptionRange ( CPoint &  point) [private]

Definition at line 139 of file HyperlinkStatic.cpp.

{
    if ( _bGetCaptionSize == false )
        return false;
    return (( point.x >= 0 )&&( point.x < _sizeCaption.cx ) &&
            ( point.y >= 0 )&&( point.y < _sizeCaption.cy ));
}

Here is the caller graph for this function:

void CHyperlinkStatic::OnDestroy ( ) [protected]

Definition at line 74 of file HyperlinkStatic.cpp.

{
    CStatic::OnDestroy();
    _fontCaption.DeleteObject();
}
void CHyperlinkStatic::OnLButtonDown ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 53 of file HyperlinkStatic.cpp.

{
    if ( _bGetCaptionSize == false )
        GetCaptionSize();
    if (InCaptionRange(point))
        ShellExecute(0, _T("open"), _strHyperlink, 0, 0, SW_SHOWNORMAL);
    CStatic::OnLButtonDown(nFlags, point);
}

Here is the call graph for this function:

LRESULT CHyperlinkStatic::OnMouseLeave ( WPARAM  wParam,
LPARAM  lParam 
) [protected]

Definition at line 88 of file HyperlinkStatic.cpp.

{
    UNREFERENCED_PARAMETER(wParam);
    UNREFERENCED_PARAMETER(lParam);
    _bMouseInControl = false;
    ::SetCursor(_hArrowCursor); 
    return 0;
}
void CHyperlinkStatic::OnMouseMove ( UINT  nFlags,
CPoint  point 
) [protected]

Definition at line 97 of file HyperlinkStatic.cpp.

{
    if ( _bMouseInControl == false ) {
        //Track the mouse leave event
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(tme);
        tme.hwndTrack = GetSafeHwnd();
        tme.dwFlags = TME_LEAVE;        
        _TrackMouseEvent(&tme);
        _bMouseInControl = true;
    }
    else {
        if ( _bGetCaptionSize == false )
            GetCaptionSize();
        ::SetCursor((InCaptionRange(point))?_hHandCursor:_hArrowCursor);        
    }
    CStatic::OnMouseMove(nFlags, point);
}

Here is the call graph for this function:

void CHyperlinkStatic::OnPaint ( ) [protected]

Definition at line 62 of file HyperlinkStatic.cpp.

{   
    if ( _bCreateFont == false )
        CreateFont();
    CPaintDC dc(this);
    CFont *pOldFont = (CFont*)dc.SelectObject(&_fontCaption);
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(RGB(0,0,255));
    dc.TextOut(0, 0, _strCaption);
    dc.SelectObject(pOldFont);
}

Here is the call graph for this function:

void CHyperlinkStatic::PreSubclassWindow ( ) [protected, virtual]

Definition at line 80 of file HyperlinkStatic.cpp.

{
    ModifyStyle(0, SS_NOTIFY, TRUE);
    GetWindowText(_strCaption);
    _bGetCaptionSize = false;
    CStatic::PreSubclassWindow();
}
void CHyperlinkStatic::SetCaption ( CString  strCaption)

Definition at line 47 of file HyperlinkStatic.cpp.

{
    _strCaption = strCaption;
    _bGetCaptionSize = false;   
}
void CHyperlinkStatic::SetHyperlink ( CString  strHyperlink)

Definition at line 42 of file HyperlinkStatic.cpp.

{
    _strHyperlink = strHyperlink;
}

Member Data Documentation

Definition at line 57 of file HyperlinkStatic.h.

Definition at line 57 of file HyperlinkStatic.h.

Definition at line 57 of file HyperlinkStatic.h.

Definition at line 55 of file HyperlinkStatic.h.

Definition at line 58 of file HyperlinkStatic.h.

HCURSOR CHyperlinkStatic::_hHandCursor [private]

Definition at line 58 of file HyperlinkStatic.h.

Definition at line 56 of file HyperlinkStatic.h.

CString CHyperlinkStatic::_strCaption [private]

Definition at line 54 of file HyperlinkStatic.h.

Definition at line 54 of file HyperlinkStatic.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerator Defines