Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This topic describes one way to create a command link.
What you need to know
Technologies
Prerequisites
- C/C++
- Windows User Interface Programming
Instructions
Step 1: Create an instance of the command link button.
In the following C++ code example, the style constant BS_COMMANDLINK specifies the button as a command link button.
HWND hwndCommandLink = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed
L"", // Text will be defined later
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_COMMANDLINK, // Styles
200, // x position
10, // y position
100, // Button width
100, // Button height
m_hwnd, // Parent window
NULL, // No menu
(HINSTANCE)GetWindowLongPtr(m_hwnd, GWLP_HINSTANCE),
NULL); // Pointer not needed
Step 2: Set the command link label and explanation text
Use the SendMessage function to set the command link label and supplementary text via the WM_SETTEXT message and the BCM_SETNOTE message, respectively.
SendMessage(hwndCommandLink, WM_SETTEXT, 0, (LPARAM)L"Command link");
SendMessage(hwndCommandLink, BCM_SETNOTE, 0, (LPARAM)L"with note");
Related topics