Shell.Explorer theme?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Shell.Explorer theme?

13 Oct 2017, 11:21

Does anyone know if there is a way to have the Shell.Explorer control use the same theme for its native controls (specifically buttons) as those used in a normal IE instance?

For comparison, IE on the left and a Shell.Explorer control on the right:
IE_vs_shell.explorer.png
IE_vs_shell.explorer.png (22.26 KiB) Viewed 2580 times
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Shell.Explorer theme?

15 Oct 2017, 08:07

You could try getting the window/control styles for each and comparing:

Code: Select all

q::
WinGet, vWinStyle, Style, A
WinGet, vWinExStyle, ExStyle, A
vCtlClassNN := "Internet Explorer_Server1"
ControlGet, vCtlStyle, Style,, % vCtlClassNN, A
ControlGet, vCtlExStyle, ExStyle,, % vCtlClassNN, A
MsgBox, % Format("0x{:08X} 0x{:08X}", vWinStyle, vWinExStyle)
MsgBox, % Format("0x{:08X} 0x{:08X}", vCtlStyle, vCtlExStyle)
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

15 Mar 2018, 08:25

This question came up again. I did find the following article on the MSDN Forum that mentions using a meta tag to apply the theme to the control. I tried that but it didn't appear to do anything. The next method would be to implement IDocHostUIHandler and return DOCHOSTUIFLAG_THEME when GetHostInfo is called. I do not have the know-how to do this. Then it looks at the registry. The post does state that the meta tag is the last resort.

Hoping someone may have other thoughts. Thanks!

EDIT: I did try setting the registry key with no success. I did not restart after setting it though.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Shell.Explorer theme?

15 Mar 2018, 09:31

You could at least try SetWindowTheme.

Code: Select all

q:: ;control set theme
ToolTip, abc`r`ndef`r`nghi
WinGet, hTT, ID, ahk_class tooltips_class32
Sleep, 2000
DllCall("uxtheme\SetWindowTheme", Ptr,hTT, Ptr,0, Str,"")
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
tankuser
Posts: 26
Joined: 29 Sep 2013, 16:04

Re: Shell.Explorer theme?

15 Mar 2018, 12:11

you probably need to set the User-Agent
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

15 Mar 2018, 12:22

This was what I was trying:

Code: Select all

Gui, Add, ActiveX, w400 h500 vwb hwndhwb, about:<!DOCTYPE html><meta http-equiv='MSThemeCompatible' content='yes'><meta http-equiv='X-UA-Compatible' content='IE=edge'>
wb.document.write("<div style='border: 2px solid blue; border-radius: 5px;'>DIV</div><button>test1</button><button>test2</button>")

Gui, Show

GuiClose() {
    ExitApp
}
jeeswg: I did try that (and your sample code has the parameters in the wrong order)
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Shell.Explorer theme?

15 Mar 2018, 12:27

- Are you saying that the SetWindowTheme DllCall arguments are the wrong way round in my example? The script did work.
- You could try 'IE=9' instead of 'IE=edge'.
- What theme names have you tried?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
PlangavanCartier

Re: Shell.Explorer theme?

15 Mar 2018, 12:29

Code: Select all

Gui, Add, ActiveX, w400 h500 vwb hwndhwb, about:<!DOCTYPE html>
wb.document.write("<meta http-equiv='MSThemeCompatible' content='yes'><meta http-equiv='X-UA-Compatible' content='IE=edge'><div style='border: 2px solid blue; border-radius: 5px;'>DIV</div><button>test1</button><button>test2</button>")

Gui, Show

GuiClose() {
    ExitApp
}
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

15 Mar 2018, 12:34

I am. The last two parameters are opposite of Just Me's SetExplorerTheme function in addition to how it is defined on MSDN

Code: Select all

SetExplorerTheme(HCTL) { ; HCTL : handle of a ListView or TreeView control
	If (DllCall("GetVersion", "UChar") > 5) {
		VarSetCapacity(ClassName, 1024, 0)
		If DllCall("GetClassName", "Ptr", HCTL, "Str", ClassName, "Int", 512, "Int") {
			If (ClassName = "SysListView32") || (ClassName = "SysTreeView32") {
				if(!DllCall("UxTheme.dll\SetWindowTheme", "Ptr", HCTL, "WStr", "Explorer", "Ptr", 0)) {
					if(!(LV_EX_GetExtendedStyle(HCTL) & 0x10000))
						LV_EX_SetExtendedStyle(HCTL, 0x00010000, 0x00010000) ; LVS_EX_DOUBLEBUFFER = 0x00010000
					return True
				}
			}
		}
   }
   Return False
}
Using IE=9 also does not work, though I can't imagine why anyone would ever want to revert to using IE9...

Lastly, the only theme name I know of that does anything is "Explorer", and passing that does not work either.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

15 Mar 2018, 12:47

PlangavanCartier: It makes no sense to me, but that actually works. I moved the X-UA-Compatible tag to the end of the first line as I know that has to be present when the control is created.

Would be interesting to know why it works when writing to the page. Strange. But THANK YOU!
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

16 Mar 2018, 11:43

To keep this thread updated, I am unable to get PlangavanCartier's solution to work if I included a <link> tag to pull in some CSS styles.
PlangavanCartier

Re: Shell.Explorer theme?

16 Mar 2018, 16:40

Not a web dev (which is why I can't answer the why, sorry), but after seeing your screenshot I tried your T-T-T implementation from https://autohotkey.com/boards/viewtopic.php?f=6&t=38296 and, as far as I can tell, that loads a CSS file through the link tag.

Just doing this is enough to have normal IE-styled buttons here

Code: Select all

diff -Naurp AHK-ReactJS.orig/index.css AHK-ReactJS/index.css
--- AHK-ReactJS.orig/index.css	2017-10-13 13:20:10 +0100
+++ AHK-ReactJS/index.css	2018-03-16 21:32:48 +0000
@@ -32,17 +32,6 @@ body {
     width: 34px;
   }
 
-button:not(.square) {
-    background-color: #FFF;
-    box-shadow: none;
-    border-radius: 5px;
-    border: 1px solid gray;
-}
-
-button:not(.square):hover {
-    background-color: cyan;
-}
-
   .square:focus {
     outline: none;
   }
diff -Naurp AHK-ReactJS.orig/index.html AHK-ReactJS/index.html
--- AHK-ReactJS.orig/index.html	2017-10-13 13:20:56 +0100
+++ AHK-ReactJS/index.html	2018-03-16 21:34:28 +0000
@@ -2,6 +2,7 @@
 <html>
   <head>
     <meta charset="UTF-8" />
+    <meta http-equiv='MSThemeCompatible' content='yes'>
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Hello World</title>
     <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Shell.Explorer theme?

16 Mar 2018, 19:56

Seems as if you've helped to uncover more errors in my code. I had my <head> tags misaligned so the meta tags weren't properly being applied. Thanks!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 242 guests