XHyperLink.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. // XHyperLink.cpp Version 1.0
  2. //
  3. // XHyperLink static control. Will open the default browser with the
  4. // given URL when the user clicks on the link.
  5. //
  6. // Copyright (C) 1997 - 1999 Chris Maunder
  7. // All rights reserved. May not be sold for profit.
  8. //
  9. // Thanks to Pål K. Tønder for auto-size and window caption changes.
  10. //
  11. // "GotoURL" function by Stuart Patterson
  12. // As seen in the August, 1997 Windows Developer's Journal.
  13. // Copyright 1997 by Miller Freeman, Inc. All rights reserved.
  14. // Modified by Chris Maunder to use TCHARs instead of chars.
  15. //
  16. // "Default hand cursor" from Paul DiLascia's Jan 1998 MSJ article.
  17. //
  18. // 2/29/00 -- P. Shaffer standard font mod.
  19. //
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Modified by: Hans Dietrich
  23. // hdietrich2@hotmail.com
  24. //
  25. ///////////////////////////////////////////////////////////////////////////////
  26. #include "stdafx.h"
  27. #include "XHyperLink.h"
  28. #include "atlconv.h" // for Unicode conversion
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. #define TOOLTIP_ID 1
  35. // Uncomment following line to enable error message box for URL navigation
  36. //#define XHYPERLINK_REPORT_ERROR
  37. #ifndef IDC_HAND
  38. #define IDC_HAND MAKEINTRESOURCE(32649) // From WINUSER.H
  39. #endif
  40. // sends message to parent when hyperlink is clicked (see SetNotifyParent())
  41. UINT WM_XHYPERLINK_CLICKED = ::RegisterWindowMessage(_T("WM_XHYPERLINK_CLICKED"));
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // CXHyperLink
  44. BEGIN_MESSAGE_MAP(CXHyperLink, CStatic)
  45. //{{AFX_MSG_MAP(CXHyperLink)
  46. ON_WM_CTLCOLOR_REFLECT()
  47. ON_WM_SETCURSOR()
  48. ON_WM_MOUSEMOVE()
  49. ON_WM_TIMER()
  50. ON_CONTROL_REFLECT(STN_CLICKED, OnClicked)
  51. ON_WM_ERASEBKGND()
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // ctor
  56. CXHyperLink::CXHyperLink()
  57. {
  58. m_hLinkCursor = NULL; // No cursor as yet
  59. m_crLinkColour = RGB(0,0,238); // Blue
  60. m_crVisitedColour = RGB(85,26,139); // Purple
  61. m_crHoverColour = RGB(255,0,0); // Red
  62. m_bOverControl = FALSE; // Cursor not yet over control
  63. m_bVisited = FALSE; // Hasn't been visited yet.
  64. m_nUnderline = ulHover; // Underline the link?
  65. m_bAdjustToFit = TRUE; // Resize the window to fit the text?
  66. m_strURL = _T("");
  67. m_nTimerID = 100;
  68. m_bNotifyParent = FALSE; // TRUE = notify parent
  69. m_bIsURLEnabled = TRUE; // TRUE = navigate to url
  70. m_bToolTip = TRUE; // TRUE = display tooltip
  71. m_crBackground = (UINT) -1; // set to default (no bg color)
  72. m_bAlwaysOpenNew = FALSE; // TRUE = always open new browser window
  73. }
  74. ///////////////////////////////////////////////////////////////////////////////
  75. // dtor
  76. CXHyperLink::~CXHyperLink()
  77. {
  78. TRACE(_T("in CXHyperLink::~CXHyperLink\n"));
  79. if (m_hLinkCursor)
  80. DestroyCursor(m_hLinkCursor);
  81. m_hLinkCursor = NULL;
  82. m_UnderlineFont.DeleteObject();
  83. if (m_Brush.GetSafeHandle())
  84. m_Brush.DeleteObject();
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CXHyperLink overrides
  88. ///////////////////////////////////////////////////////////////////////////////
  89. // DestroyWindow
  90. BOOL CXHyperLink::DestroyWindow()
  91. {
  92. KillTimer(m_nTimerID);
  93. return CStatic::DestroyWindow();
  94. }
  95. ///////////////////////////////////////////////////////////////////////////////
  96. // PreTranslateMessage
  97. BOOL CXHyperLink::PreTranslateMessage(MSG* pMsg)
  98. {
  99. m_ToolTip.RelayEvent(pMsg);
  100. return CStatic::PreTranslateMessage(pMsg);
  101. }
  102. ///////////////////////////////////////////////////////////////////////////////
  103. // PreSubclassWindow
  104. void CXHyperLink::PreSubclassWindow()
  105. {
  106. // We want to get mouse clicks via STN_CLICKED
  107. DWORD dwStyle = GetStyle();
  108. ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
  109. // Set the URL as the window text
  110. if (m_strURL.IsEmpty())
  111. GetWindowText(m_strURL);
  112. // Check that the window text isn't empty. If it is, set it as the URL.
  113. CString strWndText;
  114. GetWindowText(strWndText);
  115. if (strWndText.IsEmpty())
  116. {
  117. ASSERT(!m_strURL.IsEmpty()); // Window and URL both NULL. DUH!
  118. SetWindowText(m_strURL);
  119. }
  120. CFont* pFont = GetFont();
  121. if (!pFont)
  122. {
  123. HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
  124. if (hFont == NULL)
  125. hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
  126. if (hFont)
  127. pFont = CFont::FromHandle(hFont);
  128. }
  129. ASSERT(pFont->GetSafeHandle());
  130. // Create the underline font
  131. LOGFONT lf;
  132. pFont->GetLogFont(&lf);
  133. m_StdFont.CreateFontIndirect(&lf);
  134. lf.lfUnderline = (BYTE) TRUE;
  135. m_UnderlineFont.CreateFontIndirect(&lf);
  136. PositionWindow(); // Adjust size of window to fit URL if necessary
  137. SetDefaultCursor(); // Try and load up a "hand" cursor
  138. SetUnderline();
  139. // Create the tooltip
  140. if (m_bToolTip)
  141. {
  142. CRect rect;
  143. GetClientRect(rect);
  144. m_ToolTip.Create(this);
  145. m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
  146. }
  147. CStatic::PreSubclassWindow();
  148. }
  149. /////////////////////////////////////////////////////////////////////////////
  150. // CXHyperLink message handlers
  151. ///////////////////////////////////////////////////////////////////////////////
  152. // OnClicked
  153. void CXHyperLink::OnClicked()
  154. {
  155. m_bOverControl = FALSE;
  156. int result = HINSTANCE_ERROR + 1;
  157. if (m_bIsURLEnabled)
  158. result = (int)GotoURL(m_strURL, SW_SHOW, m_bAlwaysOpenNew);
  159. m_bVisited = (result > HINSTANCE_ERROR);
  160. if (!m_bVisited)
  161. {
  162. MessageBeep(MB_ICONEXCLAMATION); // Unable to follow link
  163. ReportError(result);
  164. }
  165. else
  166. SetVisited(); // Repaint to show visited colour
  167. NotifyParent();
  168. }
  169. ///////////////////////////////////////////////////////////////////////////////
  170. // CtlColor
  171. #ifdef _DEBUG
  172. HBRUSH CXHyperLink::CtlColor(CDC* pDC, UINT nCtlColor)
  173. #else
  174. HBRUSH CXHyperLink::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
  175. #endif
  176. {
  177. ASSERT(nCtlColor == CTLCOLOR_STATIC);
  178. if (m_bOverControl)
  179. pDC->SetTextColor(m_crHoverColour);
  180. else if (m_bVisited)
  181. pDC->SetTextColor(m_crVisitedColour);
  182. else
  183. pDC->SetTextColor(m_crLinkColour);
  184. // transparent text.
  185. pDC->SetBkMode(TRANSPARENT);
  186. if (m_Brush.GetSafeHandle())
  187. {
  188. pDC->SetBkColor(m_crBackground);
  189. return (HBRUSH) m_Brush;
  190. }
  191. else
  192. {
  193. return (HBRUSH)GetStockObject(NULL_BRUSH);
  194. }
  195. }
  196. ///////////////////////////////////////////////////////////////////////////////
  197. // OnMouseMove
  198. void CXHyperLink::OnMouseMove(UINT nFlags, CPoint point)
  199. {
  200. if (!m_bOverControl) // Cursor has just moved over control
  201. {
  202. m_bOverControl = TRUE;
  203. if (m_nUnderline == ulHover)
  204. SetFont(&m_UnderlineFont);
  205. Invalidate();
  206. SetTimer(m_nTimerID, 100, NULL);
  207. }
  208. CStatic::OnMouseMove(nFlags, point);
  209. }
  210. ///////////////////////////////////////////////////////////////////////////////
  211. // OnTimer
  212. void CXHyperLink::OnTimer(UINT nIDEvent)
  213. {
  214. CPoint p(GetMessagePos());
  215. ScreenToClient(&p);
  216. CRect rect;
  217. GetClientRect(rect);
  218. if (!rect.PtInRect(p))
  219. {
  220. m_bOverControl = FALSE;
  221. KillTimer(m_nTimerID);
  222. if (m_nUnderline != ulAlways)
  223. SetFont(&m_StdFont);
  224. rect.bottom+=10;
  225. InvalidateRect(rect);
  226. }
  227. CStatic::OnTimer(nIDEvent);
  228. }
  229. ///////////////////////////////////////////////////////////////////////////////
  230. // OnSetCursor
  231. BOOL CXHyperLink::OnSetCursor(CWnd* /*pWnd*/, UINT /*nHitTest*/, UINT /*message*/)
  232. {
  233. if (m_hLinkCursor)
  234. {
  235. ::SetCursor(m_hLinkCursor);
  236. return TRUE;
  237. }
  238. return FALSE;
  239. }
  240. ///////////////////////////////////////////////////////////////////////////////
  241. // OnEraseBkgnd
  242. BOOL CXHyperLink::OnEraseBkgnd(CDC* pDC)
  243. {
  244. CRect rect;
  245. GetClientRect(rect);
  246. if (m_crBackground != (UINT)-1)
  247. pDC->FillSolidRect(rect, m_crBackground);
  248. else
  249. pDC->FillSolidRect(rect, ::GetSysColor(COLOR_3DFACE));
  250. return TRUE;
  251. }
  252. /////////////////////////////////////////////////////////////////////////////
  253. // CXHyperLink operations
  254. ///////////////////////////////////////////////////////////////////////////////
  255. // SetURL
  256. void CXHyperLink::SetURL(CString strURL)
  257. {
  258. m_strURL = strURL;
  259. if (::IsWindow(GetSafeHwnd()))
  260. {
  261. PositionWindow();
  262. m_ToolTip.UpdateTipText(strURL, this, TOOLTIP_ID);
  263. }
  264. }
  265. ///////////////////////////////////////////////////////////////////////////////
  266. // SetColours
  267. void CXHyperLink::SetColours(COLORREF crLinkColour,
  268. COLORREF crVisitedColour,
  269. COLORREF crHoverColour /* = -1 */)
  270. {
  271. m_crLinkColour = crLinkColour;
  272. m_crVisitedColour = crVisitedColour;
  273. if (crHoverColour == -1)
  274. m_crHoverColour = ::GetSysColor(COLOR_HIGHLIGHT);
  275. else
  276. m_crHoverColour = crHoverColour;
  277. if (::IsWindow(m_hWnd))
  278. Invalidate();
  279. }
  280. ///////////////////////////////////////////////////////////////////////////////
  281. // SetBackgroundColour
  282. void CXHyperLink::SetBackgroundColour(COLORREF crBackground)
  283. {
  284. m_crBackground = crBackground;
  285. if (m_Brush.GetSafeHandle())
  286. m_Brush.DeleteObject();
  287. m_Brush.CreateSolidBrush(m_crBackground);
  288. }
  289. ///////////////////////////////////////////////////////////////////////////////
  290. // SetVisited
  291. void CXHyperLink::SetVisited(BOOL bVisited /* = TRUE */)
  292. {
  293. m_bVisited = bVisited;
  294. if (::IsWindow(GetSafeHwnd()))
  295. Invalidate();
  296. }
  297. ///////////////////////////////////////////////////////////////////////////////
  298. // SetLinkCursor
  299. void CXHyperLink::SetLinkCursor(HCURSOR hCursor)
  300. {
  301. m_hLinkCursor = hCursor;
  302. if (m_hLinkCursor == NULL)
  303. SetDefaultCursor();
  304. }
  305. ///////////////////////////////////////////////////////////////////////////////
  306. // SetUnderline
  307. void CXHyperLink::SetUnderline(int nUnderline /*=ulHover*/)
  308. {
  309. if (m_nUnderline == nUnderline)
  310. return;
  311. if (::IsWindow(GetSafeHwnd()))
  312. {
  313. if (nUnderline == ulAlways)
  314. SetFont(&m_UnderlineFont);
  315. else
  316. SetFont(&m_StdFont);
  317. Invalidate();
  318. }
  319. m_nUnderline = nUnderline;
  320. }
  321. ///////////////////////////////////////////////////////////////////////////////
  322. // SetAutoSize
  323. void CXHyperLink::SetAutoSize(BOOL bAutoSize /* = TRUE */)
  324. {
  325. m_bAdjustToFit = bAutoSize;
  326. if (::IsWindow(GetSafeHwnd()))
  327. PositionWindow();
  328. }
  329. ///////////////////////////////////////////////////////////////////////////////
  330. // SetWindowText
  331. void CXHyperLink::SetWindowText(LPCTSTR lpszString)
  332. {
  333. ASSERT(lpszString);
  334. if (!lpszString)
  335. return;
  336. CStatic::SetWindowText(_T(""));
  337. RedrawWindow();
  338. CStatic::SetWindowText(lpszString);
  339. PositionWindow();
  340. }
  341. ///////////////////////////////////////////////////////////////////////////////
  342. // PositionWindow
  343. // Move and resize the window so that the window is the same size
  344. // as the hyperlink text. This stops the hyperlink cursor being active
  345. // when it is not directly over the text. If the text is left justified
  346. // then the window is merely shrunk, but if it is centred or right
  347. // justified then the window will have to be moved as well.
  348. //
  349. // Suggested by Pål K. Tønder
  350. //
  351. void CXHyperLink::PositionWindow()
  352. {
  353. if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit)
  354. return;
  355. // Get the current window position
  356. CRect WndRect, ClientRect;
  357. GetWindowRect(WndRect);
  358. GetClientRect(ClientRect);
  359. ClientToScreen(ClientRect);
  360. CWnd* pParent = GetParent();
  361. if (pParent)
  362. {
  363. pParent->ScreenToClient(WndRect);
  364. pParent->ScreenToClient(ClientRect);
  365. }
  366. // Get the size of the window text
  367. CString strWndText;
  368. GetWindowText(strWndText);
  369. CDC* pDC = GetDC();
  370. CFont* pOldFont = pDC->SelectObject(&m_UnderlineFont);
  371. CSize Extent = pDC->GetTextExtent(strWndText);
  372. pDC->SelectObject(pOldFont);
  373. ReleaseDC(pDC);
  374. // Adjust for window borders
  375. Extent.cx += WndRect.Width() - ClientRect.Width();
  376. Extent.cy += WndRect.Height() - ClientRect.Height();
  377. // Get the text justification via the window style
  378. DWORD dwStyle = GetStyle();
  379. // Recalc the window size and position based on the text justification
  380. if (dwStyle & SS_CENTERIMAGE)
  381. WndRect.DeflateRect(0, (WndRect.Height() - Extent.cy)/2);
  382. else
  383. WndRect.bottom = WndRect.top + Extent.cy;
  384. if (dwStyle & SS_CENTER)
  385. WndRect.DeflateRect((WndRect.Width() - Extent.cx)/2, 0);
  386. else if (dwStyle & SS_RIGHT)
  387. WndRect.left = WndRect.right - Extent.cx;
  388. else // SS_LEFT = 0, so we can't test for it explicitly
  389. WndRect.right = WndRect.left + Extent.cx;
  390. // Move the window
  391. SetWindowPos(NULL,
  392. WndRect.left, WndRect.top,
  393. WndRect.Width(), WndRect.Height(),
  394. SWP_NOZORDER);
  395. }
  396. /////////////////////////////////////////////////////////////////////////////
  397. // CXHyperLink implementation
  398. ///////////////////////////////////////////////////////////////////////////////
  399. // SetDefaultCursor
  400. void CXHyperLink::SetDefaultCursor()
  401. {
  402. if (m_hLinkCursor == NULL) // No cursor handle - try to load one
  403. {
  404. // First try to load the Win98 / Windows 2000 hand cursor
  405. TRACE(_T("loading from IDC_HAND\n"));
  406. m_hLinkCursor = AfxGetApp()->LoadStandardCursor(IDC_HAND);
  407. if (m_hLinkCursor == NULL) // Still no cursor handle -
  408. // load the WinHelp hand cursor
  409. {
  410. // The following appeared in Paul DiLascia's Jan 1998 MSJ articles.
  411. // It loads a "hand" cursor from the winhlp32.exe module.
  412. TRACE(_T("loading from winhlp32\n"));
  413. // Get the windows directory
  414. CString strWndDir;
  415. GetWindowsDirectory(strWndDir.GetBuffer(MAX_PATH), MAX_PATH);
  416. strWndDir.ReleaseBuffer();
  417. strWndDir += _T("\\winhlp32.exe");
  418. // This retrieves cursor #106 from winhlp32.exe, which is a hand pointer
  419. HMODULE hModule = LoadLibrary(strWndDir);
  420. if (hModule)
  421. {
  422. HCURSOR hHandCursor = ::LoadCursor(hModule, MAKEINTRESOURCE(106));
  423. if (hHandCursor)
  424. m_hLinkCursor = CopyCursor(hHandCursor);
  425. FreeLibrary(hModule);
  426. }
  427. }
  428. }
  429. }
  430. ///////////////////////////////////////////////////////////////////////////////
  431. // GetRegKey
  432. LONG CXHyperLink::GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
  433. {
  434. HKEY hkey;
  435. LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
  436. if (retval == ERROR_SUCCESS)
  437. {
  438. long datasize = MAX_PATH;
  439. TCHAR data[MAX_PATH];
  440. RegQueryValue(hkey, NULL, data, &datasize);
  441. _tcscpy(retdata, data);
  442. RegCloseKey(hkey);
  443. }
  444. return retval;
  445. }
  446. ///////////////////////////////////////////////////////////////////////////////
  447. // ReportError
  448. void CXHyperLink::ReportError(int nError)
  449. {
  450. #ifdef XHYPERLINK_REPORT_ERROR
  451. CString str;
  452. switch (nError)
  453. {
  454. case 0: str = "The operating system is out\nof memory or resources."; break;
  455. case SE_ERR_PNF: str = "The specified path was not found."; break;
  456. case SE_ERR_FNF: str = "The specified file was not found."; break;
  457. case ERROR_BAD_FORMAT: str = "The .EXE file is invalid\n(non-Win32 .EXE or error in .EXE image)."; break;
  458. case SE_ERR_ACCESSDENIED: str = "The operating system denied\naccess to the specified file."; break;
  459. case SE_ERR_ASSOCINCOMPLETE: str = "The filename association is\nincomplete or invalid."; break;
  460. case SE_ERR_DDEBUSY: str = "The DDE transaction could not\nbe completed because other DDE transactions\nwere being processed."; break;
  461. case SE_ERR_DDEFAIL: str = "The DDE transaction failed."; break;
  462. case SE_ERR_DDETIMEOUT: str = "The DDE transaction could not\nbe completed because the request timed out."; break;
  463. case SE_ERR_DLLNOTFOUND: str = "The specified dynamic-link library was not found."; break;
  464. case SE_ERR_NOASSOC: str = "There is no application associated\nwith the given filename extension."; break;
  465. case SE_ERR_OOM: str = "There was not enough memory to complete the operation."; break;
  466. case SE_ERR_SHARE: str = "A sharing violation occurred. ";
  467. default: str.Format(_T("Unknown Error (%d) occurred."), nError); break;
  468. }
  469. str = "Unable to open hyperlink:\n\n" + str;
  470. AfxMessageBox(str, MB_ICONEXCLAMATION | MB_OK);
  471. #else
  472. UNUSED_ALWAYS(nError);
  473. #endif // XHYPERLINK_REPORT_ERROR
  474. }
  475. ///////////////////////////////////////////////////////////////////////////////
  476. // NotifyParent
  477. void CXHyperLink::NotifyParent()
  478. {
  479. if (m_bNotifyParent)
  480. {
  481. CWnd *pParent = GetParent();
  482. if (pParent && ::IsWindow(pParent->m_hWnd))
  483. {
  484. // wParam will contain control id
  485. pParent->SendMessage(WM_XHYPERLINK_CLICKED, GetDlgCtrlID());
  486. }
  487. }
  488. }
  489. ///////////////////////////////////////////////////////////////////////////////
  490. // GotoURL
  491. HINSTANCE CXHyperLink::GotoURL(LPCTSTR url, int showcmd, BOOL bAlwaysOpenNew /*= FALSE*/)
  492. {
  493. // if no url then this is not an internet link
  494. if (!url || url[0] == _T('\0'))
  495. return (HINSTANCE) HINSTANCE_ERROR + 1;
  496. TCHAR key[MAX_PATH*2];
  497. // First try ShellExecute()
  498. TCHAR *verb = _T("open");
  499. if (bAlwaysOpenNew)
  500. verb = _T("new");
  501. HINSTANCE result = ShellExecute(NULL, verb, url, NULL,NULL, showcmd);
  502. // If it failed, get the .htm regkey and lookup the program
  503. if ((UINT)result <= HINSTANCE_ERROR)
  504. {
  505. if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS)
  506. {
  507. _tcscat(key, _T("\\shell\\open\\command"));
  508. if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS)
  509. {
  510. TCHAR *pos;
  511. pos = _tcsstr(key, _T("\"%1\""));
  512. if (pos == NULL)
  513. { // No quotes found
  514. pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes
  515. if (pos == NULL) // No parameter at all...
  516. pos = key + _tcslen(key)-1;
  517. else
  518. *pos = _T('\0'); // Remove the parameter
  519. }
  520. else
  521. {
  522. *pos = _T('\0'); // Remove the parameter
  523. }
  524. _tcscat(pos, _T(" "));
  525. _tcscat(pos, url);
  526. USES_CONVERSION;
  527. result = (HINSTANCE) WinExec(T2A(key),showcmd);
  528. }
  529. }
  530. }
  531. return result;
  532. }