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.
LVL 10
wildzeroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HypoviaxCommented:
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
0
wildzeroAuthor Commented:
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...
0
HypoviaxCommented:
To learn how to write and read to registry have a look at these:

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20387935.html
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10834801.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

0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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

Try freeing the webbrowser then recreating it, that might work

Regards,

Hypoviax

0
wildzeroAuthor Commented:
Ok :)
How do I do that? :)
0
HypoviaxCommented:
Ill post tommorow...
0
wildzeroAuthor Commented:
Cheers that would be excellent :D
0
Eddie ShipmanAll-around developerCommented:
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.
0
wildzeroAuthor Commented:
The who what?
*I just want the changes to happen without having to close and open the program*
0
HypoviaxCommented:
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
0
wildzeroAuthor Commented:
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); ?
0
wildzeroAuthor Commented:
Just thinking because if it gets free'd and created say 5-6 times, don't want it to be to hard to 'track'
0
HypoviaxCommented:
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
0
HypoviaxCommented:
Yep, my code works, i don't think yours works although you might be able to get it working.
0
HypoviaxCommented:
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


0
wildzeroAuthor Commented:
....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 :)
0
HypoviaxCommented:
Ok this should work. Its a bit different to the original i posted:

webbrowser1.Free;
webbrowser1 := TWebBrowser.Create( Self );
//webbrowser1.Align := alClient;
//webbrowser1.ParentWindow := form1.Handle;
form1.insertcontrol(Webbrowser1); //This will be your tabsheet instead
WebBrowser1.Align := alClient

Regards,

Hypoviax
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wildzeroAuthor Commented:
Beautiful!
:)
Thats right on man, supper excellent
0
HypoviaxCommented:
I'm looking for that ActiveX thing now

0
HypoviaxCommented:
Thanks,

Do you just want the ActiveX registry key?

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

Regards,

Hypoviax
0
wildzeroAuthor Commented:
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 :)
0
HypoviaxCommented:
Ok, that would be great,
 Thanks again,

Hypoviax
0
HypoviaxCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.