How to create a link to a website in a window?
Example Window:
![[IMG]](proxy.php?image=http%3A%2F%2Fi48.tinypic.com%2Ff06cls.png&hash=82e4f0d3c85122a4cfbc0a5f79015ec5)
When we click the link, the webpage should open in the default web browser.
Is there any Windows API function to do this?
![[IMG]](proxy.php?image=http%3A%2F%2Fi48.tinypic.com%2Ff06cls.png&hash=82e4f0d3c85122a4cfbc0a5f79015ec5)
Member • Jan 12, 2010
Member • Jan 12, 2010
Member • Jan 12, 2010
Member • Jan 13, 2010
Administrator • Jan 13, 2010
[url=https://www.CrazyEngineers.com/]CrazyEngineers[/url]The target attribute will tell the browser to open the page in a new window.
Member • Jan 13, 2010
Member • Jan 13, 2010
Member • Jan 13, 2010
Ya, this works in HTML but I am creating a simple window in C, which should link to a webpage.The_Big_KWhat programming language are you using? If its simple HTML:
[url=https://www.CrazyEngineers.com/]CrazyEngineers[/url]The target attribute will tell the browser to open the page in a new window.
Is that what you are looking for? 😕
Member • Jan 13, 2010
I'll try your method and get back on this thread.goyal420Gaurav just add this line to .bat file
@echo off.
start "link which you want to open"
Just give it a try i am sure you will achieve what you want..and Please post your code here
Member • Jan 13, 2010
ShellExecute(hwnd, "open",
"https://www.example.com",
NULL, NULL, SW_SHOWNORMAL);Its a windows API function and it is working perfectly.Member • Jan 13, 2010
The solution you suggested is not working. I think it works only for console applications.Gaurav can you please post your code?
Member • Jan 13, 2010
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
PostQuitMessage (0);
break;
case WM_PAINT:
OnPaint (hwnd);
break;
case [B]WM_LBUTTONDOWN:[/B] /*To deal with the mouse click*/
OnClick (hwnd, LOWORD(lParam), HIWORD(lParam));
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
void OnPaint (HWND hwnd)
{
HDC hdc;
PAINTSTRUCT ps;
HFONT hfont;
LOGFONT f = {0};
HGDIOBJ holdfont;
hdc = BeginPaint (hwnd, &ps);
f.lfUnderline = 1;
hfont = CreateFontIndirect (&f);
holdfont = SelectObject (hdc, hfont);
SetTextColor (hdc, RGB (0, 0, 255));
TextOut (hdc, 0, 0, "Go to Google", 12);
SelectObject (hdc, holdfont);
DeleteObject (hfont);
EndPaint( hwnd, &ps);
}
void OnClick (HWND hwnd, int x, int y)
{
if ((x>0) && (x<85) && (y>0) && (y<15))
{
[B]ShellExecute(hwnd, "open",
"https://www.google.com",
NULL, NULL, SW_SHOWNORMAL);[/B]
}
}
This is the output.