WTL Controls
Back to the WTL Controls Home Page.
HyperlinkImage.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 //--------------------------------------------------------------------------------------
3 //--------------------------------------------------------------------------------------
4 //
5 //
6 // WTL Control Library
7 // by
8 // Bright Ideas Software®
9 // Copyright © 2018 by Bright Ideas Software.
10 //
11 //
12 //
13 //--------------------------------------------------------------------------------------
14 //--------------------------------------------------------------------------------------
15 
16 
17 namespace BIS_WTL_CONTROLS
18 {
19  //----------------------------------------------------------------------------------------------
21  {
22  m_bMsgHandled = FALSE;
23  }
24  //----------------------------------------------------------------------------------------------
26  {
27 
28  }
29  //----------------------------------------------------------------------------------------------
30  //----------------------------------------------------------------------------------------------
42  {
43 
44  CWindowImpl<CHyperlinkImage, CStatic>::SubclassWindow(hWnd);
45  ModifyStyle(0, SS_NOTIFY);
46 
47  }
48  //----------------------------------------------------------------------------------------------
57  {
58  UnsubclassWindow();
59  }
60  //----------------------------------------------------------------------------------------------
61  //----------------------------------------------------------------------------------------------
71  void CHyperlinkImage::SetURL(std::basic_string<TCHAR> url)
72  {
73  m_strURL = url.c_str();
74  }
75  //----------------------------------------------------------------------------------------------
84  std::basic_string<TCHAR> CHyperlinkImage::GetURL() const
85  {
86  return((LPCTSTR)m_strURL);
87  }
88  //----------------------------------------------------------------------------------------------
89  //----------------------------------------------------------------------------------------------
99  void CHyperlinkImage::SetMenuText(std::basic_string<TCHAR> text)
100  {
101  m_strMenuText = text.c_str();
102  }
103  //----------------------------------------------------------------------------------------------
112  std::basic_string<TCHAR> CHyperlinkImage::GetMenuText() const
113  {
114  return((LPCTSTR)m_strMenuText);
115  }
116  //----------------------------------------------------------------------------------------------
117  //----------------------------------------------------------------------------------------------
118  //
119  // Message Handlers
120  //
121  //----------------------------------------------------------------------------------------------
122  //----------------------------------------------------------------------------------------------
123  void CHyperlinkImage::OnContextMenu(CWindow wnd, CPoint point)
124  {
125  CMenu menu;
126  menu.LoadMenu(IDR_HYPERLINKIMAGE_POPUP);
127  CMenuHandle pContextMenu = menu.GetSubMenu(0);
128 
129 
130  pContextMenu.ModifyMenu(IDM_HYPERLINKIMAGE_LINK, MF_STRING | MF_BYCOMMAND,
131  IDM_HYPERLINKIMAGE_LINK, m_strMenuText);
132 
133 
134  POINT pt;
135  pt.x = point.x;
136  pt.y = point.y;
137  ClientToScreen(&pt);
138  TrackPopupMenu(pContextMenu.m_hMenu, TPM_LEFTALIGN, pt.x, pt.y, 0, m_hWnd, 0);
139 
140  }
141  //----------------------------------------------------------------------------------------------
142  void CHyperlinkImage::OnRButtonDown(UINT nFlags, CPoint point)
143  {
144  OnContextMenu(m_hWnd, point);
145  }
146  //----------------------------------------------------------------------------------------------
147  LRESULT CHyperlinkImage::OnLink(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& bHandled)
148  {
149 
150  if ( ! m_strURL.IsEmpty())
151  ::ShellExecute( m_hWnd, _T("open"), m_strURL, NULL, NULL, SW_SHOWNORMAL );
152 
153  bHandled = FALSE;
154  return(0);
155 // return(DefWindowProc());
156  }
157  //----------------------------------------------------------------------------------------------
158 };
#define IDR_HYPERLINKIMAGE_POPUP
#define IDM_HYPERLINKIMAGE_LINK