- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# StaticLink.h

    00001 /*
    00002  *      Copyright (C) 2003-2005 Gabest
    00003  *      http://www.gabest.org
    00004  *
    00005  *  This Program is free software; you can redistribute it and/or modify
    00006  *  it under the terms of the GNU General Public License as published by
    00007  *  the Free Software Foundation; either version 2, or (at your option)
    00008  *  any later version.
    00009  *
    00010  *  This Program is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    00013  *  GNU General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU General Public License
    00016  *  along with GNU Make; see the file COPYING.  If not, write to
    00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00018  *  http://www.gnu.org/copyleft/gpl.html
    00019  *
    00020  */
    00021
    00022 #pragma once
    00023
    00024 // CHyperlink
    00025
    00026 class CHyperlink : public CString {
    00027 public:
    00028     CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
    00029     ~CHyperlink() { }
    00030     const CHyperlink& operator=(LPCTSTR lpsz) {
    00031         CString::operator=(lpsz);
    00032         return *this;
    00033     }
    00034     operator LPCTSTR() {
    00035         return CString::operator LPCTSTR();
    00036     }
    00037     virtual HINSTANCE Navigate() {
    00038         return IsEmpty() ? NULL :
    00039             ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
    00040     }
    00041 };
    00042
    00043 // CStaticLink
    00044
    00045 class CStaticLink : public CStatic
    00046 {
    00047 public:
    00048     DECLARE_DYNAMIC(CStaticLink)
    00049     CStaticLink(LPCTSTR lpText = NULL, BOOL bDeleteOnDestroy=FALSE);
    00050     ~CStaticLink() { }
    00051
    00052     // Hyperlink contains URL/filename. If NULL, I will use the window text.
    00053     // (GetWindowText) to get the target.
    00054     CHyperlink    m_link;
    00055     COLORREF        m_color;
    00056
    00057     // Default colors you can change
    00058     // These are global, so they're the same for all links.
    00059     static COLORREF g_colorUnvisited;
    00060     static COLORREF g_colorVisited;
    00061
    00062     // Cursor used when mouse is on a link--you can set, or
    00063     // it will default to the standard hand with pointing finger.
    00064     // This is global, so it's the same for all links.
    00065     static HCURSOR     g_hCursorLink;
    00066
    00067 protected:
    00068     CFont            m_font;                    // underline font for text control
    00069     BOOL            m_bDeleteOnDestroy;    // delete object when window destroyed?
    00070
    00071     virtual void PostNcDestroy();
    00072
    00073     // message handlers
    00074     DECLARE_MESSAGE_MAP()
    00075     afx_msg LRESULT    OnNcHitTest(CPoint point);
    00076     afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
    00077     afx_msg void    OnLButtonDown(UINT nFlags, CPoint point);
    00078     afx_msg BOOL    OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
    00079 };
    00080
    00081