Webgadget IE compatibilty mode

Windows specific forum
Karellen
User
User
Posts: 82
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Webgadget IE compatibilty mode

Post by Karellen »

Code: Select all

If OpenWindow(0,0,0,800,600,"Webgadget",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
  WebGadget(0,0,0,800,600,"http://whatismybrowser.com/")   
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Hi everyone,
running the code above gives me the following result:
Internet Explorer 10 on Windows 7
Internet Explorer 7 Compatibility View, 32 bit compatibility layer, Media Center PC v6.0
I have two questions about this:
  1. Can anybody explain me the reason the webgadget is running in IE 7 mode?
  • Can this be changed to display modern pages with html5/css3?
Thanks!
Stanley decided to go to the meeting room...
User avatar
ostapas
Enthusiast
Enthusiast
Posts: 192
Joined: Thu Feb 18, 2010 11:10 pm

Re: Webgadget IE compatibilty mode

Post by ostapas »

Try this:

Code: Select all

RegCreateKeyValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", GetFilePart(ProgramFilename()), "10001", #REG_DWORD, ".")
Possible parameter values - http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Karellen
User
User
Posts: 82
Joined: Fri Aug 16, 2013 2:52 pm
Location: Germany

Re: Webgadget IE compatibilty mode

Post by Karellen »

Works perfectly, thanks a lot, also for the link! :)
Stanley decided to go to the meeting room...
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: Webgadget IE compatibilty mode

Post by Nico »

Exactly:

See MSDN: http://msdn.microsoft.com/en-us/library ... s.85).aspx

Registry path:

Code: Select all

32 bit:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

Value Key: yourapplication.exe

64 bit:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

Value Key: yourapplication.exe
La valeur associée doit correspondre à ça:

Code: Select all

The value to set this key to is (taken from MSDN here) as decimal values:

10001 (0x2711)
Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

10000 (0x02710)
Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.

9999 (0x270F) 
Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.

9000 (0x2328) 
Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

8888 (0x22B8) 
Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.

8000 (0x1F40) 
Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.

7000 (0x1B58) 
Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Webgadget IE compatibilty mode

Post by ts-soft »

the 64-bit Key is only for 32-Bit programs on 64-bit OS, but not for 64-Bit programs on 64-bit OS :wink:

and it is not recommed to use the Wow6432Node-path directly, better use this:
http://www.purebasic.fr/english/viewtop ... 72#p422572
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Webgadget IE compatibilty mode

Post by PB »

> RegCreateKeyValue("HKEY_LOCAL_MACHINE\Software\ [...]

Don't forget this will need Admin rights to work.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: Webgadget IE compatibilty mode

Post by Tristano »

This thread has been many times a useful reference to me, and helped me overcome the WebGadget limitation of old-browser behaviour, and enjoy some HTML5 in the WebGadget.

I'd like to keep it alive and add a few useful links on the topic, which have helped me further search the subject:
Also worth mentioning, that with RegCreateKeyEx for current user using REG_OPTION_VOLATILE for dwOptions allows to set browser compatiblity mode for the given executable without changing permanently the registry (and should not require high priviledges to run). Furthermore (unlike for local machine), the registry key under current user is the same for both 32 and 64 bit executables! (so no need to worry about bitness of app)

The registry key must be set before opening the WebGadget!

Code: Select all

LONG RegCreateKeyEx(
  HKEY hKey,                                    // handle of an open key  
  LPCTSTR lpSubKey,                             // address of subkey name  
  DWORD Reserved,                               // reserved  
  LPTSTR lpClass,                               // address of class string  
  DWORD dwOptions,                              // special options flag  
  REGSAM samDesired,                            // desired security access  
  LPSECURITY_ATTRIBUTES lpSecurityAttributes,   // address of key security structure  
  PHKEY phkResult,                              // address of buffer for opened handle  
  LPDWORD lpdwDisposition                       // address of disposition value buffer  
); 
From MS documentation:
dwOptions — Specifies special options for the key. This parameter can be one of the following values:

[...]

REG_OPTION_VOLATILE — Windows NT: This key is volatile; the information is stored in memory and is not preserved when the system is restarted. The RegSaveKey function does not save volatile keys. This flag is ignored if the key already exists.
Nowadays, the ideal value of the compatibility mode is 11001 (aka Edge mode), which will use the highest browser version available on the machine (ie: IE11 on all modern Windows). Other values don't make much sense probably.
The PureBASIC Archives: FOSS Resources:
User avatar
Kukulkan
Addict
Addict
Posts: 1348
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Webgadget IE compatibilty mode

Post by Kukulkan »

Hello Tristano,

do you have a final path for the needed registry entry and, maybe, a PB example about how you set this value?

Thanks!
User avatar
idle
Always Here
Always Here
Posts: 5019
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Webgadget IE compatibilty mode

Post by idle »

Code: Select all

Procedure SetFeature_Browser_Emulation() 
  Protected lpValueName.s,lpData.l,phkResult,lpsdata.s
  lpValueName.s = GetFilePart(ProgramFilename()) 
  lpData = 11001  
  If RegCreateKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #Null, #REG_OPTION_VOLATILE, #KEY_ALL_ACCESS, #Null, @phkResult, @lpdwDisposition) = #ERROR_SUCCESS
    RegSetValueEx_(phkResult, lpValueName, 0, #REG_DWORD, @lpData, SizeOf(LONG))
    RegCloseKey_(phkResult)
  EndIf
    
EndProcedure 

Procedure DelFeature_Browser_Emulation() 
  Protected phkResult,lpValueName.s  
  lpValueName.s = GetFilePart(ProgramFilename()) 
  If RegOpenKeyEx_(#HKEY_CURRENT_USER, "SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", 0, #KEY_SET_VALUE, @phkResult) = #ERROR_SUCCESS
    RegDeleteValue_(phkResult, lpValueName)
    RegCloseKey_(phkResult)
  EndIf
EndProcedure 
Windows 11, Manjaro, Raspberry Pi OS
Image
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Webgadget IE compatibilty mode

Post by Dude »

This thread should be made Sticky.
User avatar
Kukulkan
Addict
Addict
Posts: 1348
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Webgadget IE compatibilty mode

Post by Kukulkan »

Hi idle,

thank you very much! Great!

Is there any experience about the reliability of this hack? If I want to roll out such for thousands of users, how big is the chance that other software manipulates the same key at the same time and how often does this happen?

Best,

Kukulkan
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Webgadget IE compatibilty mode

Post by Dude »

Kukulkan wrote:If I want to roll out such for thousands of users, how big is the chance that other software manipulates the same key at the same time and how often does this happen?
Bisonte answered this exact question for me here:

viewtopic.php?p=528529#p528529

There's no clashing with other software. :)
User avatar
Kukulkan
Addict
Addict
Posts: 1348
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Webgadget IE compatibilty mode

Post by Kukulkan »

Great! Thanks! I just checked the code and yes, it enters the executable name. Therefore, it should not apply to others and others should not affect me. Perfect!
User avatar
idle
Always Here
Always Here
Posts: 5019
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Webgadget IE compatibilty mode

Post by idle »

Kukulkan wrote:Hi idle,

thank you very much! Great!

Is there any experience about the reliability of this hack? If I want to roll out such for thousands of users, how big is the chance that other software manipulates the same key at the same time and how often does this happen?

Best,

Kukulkan
It's the Microsoft official solution, it's not ideal but at least it set your application name, so yes it's safe
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Internet Explorer
Main
FeatureControl
FEATURE_BROWSER_EMULATION
YourApplication.exe = (DWORD) 00011001
Windows 11, Manjaro, Raspberry Pi OS
Image
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Webgadget IE compatibilty mode

Post by Dude »

Kukulkan wrote: yes, it enters the executable name
Yep. Just don't name your executable "calc.exe" or "notepad.exe" :lol:
Post Reply