C++: Handle the Syslink click event

Once you have the SysLink control working, you can respond to link clicks by adding a notification listener to your parent window.

case WM_NOTIFY: {
LPNMHDR pnmh = (LPNMHDR) lParam;

// If the notification came from the syslink control
if (pnmh->idFrom == IDC_SYSLINK_WEBSITE) {
// NM_CLICK is the notification is normally used.
// NM_RETURN is the notification needed for return keypress, otherwise the control is not keyboard accessible.
if ((pnmh->code == NM_CLICK) || (pnmh->code == NM_RETURN)) {
// Recast lParam to an NMLINK item because it also contains NMHDR as part of its structure
PNMLINK link = (PNMLINK) lParam;

ShellExecute(NULL, L"open", link->item.szUrl, NULL, NULL, SW_SHOWNORMAL);
}

}

break;
}

The link->item.szUrl field is the "href" given in the syslink control markup.

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog