Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. hyperlink in text box

hyperlink in text box

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    si_69
    wrote on last edited by
    #1

    Hi All i have a edit control, which i use to display text, within this text there is usually a web address. is it possible for me to make this a hyperlink ? or display a hyperlink within a text box ?? thanks si

    D A R 3 Replies Last reply
    0
    • S si_69

      Hi All i have a edit control, which i use to display text, within this text there is usually a web address. is it possible for me to make this a hyperlink ? or display a hyperlink within a text box ?? thanks si

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Have you considered a rich-edit control?


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      1 Reply Last reply
      0
      • S si_69

        Hi All i have a edit control, which i use to display text, within this text there is usually a web address. is it possible for me to make this a hyperlink ? or display a hyperlink within a text box ?? thanks si

        A Offline
        A Offline
        ashxly
        wrote on last edited by
        #3

        you'd better custom-draw your edit control

        1 Reply Last reply
        0
        • S si_69

          Hi All i have a edit control, which i use to display text, within this text there is usually a web address. is it possible for me to make this a hyperlink ? or display a hyperlink within a text box ?? thanks si

          R Offline
          R Offline
          RobJones
          wrote on last edited by
          #4

          As David posted earlier, you could do this with a RichEdit control.. Here's how I have done it in the past.. the example is using a RichEdit control in a dialog box..

          // Inside the Init of the dialog..
          unsigned mask = m_cRichEdit.GetEventMask();
          m_cRichEdit.SetEventMask(mask | ENM_LINK);
          m_cRichEdit.SendMessage(EM_AUTOURLDETECT,TRUE,0);

          // Inside WindowProc of the dialog..
          if(message == WM_NOTIFY)
          {
          // ENABLE URL LINKS IN OUR RICH EDIT CONTROL.
          if(((LPNMHDR)lParam)->code == EN_LINK)
          {
          ENLINK* p = (ENLINK *)lParam;
          if (p->msg == WM_LBUTTONDOWN)
          {
          ENLINK* p = (ENLINK *)lParam;
          m_cRichEdit.SendMessage(EM_EXSETSEL, 0, (LPARAM)&(p->chrg));
          m_cRichEdit.SetSel(p->chrg);
          CString strLink = m_cRichEdit.GetSelText();
          ShellExecute(NULL, "open", strLink, NULL, NULL, SW_SHOWNORMAL);
          }
          }
          }

          Don't forget to do a AfxInitRichEdit(); inside the Init of the APP.. Hope this helps, Rob Whoever said nothing's impossible never tried slamming a revolving door!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups