OSDN Git Service

Use SysLink control instead of CStaticLink class
authorsdottaka <sdottaka@users.sourceforge.net>
Thu, 7 May 2015 15:38:24 +0000 (00:38 +0900)
committersdottaka <sdottaka@users.sourceforge.net>
Thu, 7 May 2015 15:38:24 +0000 (00:38 +0900)
--HG--
branch : stable

Src/AboutDlg.cpp
Src/AboutDlg.h
Src/Common/StatLink.cpp [deleted file]
Src/Common/StatLink.h [deleted file]
Src/Merge.rc
Src/Merge.vcxproj
Src/Merge.vcxproj.filters
Src/PropArchive.h
Translations/WinMerge/English.pot

index df7c9a8..8677ecc 100644 (file)
@@ -36,6 +36,7 @@ BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
        ON_BN_CLICKED(IDC_OPEN_CONTRIBUTORS, OnBnClickedOpenContributors)
        ON_WM_DRAWITEM()
        ON_WM_CTLCOLOR()
+       ON_NOTIFY(NM_CLICK, IDC_WWW, OnBnClickedWWW)
 END_MESSAGE_MAP()
 
 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
@@ -47,7 +48,6 @@ void CAboutDlg::DoDataExchange(CDataExchange* pDX)
        CDialog::DoDataExchange(pDX);
        //{{AFX_DATA_MAP(CAboutDlg)
        DDX_Control(pDX, IDC_COMPANY, m_ctlCompany);
-       DDX_Control(pDX, IDC_WWW, m_ctlWWW);
        DDX_Text(pDX, IDC_VERSION, m_strVersion);
        DDX_Text(pDX, IDC_PRIVATEBUILD, m_strPrivateBuild);
        //}}AFX_DATA_MAP
@@ -115,7 +115,10 @@ BOOL CAboutDlg::OnInitDialog()
        copyright += version.GetLegalCopyright();
        copyright += _T(" All rights reserved.");
        m_ctlCompany.SetWindowText(copyright.c_str());
-       m_ctlWWW.m_link = WinMergeURL;
+       CString link;
+       GetDlgItem(IDC_WWW)->GetWindowText(link);
+       link = CString(_T("<a href=\"")) + WinMergeURL + CString(_T("\">")) + link + _T("</a>");
+       GetDlgItem(IDC_WWW)->SetWindowText(link);
 
        UpdateData(FALSE);
        
@@ -171,4 +174,8 @@ void CAboutDlg::OnBnClickedOpenContributors()
                ResMsgBox1(IDS_ERROR_FILE_NOT_FOUND, docPath.c_str(), MB_ICONSTOP);
 }
 
-
+void CAboutDlg::OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult)
+{
+       PNMLINK pNMLink = (PNMLINK)pNMHDR;
+       ShellExecute(NULL, _T("open"), pNMLink->item.szUrl, NULL, NULL, SW_SHOWNORMAL);
+}
index 6c97bef..62ed525 100644 (file)
@@ -22,7 +22,6 @@
  */
 #pragma once
 
-#include "statlink.h"
 #include "Picture.h"
 #include "resource.h" // IDD_ABOUTBOX
 
@@ -41,7 +40,6 @@ public:
        //{{AFX_DATA(CAboutDlg)
        enum { IDD = IDD_ABOUTBOX };
        CStatic m_ctlCompany;
-       CStaticLink     m_ctlWWW;
        CString m_strVersion;
        CString m_strPrivateBuild;
        CPicture m_image;
@@ -64,4 +62,5 @@ public:
        afx_msg void OnBnClickedOpenContributors();
        afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
        afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+       afx_msg void OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult);
 };
diff --git a/Src/Common/StatLink.cpp b/Src/Common/StatLink.cpp
deleted file mode 100644 (file)
index 7f8865c..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-////////////////////////////////////////////////////////////////
-// CStaticLink 1997 Microsoft Systems Journal.
-// If this program works, it was written by Paul DiLascia.
-// If not, I don't know who wrote it.
-//
-// CStaticLink implements a static control that's a hyperlink
-// to any file on your desktop or web. You can use it in dialog boxes
-// to create hyperlinks to web sites. When clicked, opens the file/URL
-//
-#include "StdAfx.h"
-#include "StatLink.h"
-#include "resource.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-IMPLEMENT_DYNAMIC(CStaticLink, CStatic)
-
-BEGIN_MESSAGE_MAP(CStaticLink, CStatic)
-       ON_WM_CTLCOLOR_REFLECT()
-       ON_CONTROL_REFLECT(STN_CLICKED, OnClicked)
-       ON_WM_SETCURSOR()
-END_MESSAGE_MAP()
-
-///////////////////
-// Constructor sets default colors = blue/purple.
-//
-CStaticLink::CStaticLink()
-{
-       m_colorUnvisited = RGB(0,0,255);                 // blue
-       m_colorVisited   = RGB(128,0,128);       // purple
-       m_bVisited       = FALSE;                                // not visited yet
-       m_hCursor = ::LoadCursor(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MERGEHAND));
-}
-
-CStaticLink::~CStaticLink()
-{
-       DestroyCursor(m_hCursor);
-}
-
-//////////////////
-// Handle reflected WM_CTLCOLOR to set custom control color.
-// For a text control, use visited/unvisited colors and underline font.
-// For non-text controls, do nothing. Also ensures SS_NOTIFY is on.
-//
-HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
-{
-       DWORD dwStyle = GetStyle();
-       if (!(dwStyle & SS_NOTIFY)) {
-               // Turn on notify flag to get mouse messages and STN_CLICKED.
-               // Otherwise, I'll never get any mouse clicks!
-               ::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | SS_NOTIFY);
-       }
-
-       HBRUSH hbr = NULL;
-       if ((dwStyle & 0xFF) <= SS_RIGHT) {
-
-               // this is a text control: set up font and colors
-               if (!(HFONT)m_font) {
-                       // first time init: create font
-                       LOGFONT lf;
-                       GetFont()->GetObject(sizeof(lf), &lf);
-                       lf.lfUnderline = TRUE;
-                       m_font.CreateFontIndirect(&lf);
-               }
-
-               // use underline font and visited/unvisited colors
-               pDC->SelectObject(&m_font);
-               pDC->SetTextColor(m_bVisited ? m_colorVisited : m_colorUnvisited);
-               pDC->SetBkMode(TRANSPARENT);
-
-               // return hollow brush to preserve parent background color
-               hbr = (HBRUSH)::GetStockObject(HOLLOW_BRUSH);
-       }
-       return hbr;
-}
-
-/////////////////
-// Handle mouse click: open URL/file.
-//
-void CStaticLink::OnClicked()
-{
-       if (m_link.IsEmpty())           // if URL/filename not set..
-               GetWindowText(m_link);  // ..get it from window text
-
-       // Call ShellExecute to run the file.
-       // For an URL, this means opening it in the browser.
-       //
-       HINSTANCE h = ShellExecute(NULL, _T("open"), m_link, NULL, NULL, SW_SHOWNORMAL);
-       if ((UINT)h > 32) {
-               m_bVisited = TRUE;      // (not really--might not have found link)
-               Invalidate();                   // repaint to show visited color
-       } else {
-               MessageBeep(0);         // unable to execute file!
-               TRACE(_T("*** WARNING: CStaticLink: unable to execute file %s\n"),
-                       (LPCTSTR)m_link);
-       }
-}
-
-BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
-{
-       ASSERT(m_hCursor != NULL);
-       ::SetCursor(m_hCursor);
-       return TRUE;
-}
\ No newline at end of file
diff --git a/Src/Common/StatLink.h b/Src/Common/StatLink.h
deleted file mode 100644 (file)
index 5749061..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-////////////////////////////////////////////////////////////////
-// CStaticLink 1997 Microsoft Systems Journal. 
-// If this program works, it was written by Paul DiLascia.
-// If not, I don't know who wrote it.
-//
-
-////////////////
-// CStaticLink implements a static control that's a hyperlink
-// to any file on your desktop or web. You can use it in dialog boxes
-// to create hyperlinks to web sites. When clicked, opens the file/URL
-//
-#include <afxwin.h>
-
-class CStaticLink : public CStatic {
-public:
-       CStaticLink();
-       ~CStaticLink();
-
-       // you can change these any time:
-       COLORREF         m_colorUnvisited;               // color for unvisited
-       COLORREF         m_colorVisited;                         // color for visited
-       BOOL             m_bVisited;                             // whether visited or not
-
-       // URL/filename for non-text controls (eg icon, bitmap) or when link is
-       // different from window text. If you don't set this, CStaticIcon will
-       // use GetWindowText to get the link.
-       CString  m_link;
-
-protected:
-       DECLARE_DYNAMIC(CStaticLink)
-       CFont            m_font;                                                 // underline font for text control
-       HCURSOR         m_hCursor;
-
-       // message handlers
-       afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
-       afx_msg void    OnClicked();
-       afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
-       DECLARE_MESSAGE_MAP()
-};
index 6dcb5e0..992184f 100644 (file)
@@ -833,7 +833,7 @@ BEGIN
     LTEXT           "",IDC_STATIC,7,60,200,120
     LTEXT           "Version 1.0",IDC_VERSION,240,153,133,20,SS_NOPREFIX
     LTEXT           "(Private Build)",IDC_PRIVATEBUILD,240,173,133,9
-    LTEXT           "Visit the WinMerge HomePage!",IDC_WWW,80,220,207,10,SS_CENTER
+       CONTROL         "Visit the WinMerge HomePage!",IDC_WWW,"SysLink",LWS_TRANSPARENT|LWS_IGNORERETURN,120,220,167,10
     LTEXT           "[VERSION COPYRIGHT GOES HERE]",IDC_COMPANY,7,175,350,40
     DEFPUSHBUTTON   "OK",IDOK,295,218,65,14
     PUSHBUTTON      "Contributors",IDC_OPEN_CONTRIBUTORS,7,218,65,14
index 5eb0fae..b045f0a 100644 (file)
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UnicodeDebug|x64'">NotUsing</PrecompiledHeader>\r
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Unicode + Code Analysis|x64'">NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
-    <ClCompile Include="Common\StatLink.cpp">\r
-    </ClCompile>\r
     <ClCompile Include="StdAfx.cpp">\r
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='UnicodeDebug|Win32'">Create</PrecompiledHeader>\r
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Unicode + Code Analysis|Win32'">Create</PrecompiledHeader>\r
     <ClInclude Include="Common\SortHeaderCtrl.h" />\r
     <ClInclude Include="Common\SplitterWndEx.h" />\r
     <ClInclude Include="ssapi.h" />\r
-    <ClInclude Include="Common\StatLink.h" />\r
     <ClInclude Include="StdAfx.h" />\r
     <ClInclude Include="stringdiffs.h" />\r
     <ClInclude Include="stringdiffsi.h" />\r
index 94e0fe1..4481437 100644 (file)
     <ClCompile Include="VssPromptDlg.cpp">\r
       <Filter>MFCGui\Dialogs</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="Common\StatLink.cpp">\r
-      <Filter>MFCGui\Common</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="Common\SuperComboBox.cpp">\r
       <Filter>MFCGui\Common</Filter>\r
     </ClCompile>\r
     <ClInclude Include="Common\SuperComboBox.h">\r
       <Filter>MFCGui\Common</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="Common\StatLink.h">\r
-      <Filter>MFCGui\Common</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="Common\SortHeaderCtrl.h">\r
       <Filter>MFCGui\Common</Filter>\r
     </ClInclude>\r
index 3417d77..e8d2ac4 100644 (file)
@@ -6,7 +6,6 @@
  */
 #pragma once
 
-#include "StatLink.h"
 #include "OptionsPanel.h"
 
 class COptionsMgr;
index a83b028..7ded56d 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: WinMerge\n"
 "Report-Msgid-Bugs-To: http://bugs.winmerge.org/\n"
-"POT-Creation-Date: 2015-05-07 17:50+0000\n"
+"POT-Creation-Date: 2015-05-08 00:36+0000\n"
 "PO-Revision-Date: \n"
 "Last-Translator: \n"
 "Language-Team: English <winmerge-translate@lists.sourceforge.net>\n"