MFC question - Help !!!!
#1
Scooby Regular
Thread Starter
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes
on
0 Posts
Hopefully there's an MFC guru out there somewhere
I'm updating some old MFC code which implements a web browser inside an application (using a class derived from CHTMLView). Basically I want to set a property when the window / htmlview is invoked which I can pick up in the html using JavaScript (in the same way as the browser name / version etc), so that I can display different content depending on whether the pages are displayed inside the app, or via a normal web browser.
Anyone know if it's possible, and if so, how I do it (a web search has revealed very little info on the subject).
Thanks,
Iain
I'm updating some old MFC code which implements a web browser inside an application (using a class derived from CHTMLView). Basically I want to set a property when the window / htmlview is invoked which I can pick up in the html using JavaScript (in the same way as the browser name / version etc), so that I can display different content depending on whether the pages are displayed inside the app, or via a normal web browser.
Anyone know if it's possible, and if so, how I do it (a web search has revealed very little info on the subject).
Thanks,
Iain
#2
Scooby Regular
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like
on
1 Post
Im off on holiday and need to pack so dont have time to think... ARGH..
try MrDeference... Excellent bloke... really helfull or try Fosters.
David
try MrDeference... Excellent bloke... really helfull or try Fosters.
David
#3
I would have thought your best bet would be to preprocess the stream before you load it into the CHTMLView. Have a comment line in the Javascript like
var InCHTMLView = false;
//::REPLACE-ME::
then replace the //::REPLACE-ME:: line with InCHTMLView = true;
Sound doable?
var InCHTMLView = false;
//::REPLACE-ME::
then replace the //::REPLACE-ME:: line with InCHTMLView = true;
Sound doable?
#4
Scooby Regular
Join Date: Oct 1998
Location: London
Posts: 4,891
Likes: 0
Received 0 Likes
on
0 Posts
Either that or use a meta-tag of your own format, and scan for that?
Depending on exactly what you're trying to do, the other option would be to download the HTML yourself (using the WinINet APIs) and scan it for the content you're looking for. If it exists, you can blat some different content to the browser control, and if the content you're searching for isn't there, then you can blat the original HTML to the browser unchanged. If you want help doing this let me know, I've got a lot of experience in WinINet in MFC (see http://www.webreaper.net and http://www.otway.info/docs/gedtree.html for example of stuff I've written)
If you want more comprehensive help and ideas, check out www.codeproject.com which is a good source for C++/MFC stuff, and has good forums. You might also want to join the WinDev list (www.windev.org) which is a good MFC/C++/Windows discussion list.
Mark
PS: For christ's sake don't use WebReaper on this BBS though - it causes all kinds of havoc with the site host's bandwitdth.
[Edited by MarkO - 5/15/2002 8:49:59 AM]
Depending on exactly what you're trying to do, the other option would be to download the HTML yourself (using the WinINet APIs) and scan it for the content you're looking for. If it exists, you can blat some different content to the browser control, and if the content you're searching for isn't there, then you can blat the original HTML to the browser unchanged. If you want help doing this let me know, I've got a lot of experience in WinINet in MFC (see http://www.webreaper.net and http://www.otway.info/docs/gedtree.html for example of stuff I've written)
If you want more comprehensive help and ideas, check out www.codeproject.com which is a good source for C++/MFC stuff, and has good forums. You might also want to join the WinDev list (www.windev.org) which is a good MFC/C++/Windows discussion list.
Mark
PS: For christ's sake don't use WebReaper on this BBS though - it causes all kinds of havoc with the site host's bandwitdth.
[Edited by MarkO - 5/15/2002 8:49:59 AM]
#5
I would use the IE object model to drill down the loaded document - you should be able to get this easily from CHtmlView::GetHtmlDocument(). Call this when you get CHtmlView::OnDocumentComplete, and drill down the object model to your property, you can change the contents of the page using DHTML.
As the Html document which you have just found is hanging off an IDispatch interface, you could alternatively be able to set an event using the script tag "for" attribute, and call that method from the app.
Good luck.
MrD.
EDIT : to clarify, write the page to default as running in a standalone IE, and modify a property to tell it that it is running in your application's hosted shdocvw control.
[Edited by MrDeference - 5/15/2002 9:54:06 AM]
As the Html document which you have just found is hanging off an IDispatch interface, you could alternatively be able to set an event using the script tag "for" attribute, and call that method from the app.
Good luck.
MrD.
EDIT : to clarify, write the page to default as running in a standalone IE, and modify a property to tell it that it is running in your application's hosted shdocvw control.
[Edited by MrDeference - 5/15/2002 9:54:06 AM]
#7
Scooby Regular
Thread Starter
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes
on
0 Posts
Thanks everyone, I've got it working now. I opted for the route of getting OnDocumentComplete() to set a temporary cookie, and getting the html document to check for it. Works a treat
Cheers,
Iain
Cheers,
Iain
Thread
Thread Starter
Forum
Replies
Last Post
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM