Subject Re: [IBO] IB_LookupCombo and Themes
Author Geoff Worboys
Jason Wharton wrote:
> Geoff or someone,
> Have you looked into this aspect and can you help Guido?

The Enh components versions have XP theme support ... but
I've never used it myself so not sure how smooth it is.

http://www.telesiscomputing.com.au/enhcomp.htm

In the Telesis_Utils.pas unit you will find the function:
DrawStandardImage. Inside SUPPORT_XP_THEMES defines you
will find example theme drawing used in my components. Feel
free to grab what you need.

The actual code required is simpler than it may appear in
that unit. All you need is something like the following
pseudo-code:


uses themes;

function ...(Canvas: TCanvas; Rect: TRect);
var
Details : TThemedElementDetails;
Offset: integer;
begin
Offset := 0;
if not Enabled then
Offset := 3
else if [[state-is-pressed]] then
Offset := 2
else if [[state-is-hover]] then
Offset := 1;
Details := ThemeServices.GetElementDetails(
TThemedScrollBar(Ord(tsArrowBtnDownNormal) + Offset));
ThemeServices.DrawElement(Canvas.Handle, Details, Rect);
end;


This example code as two pieces that you may need to
experiment with to get the desired effect.

TThemedScrollBar - I chose to scroll-bar buttons for my
control buttons (except where the button gets small, then
change to using TThemedSpin which draw better for small).
I chose scroll-buttons because they worked better for my
stuff and gave me the option of drawing arrows in different
directions.

The Ord(tsArrowBtnDownNormal) code has to be altered to
draw whichever variation of TThemedScrollBar element you
want. You have to alter this to match the TThemed* object
you are drawing. See the Delphi Themes.pas unit (or online
help if you can make it work) to see what enumerations are
relevant to what TThemed* objects.

Since TIB_LookupCombo only ever wants a down arrow you may
find you are happier with combobox-specific code like:

Details := ThemeServices.GetElementDetails(
TThemedComboBox(Ord(tcDropDownButtonNormal) + Offset));
ThemeServices.DrawElement(Canvas.Handle, Details, Rect);


As for fitting this into the IBO code ... well that's for
someone else.

Notes:

I took a brief look and found TIB_CustomEdit.DrawButton inside
IB_Controls.pas ... but that already has themed drawing
(apparently) but it is apparently not used by lookupcombo.

It seems that what you are looking for is the ib_grids.pas unit
and the TIB_ComboButton class which derives from TSpeedButton.
I would have thought that TSpeedButton would have given you
something close to a themed button anyway ... but since you
tell it doesn't then you may need to alter TIB_ComboButton to
add an override for the Paint procedure, using code such as
that above. (In which case you would no longer need the
image resource you've been loading.) [All a bit convoluted
but that's what seems to be there.]

--
Geoff Worboys
Telesis Computing