Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modify web browser control in VB6? 1

Status
Not open for further replies.

JimSchuuz

IS-IT--Management
Joined
Jan 24, 2005
Messages
45
Location
US
First off, I am NOT a programmer. I am an IT guy who got roped into (what appeared to be) a simple project at work. Here is the situation:

1) I have a form containing a webbrowser control. It isn't the wizard-created browser, just a form with a browser control on it.
2) The webbrowser defaults to page1.htm when the form loads, which displays basic text and images stored locally, not on the Internet.
3) The image files are copyrighted by us so we do not want the images used by the recipient of this program.

4) Is it possible to change the image file extensions to something like ".HID" and then alter the browser control so that it considers .HID files as just another image file format (like .JPG, .GIF, .PNG)?
 
OK, please let me revise my question. I just realized that in HTML you can define an image file by extension, and I just tested it successfully.

Here is the new question:

1) To decrease the likelihood that someone will edit the .HTM file to view the code, and then find the corresponding image files, I would like to change the extension to something other than traditional HTML file extensions.
2) I tested this in the webbrowser form and it doesn't parse the HTML-- it only reads the file as a basic text file.
3) Do I even need to modify the browser control or just add some lines of code that tell the program/browser form to open a ".FAK" file as an HTML file?

Jim Schuuz
{ F1 = my.friend
}
 
This may be obvious but I'm sure you realise that any image shown in a browser can be saved to your local hard drive regardless of it's filetype or any other code. They can just right-click and 'save image as...'

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

For tsunami relief donations

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
I appreciate the thought. Currently I have some javascript that disables right-clicking on the webpage, and on the next revision of the program I plan on disabling it through the code in VB. If I run into a problem with that I'll ask for help in a new thread. I didn't want this one to stray too far from the topic at hand, which is to force the browser control to read a document without an .HTM extension as an HTML document, not as plain text.

Jim Schuuz
{ F1 = my.friend
}
 
Code:
Dim HtmName As String

Private Sub Form_Load()
'Navigate to a file (it could anything...
'...say an HTML file, encrypted and saved with a "QAZ" extension).
WB.Navigate "c:/Bad Deeds/Help/HelpMe.qaz"
End Sub

Private Sub WB_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, FLAGS As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
If InStr(URL, ".qaz") > 0 Then
    HtmName = Left$(URL, InStr(URL, "."))
    'Copy the file to a new name
    '(decrypt or otherwise process it)
    FileCopy HtmName & "qaz", HtmName & "htm"
    'then re-navigate
    WB.Navigate HtmName & "htm"
    Cancel = True
End If
End Sub

Private Sub WB_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
'Clean up by deleting the HTML file,
'or overwrite it with garbage and THEN delete it
'(if you want to be a bit more secure).
If Dir(HtmName & "htm") <> "" Then Kill HtmName & "htm"
'...of course, you will have to find a way to handle a "refresh"
'since the page will no longer exist.
End Sub


Add water (makes its own sauce).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top