XP-Theming for TDBGrid

Delphi/C++Builder 7-2009

I have extended Jeremy North’s themed DBGrid with some additional features and some TDBGrid bugfixes. But that is not all. You can now theme all your TDBGrids in your applications without replacing them by hand. Adding the ThemedDBGrid.pas unit to your project is all you have to do. The unit will automatically replace all TDBGrid at runtime by a themed TDBGrid. (You must have an XP manifest for your application and XP theming must be active to see the difference).

Additional features compared to Jeremy North’s code:

  • Moving the mouse over the header invalidates the cell only if it must be repainted.
  • Supports multiple row selection

Included TDBGrid bugfixes:

  • Reduces WM_ERASEBKGND related flicker
  • Fixes multiple deLayoutChanged events when resizing one column.

Limitation:
TDBGrid descendants are not themed. Only TDBGrid is replaced at runtime.

Download:

Name IDE Version File Size Downloads Added
Themed DBGrid 7-2009 ThemedDBGrid.zip 5.03 KB 5782 times 2009-01-10

Download from Code Central:
http://cc.codegear.com/item/24513

History:

  • Version 2009-01-08
    • Fixed Indicator direction in bdRightToLeft BiDiMode (by Issam Ali http://www.issamsoft.com)
    • Fixed: WMEraseBkgnd didn’t work correctly in bidiRightToLeft BiDiMode
    • Added: Mouse wheel support
    • Added: Workaround for a RightToLeft painting bug (QC #70075)
  • Version 2008-03-21
    • Added support for Columns[].Title.Alignment
  • Version 2008-03-10
    • Fixed: TitleFont was not used
    • Fixed: indicator column was not aligned to the bottom line of the cells
  • Version 2008-03-02
    • Fixed AccessViolation if DataSource is NIL
    • DefaultDrawing isn’t forced anymore

9 thoughts on “XP-Theming for TDBGrid

  1. Samir

    Thanks a lot. I have downloaded it and now using it. I use also DelphiSpeedUp, DDevExtensions and C++ Compiler Enhancements. Working in C++Builder without “C++ Compiler Enhancements” is a torture. Will it be available for 2009 version? (CBB 2009 is faster than previous versions but it is still enough slow)

  2. Issam Ali

    I’ve tried ThemedDBGrid, and i’ve found a problem with right to left direction; when change the BiDiMode to bdRightToLeft the Arrow indicator still indicates to right (outside the grid), and that gives a wrong effect. I fixed this problem.
    http://blog.issamsoft.com/index.php?q=en/node/35
    BTW: I wrote to you about (the problem and fix) before but there is no reply 🙁

  3. Andreas Hausladen Post author

    Thanks for the bugfix. I have incorporated your changes (and the WM_PAINT workaround) into the new ThemedDBGrid unit.

  4. user

    Why download from Code Central? I am not registered there. How can I download the unit? 🙁

  5. Ante

    Thank you. Great work. You solved one of the biggest VCL problem.
    Could you do something about DbNavigator paint bug in themed mode (Delphi 2007, XP, QC52439)?

  6. Ante

    Thanks Issam. Can’t test this myself but I believe it works.

  7. Rüdiger Leilich

    Hallo Andreas,

    ich denke, ich habe einen kleinen Bug gefunden.
    Bei initialization steht:
    OrgTDBGrid_NewInstance := GetVirtualMethod(TDBGrid, vmtNewInstance);

    sollte das nicht
    OrgTDBGrid_NewInstance := GetVirtualMethod(DBGrids.TDBGrid, vmtNewInstance);
    heisen?

    Gruß
    Rüdiger

    1. Andreas Hausladen Post author

      Das funktioniert so schon, denn ThemedDBGrid.TDBGrid hat keine eigene NewInstance Klassenmethode und somit ist der von GetVirtualMethod zurückgelieferte Wert identisch mit DBGrids.TDBGrid.NewInstance.
      Besser aussehen tut es natürlich wenn man hier auch DBGrids.TDBGrid schreibt, was ich in der nächsten Version (falls es je eine geben wird) auch so machen werde.

Comments are closed.