Link to home
Start Free TrialLog in
Avatar of wildzero
wildzero

asked on

Twebbrowser re-set / reload registry settings

Hello there,

I have a Twebbrowser on my form, and if I browse to a few sites, I want to be able to 'reset' the browser - reloading the IE settings from the registry.
Exmaple, if I surf sites, disable images from loading I need to 'reset' the browser to reload those changed IE settings.


Also, if someone knows how to get IE to disable active X I will up the points :)

Cheers all.
Avatar of Hypoviax
Hypoviax
Flag of Australia image

Well how i would do it would be to add all the settings you would change to a listbox (or the like) and then perform your changes. When you want to change back cycle through the listbox of original items

Regards,

Hypoviax
Avatar of wildzero
wildzero

ASKER

Huh?
If I have a twebrowser on my form
I browse some sites
I then disable IE from showing images, I have to close and open the program for the twebbroser to re-read the registry to get the setting to say not to download the images.

I would like to be able to disable images and not have to close the program...
To learn how to write and read to registry have a look at these:

https://www.experts-exchange.com/questions/20387935/write-to-registry.html
https://www.experts-exchange.com/questions/10834801/read-and-write-the-registry.html

Explaining my concept:

-Read Registry Keys to Change
-Add these to listbox ( listbox1.items.add(readstring(...));
-Write changes to registry: writestring(...);
-When done revert back: writestring(listbox1.items.strings[x]...);

The settings for IE are found in the following key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer

Related Settings:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

Regards,

Hypoviax

Hypoviax...
I know how to do that part, I just want the changes to happen without having to close and open the program
Ahhh... Sorry i didn't understand.

Try freeing the webbrowser then recreating it, that might work

Regards,

Hypoviax

Ok :)
How do I do that? :)
Ill post tommorow...
Cheers that would be excellent :D
Avatar of Eddie Shipman
No need to do that, use TRegistry SaveKey and RestoreKey.
SaveKey to save the Key's data to a file and RestoreKey restores the data from the file saved
using SaveKey.
The who what?
*I just want the changes to happen without having to close and open the program*
Ok,

After you change your settings free the browser:

webbrowser1.free;

Then once you have done this recreate it and the new settings *should* apply:

var web:twebbrowser;
begin
Web := TWebBrowser.Create( Self );
Web.ParentWindow := Form1.Handle;
Web.Navigate( 'http://www.google.com' );  //You can set the width and height , left and top properties here too.
//You may wish to declare the web variable globally so that you can access it with other controls etc.
//To do this put it in the public or private sections towards the top of the code. With your controls you may want to specify something like:

Example for navigate button:

If webbrowser1.visible then //if it has not been destroyed
webbrowser1.navigate('http://www.google.com')
else
Web.Navigate( 'http://www.google.com' ); //if so use the created one

If you want to destroy the created one the same procedure applys as for the original

Regards,

Hypoviax
Hupoviax,

Cool cheers for that.
Is there a way to re-create it using it's original name, that way don't have to worry about if it's webbrowser1 or Web
ie
webbrowser1.create(self); ?
Just thinking because if it gets free'd and created say 5-6 times, don't want it to be to hard to 'track'
Yeah, that should work i think or try this too:

webbrowser1 := TWebBrowser.Create( Self );
webbrowser1.ParentWindow := Form1.Handle;
webbrowser1.Navigate( 'http://www.google.com' );

Regards,

Hypoviax
Yep, my code works, i don't think yours works although you might be able to get it working.
Just a suggestion, when you are freeing and recreating, it is probably best to store all the browser properties so that you can easily adjust when freeing and recreating:

global variables:

webleft,webright, webwidth,webheight:integer;

on form create:

webleft:=webbrowser1.left
etc for others

When recreating

webbrowser1.left:=webleft
etc for others

Regards,

Hypoviax


....i don't think yours works although you might be able to get it working.... ? eh??

I tired your last bit of code, and it does work, it frees it, re-creates it perfect.
I changed the Form1.Handle to Tabsheet1.Handle as it's on a tab sheet.
The only thing is, it doesn't seem to want to align it's self to the client.

I've done
webbrowser1.Free;
webbrowser1 := TWebBrowser.Create( Self );
webbrowser1.ParentWindow := TabSheet1.Handle;
webbrowser1.Align := alClient;

But all I get is a square that isn't alClient.... - so when I resize the form, it doesn't resize with it..
Extra points here :)
ASKER CERTIFIED SOLUTION
Avatar of Hypoviax
Hypoviax
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Beautiful!
:)
Thats right on man, supper excellent
I'm looking for that ActiveX thing now

Thanks,

Do you just want the ActiveX registry key?

I'll have a look around for it if that is so

Regards,

Hypoviax
If you do find it that'd be great
If you manage to find it, i'll open another question and get you to answer there
just a key is here
set it to whatever
I can code the rest :)
Ok, that would be great,
 Thanks again,

Hypoviax
I think this is the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility

Registry Settings
System Key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{CLSID of the ActiveX control}]
Value Name: Compatibility Flags
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = allow, 1024 (400hex) = disable)

http://www.winguides.com/registry/display.php/1188/

Regards,

Hypoviax