[Misfeature] GroupBox deosn't have XP style

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

[Misfeature] GroupBox deosn't have XP style

Post by *Alextp »

As I can see, TGroupBox control (frame around other controls) not uses XP style.
Look at native programs: GroupBox must have

- rounded corners
- grayed lines
- blue caption

Can it be fixed?
User avatar
szlori
Senior Member
Senior Member
Posts: 263
Joined: 2005-01-17, 07:12 UTC
Location: Sydney

Post by *szlori »

To be honest, I like this better than the XP look-and-feel groupbox...
CoolWater
Power Member
Power Member
Posts: 737
Joined: 2003-03-27, 16:33 UTC

Post by *CoolWater »

szlori wrote:To be honest, I like this better than the XP look-and-feel groupbox...
but if TC/CG says it supports XP styles, it also should support groupbox styles. IMHO! Turning off XP L&F should display the groupbox as it is displayed at the moment.

Alextp
Support++, since it is a quite simple job to use XP L&F (just the same way as TC7 will (hopefully!) draw the XP L&F toolbar (buttons))

Regards,
CoolWater
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

I looked at the dialogs over and over again and thought something is strange. Now I know the reason :oops:
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2Lefteous
I just looked at my Delphi program (compiled in D5 and in D7) and saw the difference.

BTW, 2nd difference:
D7 applies style "Show left vertical row of buttons" to TOpenDialog/TSaveDialog.
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2Alextp
D7 applies style "Show left vertical row of buttons" to TOpenDialog/TSaveDialog.
I didn't know that this is a style. That works fine here in all my TC installations.
User avatar
Rocky
Junior Member
Junior Member
Posts: 13
Joined: 2004-12-23, 07:52 UTC

Post by *Rocky »

If you include resources file WindowsXP.RES in your D5 program({$R WindowsXP.RES}) or directly use unit XPMan(in fact this unit includes the resource file above) you D5 program can also appear XP theme style. The RES file can be found in D7 install dir or you can make one by yourself, just a XP manifest file.

D7 version of "Dialogs.pas" implement a feature TOptionsEx, just one option "ofExNoPlacesBar", if it set true, no "Left vertical row of buttons". It's a feature of Windows 2000/XP, D5 can also do this if you initialize the dialog box yourself :)
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2Rocky
Manifest is already included, so most of controls have XP style - except TGroupBox.
D7 version of "Dialogs.pas" implement a feature TOptionsEx, just one option "ofExNoPlacesBar", if it set true, no "Left vertical row of buttons".
I'll try it, thanks.
Is there an option to set style for TGroupBox?
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

Applied patch to TOpenDialog, it was easy.

Patch for TGroupBox is no so easy. THis needs to be added to TCustomGroupBox.Paint:

Code: Select all

    if ThemeServices.ThemesEnabled then
    begin
      if Text <> '' then
      begin
        GetTextExtentPoint32(Handle, PChar(Text), Length(Text), Size);
        CaptionRect := Rect(0, 0, Size.cx, Size.cy);
        if not UseRightToLeftAlignment then
          OffsetRect(CaptionRect, 8, 0)
        else
          OffsetRect(CaptionRect, Width - 8 - CaptionRect.Right, 0);
      end
      else
        CaptionRect := Rect(0, 0, 0, 0);

      OuterRect := ClientRect;
      OuterRect.Top := (CaptionRect.Bottom - CaptionRect.Top) div 2;
      with CaptionRect do
        ExcludeClipRect(Handle, Left, Top, Right, Bottom);
      if Enabled then
        Box := tbGroupBoxNormal
      else
        Box := tbGroupBoxDisabled;
      Details := ThemeServices.GetElementDetails(Box);
      ThemeServices.DrawElement(Handle, Details, OuterRect);

      SelectClipRgn(Handle, 0);
      if Text <> '' then
        ThemeServices.DrawText(Handle, Details, Text, CaptionRect, DT_LEFT, 0);
    end
So, TThemeServices class from Themes.pas needs to be used (Themes.pas absent in D2-D5)...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48097
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Thanks, I will try to add theming. However, the above code will not work correctly with all themes: The themes-specific DrawText uses theme-specific fonts for some themes. When using GetTextExtentPoint32, the font size of the currently selected font will be used instead.
Author of Total Commander
https://www.ghisler.com
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2ghisler(Author)
It was D7 code.
Maybe, D2006 have better code?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48097
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I had no problems to add theming to the TGroupBox (using the Theming API directly, not using a Delphi unit). The right function to call is GetThemeTextExtent instead of GetTextExtentPoint32. I tried it with several themes, and works OK.

However, there is another problem, see image:
http://ghisler.ch/img/groupbox.gif

The problem is that I'm using separator lines _within_ the groupbox to separate some items from each other. Of course this line doesn't use the groupbox border theme, so it looks odd. Any ideas how to solve this problem?
Author of Total Commander
https://www.ghisler.com
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
Wow the first TC 7 screenshot....

I guess you have to draw using DrawThemeEdge.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48097
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I guess you have to draw using DrawThemeEdge.
That doesn't help, it's still a completely different part+style...
Author of Total Commander
https://www.ghisler.com
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

2ghisler(Author)
TBevel doesn't have XP style at all. So don't use it (inside GroupBox).
BTW, did you ever see such view (Bevel inside GroupBox) in *standard* Win or Office dialogs? I didn't.
Last edited by Alextp on 2006-07-04, 10:39 UTC, edited 1 time in total.
Post Reply