web browser control difficulty
-
Hello, I'm trying to display a web page inside my own window. I found a c++ example by chris becke on the net which is huge. I ported the code into my application but I can only get the web page to display when I run the project in visual c++. Is there a more bare bone example that displays a web page inside a window ? or why does my program only work when I run it from visual c++ ? I'm not of a great state of intelligence to understand all the com code needed to display a web page but with a little help I think I might understand.. thanks,
-
Hello, I'm trying to display a web page inside my own window. I found a c++ example by chris becke on the net which is huge. I ported the code into my application but I can only get the web page to display when I run the project in visual c++. Is there a more bare bone example that displays a web page inside a window ? or why does my program only work when I run it from visual c++ ? I'm not of a great state of intelligence to understand all the com code needed to display a web page but with a little help I think I might understand.. thanks,
If you are using
MFC
then you may have a look at "Using MFC to Host a WebBrowser Control"[^] at MSDN.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hello, I'm trying to display a web page inside my own window. I found a c++ example by chris becke on the net which is huge. I ported the code into my application but I can only get the web page to display when I run the project in visual c++. Is there a more bare bone example that displays a web page inside a window ? or why does my program only work when I run it from visual c++ ? I'm not of a great state of intelligence to understand all the com code needed to display a web page but with a little help I think I might understand.. thanks,
When you run an application from inside Visual Studio, the working directory is the directory containing the project files (.vcxproj, .sln). However when you run outside of VS, the working directory is the one containing the .exe file. So if you are opening an html file with just a file name (e.g. open "MyTest.html") then that file must exist in the working directory. You should use full path names to avoid this problem. (You can use GetModuleFileName to find out the directory containing your exe). Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
If you are using
MFC
then you may have a look at "Using MFC to Host a WebBrowser Control"[^] at MSDN.If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
When you run an application from inside Visual Studio, the working directory is the directory containing the project files (.vcxproj, .sln). However when you run outside of VS, the working directory is the one containing the .exe file. So if you are opening an html file with just a file name (e.g. open "MyTest.html") then that file must exist in the working directory. You should use full path names to avoid this problem. (You can use GetModuleFileName to find out the directory containing your exe). Hope that helps.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
I understand this, I have been using the full path and file name. I need to convert the string to a BSTR, I'm assuming i'm doing it correctly because as I say, the program works but only shows a web page when I run it from visual studio. here's how:
char url[MAX_PATH];
// _getcwd(url, MAX_PATH);
GetModuleFileName(InstanceHandle, url, MAX_PATH);
std::string file = url;
file = file.substr(0, file.find_last_of("\\"));
file += "\\Help.html";
//file = "Help.html";// show that the path is correct
MessageBox(NULL, file.c_str(), NULL, NULL);OLECHAR* oleChar = NULL;
oleChar = (OLECHAR*)calloc(file.length(), sizeof(OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, file.c_str(), -1, oleChar, sizeof(WCHAR)*file.length());vURL.bstrVal = SysAllocString(oleChar);
-
Hello, I'm trying to display a web page inside my own window. I found a c++ example by chris becke on the net which is huge. I ported the code into my application but I can only get the web page to display when I run the project in visual c++. Is there a more bare bone example that displays a web page inside a window ? or why does my program only work when I run it from visual c++ ? I'm not of a great state of intelligence to understand all the com code needed to display a web page but with a little help I think I might understand.. thanks,