Visual C++ : How can put a clickable URL in a dialog?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Visual C++ : How can put a clickable URL in a dialog?

  1. #1
    Join Date
    Jun 2010
    Posts
    1

    Visual C++ : How can put a clickable URL in a dialog?

    How can put a clickable URL in a dialog?
    It’s getting quite common these days to place a URL to a web site in about boxes. But how do you this in a typical MFC app? Well, first you need a static which will respond to being clicked. Let’s assume you have a static named IDC_URL in your dialog, which has as its text the URL for your website. You need to apply the SS_NOTIFY style to this static (i.e. check the Notify checkbox in the static’s properties dialog). Then you need to override the WM_COMMAND handler for the dialog which hosts the static, and place code something like that below in it:
    view plaincopy to clipboardprint?
    Code:
    BOOL CTestbed2Dlg::OnCommand(WPARAM wParam, LPARAM lParam)  
    {  
       CString csURL;  
      
       if (HIWORD(wParam) == STN_CLICKED)  
       {  
          if (LOWORD(wParam) == IDC_URL)  
          {  
             FromHandle ((HWND)lParam)->GetWindowText (csURL);  
             ShellExecute (GetSafeHwnd(),  
                           "open",  
                           csURL,  
                           NULL,  
                           NULL,  
                           SW_SHOWNORMAL);  
             return TRUE;  
          }  
       }  
       return (CDialog::OnCommand(wParam,lParam));  
    }
    Last edited by ovidiucucu; June 22nd, 2010 at 05:02 AM. Reason: Remove ad links.

  2. #2
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Visual C++ : How can put a clickable URL in a dialog?

    That's nice.

    But why not just use a SysLink control?

  3. #3
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Visual C++ : How can put a clickable URL in a dialog?

    This is the questions section. If you want to publish information please use Codeguru itself, not the forum.

  4. #4
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,051

    Re: Visual C++ : How can put a clickable URL in a dialog?

    This one is good to be published in the FAQs section.
    So, write it in Q&A form, e.g.

    Q: How can put a clickable URL in a dialog?
    A: Itís getting quite common these days...

    then post it in CodeGuru Individual FAQs.

    // please avoid links which can be ads!
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center