How to Create SysLink Controls

You implement the SysLink control's hyperlinks through markup in the control's initialization string, or by sending it a LM_SETITEM message.

Note

Before creating SysLink controls, you must call the InitCommonControlsEx function, specifying the ICC_LINK_CLASS.

 

To create a SysLink, call the CreateWindow or CreateWindowEx function, specifying the WC_LINK window class. The lpWindowName parameter that is common to these functions specifies a pointer to a zero-terminated string that contains the marked-up text to display. For window styles particular to SysLink controls, see SysLink Control Styles.

What you need to know

Technologies

Prerequisites

  • C/C++
  • Windows User Interface Programming

Instructions

The following example code creates a SysLink control that displays two hyperlinks. The first hyperlink is an Internet URL, and the second is application-defined.

HWND CreateSysLink(HWND hDlg, HINSTANCE hInst, RECT rect)
{
    return CreateWindowEx(0, WC_LINK, 
        L"For more information, <A HREF=\"https://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);
}

Remarks

It is assumed that InitCommonControlsEx has already been called.

Specifying the WS_TABSTOP style ensures that the user will be able to select a link by tabbing to it and pressing the Enter key.

Version 6 of ComCtl32.dll supports Unicode only. Therefore, you cannot create ANSI versions of SysLink controls—only Unicode.

Using SysLink Controls

Windows common controls demo (CppWindowsCommonControls)