"Explorer" subclassed/themed Listview and TreeView controls, draw explorer style focus rectangle

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

"Explorer" subclassed/themed Listview and TreeView controls, draw explorer style focus rectangle

19 Aug 2016, 15:46

Hey all,

I recently discovered that you can use some of Windows' own classes for things to get your own guis to look more like windows explorer windows:

Code: Select all

SetWindowTheme(hListView, "ItemsView") ;or "Explorer"
;...
SetWindowTheme(hwnd, str) {
 Return DllCall("uxtheme\SetWindowTheme", "Uint", hwnd, "Str", str, "Ptr", 0)
}
It looks great (triangles on the TreeViews instead of +'s, selection rectangle is "glass"ified, etc... but the selection/focus rectangle is showing the normal dotted line rectangle instead of the rounded solid rectangle that explorer uses

I found a thread about it:
https://groups.google.com/forum/#!topic ... Kg3t1GNiLo

that says to use class named "ItemsView" and draw the rectangle with DrawThemeBackground (on part id 3 and state id 1 or 2). I'm trying to make sense of this (and get DrawThemeBackground working to draw a uxThemed button, but thats another issue) and i think i have to OnMessage WM_NCPAINT and do the drawing there, but i'm in over my head.

If anyone has any tips or insight it would be greatly appreciated

Code: Select all

WM_NCPAINT( wP, lP, msg, hwnd ) { ;not working attempt
hDC    := DllCall("GetDC", "UInt", hwnd)
hTheme := DllCall("UxTheme.dll\OpenThemeData", uInt, hwnd, Str, "ItemsView" )
if(hTheme)
{
 VarSetCapacity(pRect, 16, 0) ;replace with getRect...
 NumPut(0,    pRect,  0, "Int")
 NumPut(0,    pRect,  4, "Int")
 NumPut(100,  pRect,  8, "Int")
 NumPut(100,  pRect, 12, "Int")
  DllRet := DllCall("UxTheme.dll\DrawThemeBackground", Ptr, hTheme, Ptr, hDC, uInt, PartID:=3, uInt, StateID:=1 , Ptr, pRect, Ptr, 0, uInt)
}
DllCall("ReleaseDC", "UInt", hwnd, "UInt", hDC)
Return 
}
"Explorer" or "ItemsView" subclassed:
Image

Normal:
Image

The focus rectangle I want:
Image

The focus rectangle I get:
Image
Last edited by gwarble on 19 Aug 2016, 16:19, edited 1 time in total.
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: "Explorer" subclassed/themed Listview and TreeView controls, draw explorer style focus rectangle

19 Aug 2016, 16:19

oops, thanks
fixed first post, same result
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: "Explorer" subclassed/themed Listview and TreeView controls, draw explorer style focus rectangle

19 Aug 2016, 17:39

Try this:

Code: Select all

DllRet := DllCall("UxTheme.dll\DrawThemeBackground", "Int", hTheme, "UInt", hDC, "Int", 3, "Int", 1 , "Uint", &pRect, "Uint", 0)
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: "Explorer" subclassed/themed Listview and TreeView controls, draw explorer style focus rectangle

19 Aug 2016, 18:06

thanks man! that works for the drawing the rectangle (and for buttons!)

now i think instead of drawing it on the window's DC i need to ownerdraw or customdraw the listview control, find the dc and rect where the rectangle would normally be drawn, prevent it, and DrawThemeBackground at that point

Image
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Joey5 and 199 guests