00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include "StaticLink.h"
00028
00029
00030
00031
00032 COLORREF CStaticLink::g_colorUnvisited = RGB(0,0,255);
00033 COLORREF CStaticLink::g_colorVisited = RGB(128,0,128);
00034
00035 HCURSOR CStaticLink::g_hCursorLink = NULL;
00036
00037 IMPLEMENT_DYNAMIC(CStaticLink, CStatic)
00038
00039 BEGIN_MESSAGE_MAP(CStaticLink, CStatic)
00040 ON_WM_NCHITTEST()
00041 ON_WM_CTLCOLOR_REFLECT()
00042 ON_WM_LBUTTONDOWN()
00043 ON_WM_SETCURSOR()
00044 END_MESSAGE_MAP()
00045
00047
00048
00049
00050 CStaticLink::CStaticLink(LPCTSTR lpText, BOOL bDeleteOnDestroy)
00051 {
00052 m_link = lpText;
00053 m_color = g_colorUnvisited;
00054 m_bDeleteOnDestroy = bDeleteOnDestroy;
00055 }
00056
00058
00059
00060
00061
00062
00063 LRESULT CStaticLink::OnNcHitTest(CPoint point)
00064 {
00065 return HTCLIENT;
00066 }
00067
00069
00070
00071
00072
00073 HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
00074 {
00075 ASSERT(nCtlColor == CTLCOLOR_STATIC);
00076 DWORD dwStyle = GetStyle();
00077
00078 HBRUSH hbr = NULL;
00079 if ((dwStyle & 0xFF) <= SS_RIGHT) {
00080
00081
00082 if (!(HFONT)m_font) {
00083
00084 LOGFONT lf;
00085 GetFont()->GetObject(sizeof(lf), &lf);
00086 lf.lfUnderline = TRUE;
00087 m_font.CreateFontIndirect(&lf);
00088 }
00089
00090
00091 pDC->SelectObject(&m_font);
00092 pDC->SetTextColor(m_color);
00093 pDC->SetBkMode(TRANSPARENT);
00094
00095
00096 hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
00097 }
00098 return hbr;
00099 }
00100
00102
00103
00104 void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
00105 {
00106 if (m_link.IsEmpty()) {
00107
00108 m_link.LoadString(GetDlgCtrlID()) || (GetWindowText(m_link),1);
00109 if (m_link.IsEmpty())
00110 return;
00111 }
00112
00113
00114
00115
00116 HINSTANCE h = m_link.Navigate();
00117 if ((UINT)h > 32) {
00118 m_color = g_colorVisited;
00119 Invalidate();
00120 } else {
00121 MessageBeep(0);
00122 TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
00123 (LPCTSTR)m_link);
00124 }
00125 }
00126
00128
00129
00130
00131
00132
00133 BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00134 {
00135 if (g_hCursorLink == NULL) {
00136 static BOOL bTriedOnce = FALSE;
00137 if (!bTriedOnce) {
00138 CString windir;
00139 GetWindowsDirectory(windir.GetBuffer(MAX_PATH), MAX_PATH);
00140 windir.ReleaseBuffer();
00141 windir += _T("\\winhlp32.exe");
00142 HMODULE hModule = LoadLibrary(windir);
00143 if (hModule) {
00144 g_hCursorLink =
00145 CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
00146 }
00147 FreeLibrary(hModule);
00148 bTriedOnce = TRUE;
00149 }
00150 }
00151 if (g_hCursorLink) {
00152 ::SetCursor(g_hCursorLink);
00153 return TRUE;
00154 }
00155 return FALSE;
00156 }
00157
00159
00160
00161
00162
00163
00164
00165
00166 void CStaticLink::PostNcDestroy()
00167 {
00168 if (m_bDeleteOnDestroy)
00169 delete this;
00170 }
00171