I want to draw the themed border of a TEdit in a Paintbox. The code must be functional under Wi开发者_运维百科ndows Vista and 7. I have tried the following. It works only under Windows XP.
var
Details: TThemedElementDetails; //uses Themes
begin
if ThemeServices.ThemesEnabled then
begin
Details := ThemeServices.GetElementDetails(teEditRoot);
ThemeServices.DrawElement(PaintBox1.Canvas.Handle, Details, PaintBox1.ClientRect);
end;
end;
Under Windows XP all ist OK. But under Windows Vista and 7 the border is painted in dark gray. All 4 sides in the same color. But a TEdit under Vista looks different: The top border has a dark gray. The right border a medium gray. The left and bottom borders have a light gray. I hope you understand the difference. How to paint it in the right way? Thanks!
Try:
R := Rect(15, 15, 80, 30);
DrawThemeBackground(ThemeServices.Theme[teEdit], PaintBox1.Canvas.Handle, EP_EDITBORDER_NOSCROLL, ETS_NORMAL, R, @R);
/// DrawThemeBackground(ThemeServices.Theme[teEdit], PaintBox1.Canvas.Handle, EP_EDITTEXT, ETS_NORMAL, R, @R); <<< XP Behaviour
If you want your code to run in XP you should make that conditional, as on WinXP you should use the 2nd one.
精彩评论