Solved

Is it possible to use embedded resource in 'webBrowser'?

Posted on 2014-09-21
4
107 Views
Last Modified: 2015-09-29
Hi experts
I wonder if it is possible to use embedded resource of chm file in 'webBrowser'?

My C# program reads from a chm file ("Help.chm") in my local HD by calling the method
webBrowser.Navigate(url)

Open in new window

.
eg. the url could be:
//"mk:@MSITStore:C:\\Projects\\Tool\\bin\\Debug\\Help.chm::/InfoTab_InfoTab.htm"

But, I would like to use the chm file as an embedded resource. eg. Properties.Resources.Help
And I wonder how I could modify the above.
I'd seen from some Internet article suggesting casting the embedded resource into a string and assign it to webBrowser.DocumentText, but it didn't work for me.

Thanks in advance
0
Comment
Question by:dominicwong
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
help-info earned 500 total points
ID: 40337400
Form with working webBrowser controlAdding CHM's - example code onlyCopy the CHM file(s) to a subdirectory e.g. /help of your Project and always copy this file(s) to the release folder .

You need to know about the internal CHM web structure e.g. topic garden.htm

Add code:
private const string sHTMLHelpFileName_ShowWithoutAutoSync = "/help/CHM-example.chm";

Open in new window


..
    public static string GetChmUrl(string fileName, string page)
    {
      StringBuilder url = new StringBuilder();
      url.AppendFormat("mk:@MSITStore:{0}::", fileName);
      if (page.IndexOf('/') != 0) url.Append('/');
      url.Append(page);
      return url.ToString();
    }

Open in new window


..
    private void frmMain_Load(object sender, EventArgs e)
    {
      // example: System.Diagnostics.Process.Start(Application.StartupPath + sHTMLHelpFileName_ShowWithoutAutoSync);
      webBrowser1.Navigate(new Uri(GetChmUrl(Application.StartupPath + sHTMLHelpFileName_ShowWithoutAutoSync, "Garden/garden.htm")));
    }

Open in new window

0
 
LVL 7

Expert Comment

by:help-info
ID: 40337428
Please note you can show a single topic only. CHM files have their own Help Viewer coming with Windows. The CHM Help Viewer of the operating system includes a web browser control the "Content pane".
For calling the Help Viewer use e.g. following code or other solutions

// example: System.Diagnostics.Process.Start(Application.StartupPath + sHTMLHelpFileName_ShowWithoutAutoSync);

Open in new window

0
 

Author Comment

by:dominicwong
ID: 40338065
Thanks help-info for your detailed explanation and with all the nice screenshot. I appreciate it.
The issue I have here came from the trouble where anti-virus scanner scans the chm help file whenever my application attempts to read it from an (external) file in my hard drive. (Please see my other question How to workaround slow down in loading chm file into C# .NET program from background security software)

In other words, my application already reads from a chm help, and loads onto a help panel successfully. Now my thought is instead of mining the help information into my application upon program startup (as the experts suggested in the other question), I would like to test if hiding the external chm help file into an internal resource (ie embedded into a dll) might solve the anti-virus scanning issue.
0
 

Author Closing Comment

by:dominicwong
ID: 41017530
Sorry. It has been a long time. I didn't realize that this question hadn't been closed.
Thanks for your help
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now