Reputation: 143
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.
Upvotes: 1
Views: 2030
Reputation: 37192
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);
}
Upvotes: 4