Reputation: 2184
I am trying to add a hyperlink that will direct a user of the application to a website. I see that MFC has a built in "MFC Link Control". In the dialog-editor. My hyperlinks look to work correctly.
When I debug my program, the links instead turn into buttons.
Is there a way to add non-button hyperlinks? Thanks.
Upvotes: 1
Views: 4983
Reputation: 2937
CButton
is the natural base class of CMFCLinkCtrl
. If it misses certain key properies, CMFCLinkCtrl
will revert back to a CButton
. My bet is on the URL. Try this:
CMFCLinkCtrl m_btnLink; // <-- associate with your control!
...
BOOL CTestDlg::OnInitDialog()
{
...
m_btnLink.SetURL(_T("http://www.example.com"));
m_btnLink.SetTooltip(_T("Link to my site"));
m_btnLink.SizeToContent();
...
}
Upvotes: 2
Reputation: 1352
Drag SysLink
from Toolbox
to your dialog box. Double click it and add this line to void
function:
ShellExecute(
NULL, // or your can use GetSafeHwnd()
L"open",
L"http://stackoverflow.com/a/29181060/4057688",
NULL,
NULL,
SW_SHOWNORMAL
);
For more information visit.
Hope to be useful.
Upvotes: 2