Page 2 of 3
Posted: Wed Dec 27, 2006 9:34 pm
by netmaestro
Mine's steady at 33 all the time now, thanks to Sparkie!
Posted: Wed Dec 27, 2006 10:11 pm
by Trond
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.
Please update your system to not use the XP theme feature. Then you would know that netmaestro's code lacks a normal representation.
Posted: Wed Dec 27, 2006 10:14 pm
by netmaestro
does not...
Posted: Wed Dec 27, 2006 10:19 pm
by Trond
?
Edit: By the way, emule's implementation fails miserably with another theme than the default XP one. Another minimize button is displayed almost on top of the normal minimize button. So, you don't want it like emule.

Posted: Wed Dec 27, 2006 10:40 pm
by Fluid Byte
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.
ROFL Trond! I expected something like that. :roll:
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.
Posted: Wed Dec 27, 2006 10:43 pm
by Trond
Actually I knew the the code I used didn't look good with themes, but, as you said, netmaestros doesn't look good without themes. I have tried to make it theme compatible, but it's almost impossible. Remember that there's no guarantee that the user uses the default XP theme.
Posted: Wed Dec 27, 2006 10:54 pm
by netmaestro
It's easy to make my code work themed or not. 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.
Posted: Wed Dec 27, 2006 11:02 pm
by Trond
Since it's so easy, will you show us?
Posted: Wed Dec 27, 2006 11:24 pm
by Fluid Byte
Remember that there's no guarantee that the user uses the default XP theme.
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".
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.
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.
Posted: Wed Dec 27, 2006 11:33 pm
by netmaestro
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.
Posted: Wed Dec 27, 2006 11:37 pm
by Trond
netmaestro wrote:from somebody's theme engine
Not if they are using their personal theme engine. But if they are using the theme engine that ships with Windows XP.
Posted: Thu Dec 28, 2006 12:01 am
by netmaestro
Agreed then that the parameters of the challenge are that the buttons fit in with the themes that ship with Windows XP, and react in real time with changes to the theme as they occur. Deal?
Posted: Thu Dec 28, 2006 2:32 pm
by Trond
It should be any theme as long as the Windows XP theme engine is used. But that's very hard.
Posted: Fri Dec 29, 2006 6:30 am
by Fluid Byte
Gahh! I was messing around with the XP Theme API since yesterday only to come to a conclusion wich Trond already pointed out:
Did 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.
I am reffering to this thread:
http://www.purebasic.fr/english/viewtopic.php?t=22476
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)
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!
Posted: Fri Dec 29, 2006 7:12 am
by ts-soft
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)