Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@gauravbhorkar-Pf9kZD • Jan 12, 2010
Can anyone answer my question? -
@prasad-aSUfhP • Jan 12, 2010
Hey Gaurav,
Why not use a simple VB application to do this? -
@gauravbhorkar-Pf9kZD • Jan 12, 2010
-
@prasad-aSUfhP • Jan 13, 2010
I am not so strong in C (perhaps others can help you). But suffice to say you have to create event handlers and events.
What say folks? -
@thebigk • Jan 13, 2010
What 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? 😕 -
@manish-r2Hoep • Jan 13, 2010
Gaurav This is very interesting question that today you ask...i don't know much about it..but what my mind gives me this ..
First of all you have to include <stdlib.h> file.in your code..Now use something like this
Create a button on window ..when button will be clicked then this code will be executed
{
system("browser.bat");
}
here browser.bat will contain this name firefox.exe
now when ever you click button then browser will open
Now Question arises how to open a desired link..I will try this..
I hope this will help you -
@manish-r2Hoep • Jan 13, 2010
Gaurav 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 -
@gauravbhorkar-Pf9kZD • 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? 😕 -
@gauravbhorkar-Pf9kZD • 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 -
@gauravbhorkar-Pf9kZD • Jan 13, 2010
@ Goyal
The solution you suggested is not working. I think it works only for console applications.
But a very intense Google search got this solution :-
ShellExecute(hwnd, "open", "https://www.example.com", NULL, NULL, SW_SHOWNORMAL);Its a windows API function and it is working perfectly.
Thank you guys for your suggestions. -
@manish-r2Hoep • 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?
Actually i have tried this ..and this is working fine.. -
@gauravbhorkar-Pf9kZD • Jan 13, 2010
Here is the code snippet. I hope you know the contents of WinMain () function.
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.
![[IMG]](proxy.php?image=http%3A%2F%2Fi48.tinypic.com%2Ff06cls.png&hash=82e4f0d3c85122a4cfbc0a5f79015ec5)