Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

MFC question - Help !!!!

Thread Tools
 
Search this Thread
 
Old 14 May 2002, 04:35 PM
  #1  
Iain Young
Scooby Regular
Thread Starter
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 14 May 2002, 07:57 PM
  #2  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
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
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
Old 15 May 2002, 08:33 AM
  #3  
TopBanana
Scooby Regular
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Post

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?
Old 15 May 2002, 08:41 AM
  #4  
MarkO
Scooby Regular
 
MarkO's Avatar
 
Join Date: Oct 1998
Location: London
Posts: 4,891
Likes: 0
Received 0 Likes on 0 Posts
Cool

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]
Old 15 May 2002, 09:46 AM
  #5  
MrDeference
Scooby Regular
 
MrDeference's Avatar
 
Join Date: Mar 2002
Posts: 337
Likes: 0
Received 0 Likes on 0 Posts
Post

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]
Old 15 May 2002, 10:13 AM
  #6  
Iain Young
Scooby Regular
Thread Starter
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Post

Thanks everyone, I'll give the document parsing a try....

Cheers,
Iain
Old 15 May 2002, 12:39 PM
  #7  
Iain Young
Scooby Regular
Thread Starter
 
Iain Young's Avatar
 
Join Date: Sep 1999
Location: Swindon, Wiltshire Xbox Gamertag: Gutgouger
Posts: 6,956
Likes: 0
Received 0 Likes on 0 Posts
Cool

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
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
slimwiltaz
General Technical
20
09 October 2015 07:40 PM
IanG1983
Wheels, Tyres & Brakes
2
06 October 2015 03:08 PM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM
the shreksta
Other Marques
26
01 October 2015 02:30 PM



Quick Reply: MFC question - Help !!!!



All times are GMT +1. The time now is 11:26 AM.