0
votes

I was wondering, how can I add a hyperlink (A link to an online webpage) to my window. Do I use CreateWindow, WM_PAINT, etc? Please give me some advice. Thanks!

Edit: Here's what i'm doing:

HWND CreateSysLink(HWND hDlg, HINSTANCE hInst, RECT rect){
    return CreateWindowEx(0, WC_LINK,
                          "For more information, <A HREF=\"http://www.microsoft.com\">click here</A> " \
                          "or <A ID=\"idInfo\">here</A>.",
                          WS_VISIBLE | WS_CHILD | WS_TABSTOP,
                          rect.left, rect.top, rect.right, rect.bottom,
                          hDlg, NULL, hInst, NULL);
}

I'm copying the hInstance from WinMain parameters to a global variable "globalhInstance" by running globalhInstance = hInstance; in WinMain. I'm also creating a global RECT called globalRect. Then on WM_CREATE, I'm calling GetWindowRect(hwnd, &globalRect); ("hwnd" is a parameter of WndProc). Finally, in a switch statement inside WM_COMMAND i'm calling CreateSysLink(hwnd, globalhInstance, globalRect);. But it just doesn't seem to work.

1
Are you looking for the SysLink common control? - Jonathan Potter
Could you give me some sample code - jadenPete
If it's a dialog box and you have Visual C++ then you can drag & drop "SysLink control" from Toolbox. - Barmak Shemirani
@JonathanPotter - No i'm just putting RECT globalRect; below my includes at the top of my .cpp file and calling GetWindowRect(hwnd, &globalRect); on WM_CREATE. - jadenPete

1 Answers

4
votes

There's sample code from the MSDN page linked above:

HWND CreateSysLink(HWND hDlg, HINSTANCE hInst, RECT rect)
{
    return CreateWindowExW(0, WC_LINK, 
        L"For more information, <A HREF=\"http://www.microsoft.com\">click here</A> " \
        L"or <A ID=\"idInfo\">here</A>.", 
        WS_VISIBLE | WS_CHILD | WS_TABSTOP, 
        rect.left, rect.top, rect.right, rect.bottom, 
        hDlg, NULL, hInst, NULL);
}