Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Hyperlink launching

Posted on 1999-07-15
Medium Priority
Last Modified: 2013-11-20
Hi all!
How can I launch a browser to a URL address stored in a string?
I mean I've got a static text contol contining a string representing an URL address and I want to go to that address when I click the control...
Thanx a lot!
Question by:atti75
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 23

Accepted Solution

naveenkohli earned 150 total points
ID: 1310027
Derive a class from Cstatic for you static control. And then handle STN_CLICKED message which is like button click message.

Here is some part of the clss you can derive .....

class CHyperLink : public CStatic {
afx_msg void OnClicked ();


void CHyperLink::OnClicked()
// First try to execute the URL from shell.

      HINSTANCE hResult = ShellExecute (NULL, _T("Open"), urlStr, NULL,
            NULL, show);

      // If it fails then get the htm registry key.
      if ((UINT)hResult <= HINSTANCE_ERROR) {
            if (GetRegKey (HKEY_CLASSES_ROOT, _T("urlStr"), key) == ERROR_SUCCESS) {
                  lstrcat (key, _T("\\shell\\open\\command"));
                  if (GetRegKey (HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) {
                        TCHAR *pos;
                        pos = _tcsstr (key, _T("\"%1\""));
                        if (pos == NULL) {            // No quotes found.
                              pos = _tcsstr (key, _T("%1"));      // Check without quotes
                              if (pos == NULL) {
                                    pos = key + strlen(key) - 1;
                              else {
                                    pos = '\0';
                        else {
                              pos = '\0';

                        lstrcat (pos, _T(" "));
                        lstrcat (pos, urlStr);

                        hResult = (HINSTANCE) WinExec (pos, show);

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question