How to add an extra button to the WindowTitle?
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Please update your system to not use the XP theme feature. Then you would know that netmaestro's code lacks a normal representation.Fluid Byte wrote:@Trond: Please update your system respectivley use the XP theme feature. Then you would know that this code certainly corectly places/sizes the button but lacks XP skinning representation.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
ROFL Trond! I expected something like that. :roll:Trond wrote:Please update your system to not use the XP theme feature. Then you would know that netmaestro's code lacks a normal representation.
Well, don't get me wrong here. I don't want to force you to use something you dislike (although there is no argument for it) but you have to use the skinning feature in order to make your code compatible with XP themes.
@netmaestro: Trond is right here. You are using plain images so it will look like on the screenshot he posted when XP theming is disabled.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Exactly! That's what I also pointed out. Addding an extra button for themed/non-themed applications involves messing around with the "Visual Styles Reference".Remember that there's no guarantee that the user uses the default XP theme.
Not a chance! As stated before people can use different XP skins so you need to access the current theme data and obtain the appropriate images to create an extra window button.The last code I posted handles sizing correctly and all you have to do is provide 3 icon images for themed and 3 for unthemed and use the appropriate set for the environment you find.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
No problem, I'll post some code after I get back that shows the method. It isn't difficult at all to clone the current look of the window, whatever theme or color it is. But if you're looking to make the button look exactly like a button would from somebody's theme engine, that's not a reasonable goal. For my purposes it's enough make a button that fits in nicely and doesn't stick out like a sore thumb. This will do that.
BERESHEIT
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Gahh! I was messing around with the XP Theme API since yesterday only to come to a conclusion wich Trond already pointed out:
So drawing the the individual caption buttons is pretty simple (compile with Unicode enabled):
But as stated before it seems to be impossible to draw a plain window button without the corresponding gylph (the symbols on the button). Thus there is no way drawing a custom symbol on a theme template image.
Furthermore I deeply searched the internet and noticed (as pointed out by large communities like codeguru.com) that the XP Theme API is poorly documented. For example try to search for "WP_SMALLSYSBUTTON" (wich is a part constant) on Google. You get exactly 2 matches! Well, all we got are 3 includes: uxtheme.h, Schemadef.h and Tmschema.h + SDK Documentaion but as said before some information is simply missing.
I already thought about using a quick hack and just try to duplicate the image portion wich is not covered by the glyph. But a different theme may use differently sized gylphs so this ain't a real solution.
If anyone knows a way to draw a raw window button without a gylph please let me know!
I am reffering to this thread: http://www.purebasic.fr/english/viewtopic.php?t=22476Did you find out how to do this? I can extract the individual title bar buttons from the current theme, but I can't get them without glyphs.
So drawing the the individual caption buttons is pretty simple (compile with Unicode enabled):
Code: Select all
#WP_MINBUTTON = 15
#WP_MAXBUTTON = 17
#WP_CLOSEBUTTON = 18
Global HTHEME.l
Procedure WindowCallback(hWnd.l,uMsg.l,wParam.l,lParam.l)
Select uMsg
Case #WM_PAINT
hdc = BeginPaint_(hwnd,ps.PAINTSTRUCT)
SetRect_(pRect.RECT,10,10,26,26)
DrawThemeBackground_(HTHEME,hdc,#WP_MINBUTTON,1,pRect,0)
OffsetRect_(pRect,18,0)
DrawThemeBackground_(HTHEME,hdc,#WP_MAXBUTTON,1,pRect,0)
OffsetRect_(pRect,18,0)
DrawThemeBackground_(HTHEME,hdc,#WP_CLOSEBUTTON,1,pRect,0)
EndPaint_(hwnd,ps)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,200,80,"",#WS_OVERLAPPEDWINDOW | 1)
SetWindowCallback(@WindowCallback())
HTHEME = OpenThemeData_(WindowID(0),"Window")
While WaitWindowEvent() ! 16 : Wend
CloseThemeData_(HTHEME)
Furthermore I deeply searched the internet and noticed (as pointed out by large communities like codeguru.com) that the XP Theme API is poorly documented. For example try to search for "WP_SMALLSYSBUTTON" (wich is a part constant) on Google. You get exactly 2 matches! Well, all we got are 3 includes: uxtheme.h, Schemadef.h and Tmschema.h + SDK Documentaion but as said before some information is simply missing.
I already thought about using a quick hack and just try to duplicate the image portion wich is not covered by the glyph. But a different theme may use differently sized gylphs so this ain't a real solution.
If anyone knows a way to draw a raw window button without a gylph please let me know!
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
nice, works also without unicode:
Code: Select all
#WP_MINBUTTON = 15
#WP_MAXBUTTON = 17
#WP_CLOSEBUTTON = 18
Global HTHEME.l
Procedure WindowCallback(hWnd.l,uMsg.l,wParam.l,lParam.l)
Select uMsg
Case #WM_PAINT
hdc = BeginPaint_(hwnd,ps.PAINTSTRUCT)
SetRect_(pRect.RECT,10,10,26,26)
DrawThemeBackground_(HTHEME,hdc,#WP_MINBUTTON,1,pRect,0)
OffsetRect_(pRect,18,0)
DrawThemeBackground_(HTHEME,hdc,#WP_MAXBUTTON,1,pRect,0)
OffsetRect_(pRect,18,0)
DrawThemeBackground_(HTHEME,hdc,#WP_CLOSEBUTTON,1,pRect,0)
EndPaint_(hwnd,ps)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,200,80,"",#WS_OVERLAPPEDWINDOW | 1)
SetWindowCallback(@WindowCallback())
Win.s = Space(12)
PokeS(@Win, "Window", -1, #PB_Unicode)
HTHEME = OpenThemeData_(WindowID(0),Win)
While WaitWindowEvent() ! 16 : Wend
CloseThemeData_(HTHEME)
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.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
