fix xp themes drawing image on bitbtn

git-svn-id: trunk@5577 -
This commit is contained in:
micha 2004-06-18 19:55:43 +00:00
parent 336d0c8c30
commit 47ee7b1b10
5 changed files with 295 additions and 92 deletions

View File

@ -24,6 +24,11 @@
{ callback routines } { callback routines }
{*************************************************************} {*************************************************************}
{ addition XP messages }
const
WM_THEMECHANGED = $31A;
{ forward declarations } { forward declarations }
function ComboBoxEditWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; function ComboBoxEditWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
@ -894,6 +899,11 @@ Begin
LMessage.LParam := LParam; LMessage.LParam := LParam;
LMessage.WParam := WParam; LMessage.WParam := WParam;
End; End;
WM_THEMECHANGED:
begin
// winxp theme changed, recheck whether themes are enabled
TWin32WidgetSet(InterfaceObject).UpdateThemesActive;
end;
End; End;
If WinProcess Then If WinProcess Then
@ -1242,6 +1252,9 @@ end;
{ {
$Log$ $Log$
Revision 1.116 2004/06/18 19:55:43 micha
fix xp themes drawing image on bitbtn
Revision 1.115 2004/06/17 21:33:01 micha Revision 1.115 2004/06/17 21:33:01 micha
fix scroll message handling for comboboxes fix scroll message handling for comboboxes

View File

@ -36,7 +36,7 @@ Interface
successful compilation. successful compilation.
} }
Uses Uses
Windows, Classes, ComCtrls, Controls, Dialogs, DynHashArray, Windows, Classes, ComCtrls, Controls, Buttons, Dialogs, DynHashArray,
ExtCtrls, Forms, GraphMath, GraphType, InterfaceBase, LCLIntf, LCLType, ExtCtrls, Forms, GraphMath, GraphType, InterfaceBase, LCLIntf, LCLType,
LMessages, StdCtrls, SysUtils, VCLGlobals, Win32Def, Graphics, Menus; LMessages, StdCtrls, SysUtils, VCLGlobals, Win32Def, Graphics, Menus;
@ -115,6 +115,11 @@ Type
FStatusFont: HFONT; FStatusFont: HFONT;
FMessageFont: HFONT; FMessageFont: HFONT;
FThemesActive: boolean;
FThemeLibrary: HMODULE;
IsThemeActive: function: BOOL; stdcall;
IsAppThemed: function: BOOL; stdcall;
Function GetOwnerHandle(ADialog : TCommonDialog): HWND; Function GetOwnerHandle(ADialog : TCommonDialog): HWND;
Function GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean; virtual; Function GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean; virtual;
Procedure SetLabel(Sender: TObject; Data: Pointer); Procedure SetLabel(Sender: TObject; Data: Pointer);
@ -122,6 +127,7 @@ Type
Procedure ResizeChild(Sender: TWinControl; Left, Top, Width, Height: Integer); Procedure ResizeChild(Sender: TWinControl; Left, Top, Width, Height: Integer);
Procedure AssignSelf(Window: HWnd; Data: Pointer); Procedure AssignSelf(Window: HWnd; Data: Pointer);
Procedure ReDraw(Child: TObject); Procedure ReDraw(Child: TObject);
procedure DrawBitBtnImage(BitBtn: TBitBtn; ButtonCaption: PChar);
Procedure SetLimitText(Window: HWND; Limit: Word); Procedure SetLimitText(Window: HWND; Limit: Word);
Procedure ShowHide(Sender: TObject); Procedure ShowHide(Sender: TObject);
@ -172,6 +178,7 @@ Type
Function InitHintFont(HintFont: TObject): Boolean; Override; Function InitHintFont(HintFont: TObject): Boolean; Override;
Function RecreateWnd(Sender: TWinControl): Integer; virtual; Function RecreateWnd(Sender: TWinControl): Integer; virtual;
Procedure AttachMenuToWindow(AMenuObject: TComponent); Override; Procedure AttachMenuToWindow(AMenuObject: TComponent); Override;
procedure UpdateThemesActive;
// create and destroy // create and destroy
function CreateComponent(Sender : TObject): THandle; override; function CreateComponent(Sender : TObject): THandle; override;
@ -182,6 +189,7 @@ Type
{$I win32lclintfh.inc} {$I win32lclintfh.inc}
property AppHandle: HWND read FAppHandle; property AppHandle: HWND read FAppHandle;
property ThemesActive: boolean read FThemesActive;
End; End;
{$I win32listslh.inc} {$I win32listslh.inc}
@ -222,7 +230,7 @@ Uses
Win32WSStdCtrls, Win32WSStdCtrls,
// Win32WSToolwin, // Win32WSToolwin,
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
Buttons, Calendar, CListBox, Spin, CheckLst, WinExt, LclProc; Calendar, CListBox, Spin, CheckLst, WinExt, LclProc;
type type
{ Linked list of objects for events } { Linked list of objects for events }
@ -264,6 +272,9 @@ End.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.85 2004/06/18 19:55:43 micha
fix xp themes drawing image on bitbtn
Revision 1.84 2004/06/13 14:32:15 micha Revision 1.84 2004/06/13 14:32:15 micha
fix cursors to use what's available fix cursors to use what's available

View File

@ -39,6 +39,25 @@ Begin
begin begin
FMetrics.iMenuHeight := GetSystemMetrics(SM_CYMENU); FMetrics.iMenuHeight := GetSystemMetrics(SM_CYMENU);
end; end;
// see if XP themes are available, first check if correct
// common control library is loaded for themes support
if ((GetFileVersion('comctl32.dll') shr 16) and $FFFF) >= 6 then
begin
FThemeLibrary := LoadLibrary('uxtheme.dll');
if FThemeLibrary <> 0 then
begin
// load functions
Pointer(IsThemeActive) := GetProcAddress(FThemeLibrary, 'IsThemeActive');
Pointer(IsAppThemed) := GetProcAddress(FThemeLibrary, 'IsAppThemed');
end else begin
IsThemeActive := nil;
IsAppThemed := nil;
end;
end;
// init
UpdateThemesActive;
End; End;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -92,7 +111,10 @@ Begin
Windows.UnregisterClass(@ClsName, System.HInstance); Windows.UnregisterClass(@ClsName, System.HInstance);
// Windows.UnregisterClass(@ToolBtnClsName, System.HInstance); // Windows.UnregisterClass(@ToolBtnClsName, System.HInstance);
Inherited Destroy; if FThemeLibrary <> 0 then
FreeLibrary(FThemeLibrary);
inherited Destroy;
End; End;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -319,7 +341,7 @@ Begin
Case TControl(Sender).FCompStyle Of Case TControl(Sender).FCompStyle Of
csBitBtn: csBitBtn:
IntSendMessage3(LM_IMAGECHANGED, Sender, Nil); DrawBitBtnImage(TBitBtn(Sender), PChar(Data));
csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog, csFileDialog, csOpenFileDialog, csSaveFileDialog, csSelectDirectoryDialog,
csColorDialog, csFontDialog: csColorDialog, csFontDialog:
Begin Begin
@ -637,8 +659,8 @@ Begin
//TBitBtn //TBitBtn
LM_IMAGECHANGED, LM_LAYOUTCHANGED: LM_IMAGECHANGED, LM_LAYOUTCHANGED:
Begin Begin
GetClientRect(Handle, SizeRect); if Sender is TBitBtn then
InvalidateRect(Handle, @SizeRect, True); DrawBitBtnImage(TBitBtn(Sender), PChar(TBitBtn(Sender).Caption));
End; End;
{Displays a menu and makes it available for selection. Applications can use this function to display context-sensitive menus, {Displays a menu and makes it available for selection. Applications can use this function to display context-sensitive menus,
and will typically supply NULL for the parent_menu_shell, parent_menu_item, func and data parameters. and will typically supply NULL for the parent_menu_shell, parent_menu_item, func and data parameters.
@ -1328,6 +1350,220 @@ begin
end; end;
*) *)
{------------------------------------------------------------------------------
Method: TWin32WidgetSet.UpdateThemesActive
Params: None
Returns: Nothing
Updates the field FThemesActive to save whether xp themes are active
------------------------------------------------------------------------------}
procedure TWin32WidgetSet.UpdateThemesActive;
begin
if (IsThemeActive <> nil) and (IsAppThemed <> nil) then
FThemesActive := IsThemeActive() and IsAppThemed()
else
FThemesActive := false;
end;
const
BUTTON_IMAGELIST_ALIGN_LEFT = 0;
BUTTON_IMAGELIST_ALIGN_RIGHT = 1;
BUTTON_IMAGELIST_ALIGN_TOP = 2;
BUTTON_IMAGELIST_ALIGN_BOTTOM = 3;
BUTTON_IMAGELIST_ALIGN_CENTER = 4;
BCM_FIRST = $1600;
BCM_GETIDEALSIZE = BCM_FIRST + 1;
BCM_SETIMAGELIST = BCM_FIRST + 2;
BCM_GETIMAGELIST = BCM_FIRST + 3;
BCM_SETTEXTMARGIN = BCM_FIRST + 4;
BCM_GETTEXTMARGIN = BCM_FIRST + 5;
{ - you do need to destroy the imagelist yourself.
- you'll need 5 images to support all themed xp button states...
Image 0 = normal
Image 1 = mouse hover
Image 2 = button down
Image 3 = button disabled
Image 4 = button focus
}
XPBitBtn_ImageIndexToEnabled: array[0..4] of Boolean =
(true, true, true, false, true);
type
BUTTON_IMAGELIST = packed record
himl: Windows.HIMAGELIST;
margin: Windows.RECT;
uAlign: UINT;
end;
{------------------------------------------------------------------------------
Method: TWin32WidgetSet.DrawBitBtnImage
Params: BitBtn: The TBitBtn to update the image of
ButtonCaption: new button caption
Returns: Nothing
Updates the button image combining the glyph and caption
------------------------------------------------------------------------------}
procedure TWin32WidgetSet.DrawBitBtnImage(BitBtn: TBitBtn; ButtonCaption: PChar);
var
BitmapHandle: HBITMAP; // Handle of the button glyph
BitBtnLayout: TButtonLayout; // Layout of button and glyph
BitBtnHandle: HWND; // Handle to bitbtn window
BitBtnDC: HDC; // Handle to DC of bitbtn window
OldFontHandle: HFONT; // Handle of previous font in hdcNewBitmap
hdcNewBitmap: HDC; // Device context of the new Bitmap
BitmapInfo: BITMAP; // Buffer for bitmap
TextSize: SIZE; // For computing the length of button caption in pixels
OldBitmap: HBITMAP; // Handle to the old selected bitmap
NewBitmap: HBITMAP; // Handle of the new bitmap
XDestBitmap, YDestBitmap: integer; // X,Y coordinate of destination rectangle for bitmap
XDestText, YDestText: integer; // X,Y coordinates of destination rectangle for caption
newWidth, newHeight: integer; // dimensions of new combined bitmap
BitmapRect: Windows.RECT;
oldImageList: HIMAGELIST;
ButtonImageList: BUTTON_IMAGELIST;
I: integer;
procedure DrawBitmap(Enabled: boolean);
var
OldBitmapHandle: HBITMAP; // Handle of the provious bitmap in hdcNewBitmap
BitmapFlags: integer; // flags for glyph (enabled or disabled)
TextFlags: integer; // flags for caption (enabled or disabled)
begin
BitmapFlags := DST_BITMAP;
TextFlags := DST_PREFIXTEXT;
if not Enabled then
begin
BitmapFlags := BitmapFlags or DSS_DISABLED;
TextFlags := TextFlags or DSS_DISABLED;
end;
OldBitmapHandle := SelectObject(hdcNewBitmap, NewBitmap);
FillRect(hdcNewBitmap, BitmapRect, BitBtn.Brush.Handle);
SetBkMode(hdcNewBitmap, TRANSPARENT);
if BitmapHandle <> 0 then
DrawState(hdcNewBitmap, 0, nil, BitmapHandle, 0, XDestBitmap, YDestBitmap, 0, 0, BitmapFlags);
DrawState(hdcNewBitmap, 0, nil, LPARAM(ButtonCaption), 0, XDestText, YDestText, 0, 0, TextFlags);
SelectObject(hdcNewBitmap, OldBitmapHandle);
end;
begin
// gather info about bitbtn
BitBtnHandle := BitBtn.Handle;
if BitBtn.Glyph.Empty then
begin
BitmapHandle := 0;
BitmapInfo.bmWidth := 0;
BitmapInfo.bmHeight := 0;
end else begin
BitmapHandle := BitBtn.Glyph.Handle;
Windows.GetObject(BitmapHandle, sizeof(BitmapInfo), @BitmapInfo);
end;
BitBtnLayout := BitBtn.Layout;
BitBtnDC := GetDC(BitBtnHandle);
hdcNewBitmap := CreateCompatibleDC(BitBtnDC);
OldFontHandle := SelectObject(hdcNewBitmap, BitBtn.Font.Handle);
GetTextExtentPoint32(hdcNewBitmap, LPSTR(ButtonCaption), Length(ButtonCaption), TextSize);
// calculate size of new bitmap
case BitBtnLayout of
blGlyphLeft, blGlyphRight:
begin
newWidth := TextSize.cx + BitmapInfo.bmWidth;
if BitmapHandle <> 0 then
inc(newWidth, 2);
newHeight := TextSize.cy;
if newHeight < BitmapInfo.bmHeight then
newHeight := BitmapInfo.bmHeight;
YDestBitmap := (newHeight - BitmapInfo.bmHeight) shr 1;
YDestText := (newHeight - TextSize.cy) shr 1;
end;
blGlyphTop, blGlyphBottom:
begin
newWidth := TextSize.cx;
if newWidth < BitmapInfo.bmWidth then
newWidth := BitmapInfo.bmWidth;
newHeight := TextSize.cy + BitmapInfo.bmHeight;
if BitmapHandle <> 0 then
inc(newHeight, 2);
XDestBitmap := (newWidth - BitmapInfo.bmWidth) shr 1;
XDestText := (newWidth - TextSize.cx) shr 1;
end;
end;
case BitBtnLayout of
blGlyphLeft:
begin
XDestBitmap := 0;
XDestText := newWidth - TextSize.cx;
end;
blGlyphRight:
begin
XDestBitmap := newWidth - BitmapInfo.bmWidth;
XDestText := 0;
end;
blGlyphTop:
begin
YDestBitmap := 0;
YDestText := newHeight - TextSize.cy;
end;
blGlyphBottom: begin
YDestBitmap := newHeight - BitmapInfo.bmHeight;
YDestText := 0;
end;
end;
// create new
if (newWidth = 0) and (newHeight = 0) then
NewBitmap := 0
else
NewBitmap := CreateCompatibleBitmap(BitBtnDC, newWidth, newHeight);
BitmapRect.left := 0;
BitmapRect.top := 0;
BitmapRect.right := newWidth;
BitmapRect.bottom := newHeight;
// destroy previous bitmap, set new bitmap
if FThemesActive then
begin
// winxp draws BM_SETIMAGE bitmap with old style button!
// need to use BCM_SETIMAGELIST
oldImageList := Windows.SendMessage(BitBtnHandle, BCM_GETIMAGELIST, 0, LPARAM(@ButtonImageList));
if oldImageList <> 0 then
oldImageList := ButtonImageList.himl;
if NewBitmap <> 0 then
begin
ButtonImageList.himl := ImageList_Create(newWidth, newHeight, ILC_COLORDDB or ILC_MASK, 5, 0);
ButtonImageList.margin.left := 2;
ButtonImageList.margin.right := 2;
ButtonImageList.margin.top := 2;
ButtonImageList.margin.bottom := 2;
ButtonImageList.uAlign := BUTTON_IMAGELIST_ALIGN_CENTER;
// for some reason, if bitmap added to imagelist, need to redrawn, otherwise it's black!?
for I := 0 to 4 do
begin
DrawBitmap(XPBitBtn_ImageIndexToEnabled[I]);
ImageList_AddMasked(ButtonImageList.himl, NewBitmap, ColorToRGB(BitBtn.Brush.Color));
end;
end else begin
ButtonImageList.himl := 0;
end;
Windows.SendMessage(BitBtnHandle, BCM_SETIMAGELIST, 0, LPARAM(@ButtonImageList));
if oldImageList <> 0 then
ImageList_Destroy(oldImageList);
if NewBitmap <> 0 then
DeleteObject(NewBitmap);
end else begin
OldBitmap := Windows.SendMessage(BitBtnHandle, BM_GETIMAGE, IMAGE_BITMAP, 0);
if NewBitmap <> 0 then
DrawBitmap(BitBtn.Enabled);
Windows.SendMessage(BitBtnHandle, BM_SETIMAGE, IMAGE_BITMAP, NewBitmap);
if OldBitmap <> 0 then
DeleteObject(OldBitmap);
end;
SelectObject(hdcNewBitmap, OldFontHandle);
DeleteDC(hdcNewBitmap);
ReleaseDC(BitBtnHandle, BitBtnDC);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TWin32WidgetSet.PaintPixmap Method: TWin32WidgetSet.PaintPixmap
Params: Surface - The surface onto which to paint the pixmap Params: Surface - The surface onto which to paint the pixmap
@ -1870,7 +2106,6 @@ Begin
End; End;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Function: TWin32WidgetSet.CreateComponent Function: TWin32WidgetSet.CreateComponent
Params: Sender - object for which to create visual representation Params: Sender - object for which to create visual representation
@ -1991,9 +2226,8 @@ Begin
Flags := Flags or BS_DEFPUSHBUTTON Flags := Flags or BS_DEFPUSHBUTTON
else else
Flags := Flags or BS_PUSHBUTTON; Flags := Flags or BS_PUSHBUTTON;
Flags := Flags or BS_OWNERDRAW; Flags := Flags or BS_BITMAP;
WindowTitle := nil; WindowTitle := nil;
IntSendMessage3(LM_LOADXPM, Sender, StrCaption);
End; End;
csButton: csButton:
Begin Begin
@ -3060,6 +3294,9 @@ End;
{ {
$Log$ $Log$
Revision 1.207 2004/06/18 19:55:43 micha
fix xp themes drawing image on bitbtn
Revision 1.206 2004/06/17 19:54:19 micha Revision 1.206 2004/06/17 19:54:19 micha
fix bug in drawing groupbox caption when it is a child of another groupbox fix bug in drawing groupbox caption when it is a child of another groupbox

View File

@ -60,6 +60,7 @@ Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt);
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer); procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD; function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD;
function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD; function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD;
function GetFileVersion(FileName: string): dword;
implementation implementation
@ -824,6 +825,26 @@ begin
end; end;
end; end;
function GetFileVersion(FileName: string): dword;
var
buf: pointer;
lenBuf: dword;
fixedInfo: ^VS_FIXEDFILEINFO;
begin
Result := $FFFFFFFF;
lenBuf := GetFileVersionInfoSize(PChar(FileName), lenBuf);
if lenBuf > 0 then
begin
GetMem(buf, lenBuf);
if GetFileVersionInfo(PChar(FileName), 0, lenBuf, buf) then
begin
VerQueryValue(buf, '\', pointer(fixedInfo), lenBuf);
Result := fixedInfo^.dwFileVersionMS;
end;
FreeMem(buf);
end;
end;
{$IFDEF ASSERT_IS_ON} {$IFDEF ASSERT_IS_ON}
{$UNDEF ASSERT_IS_ON} {$UNDEF ASSERT_IS_ON}
{$C-} {$C-}

View File

@ -193,84 +193,6 @@ var
end; end;
end; end;
procedure DrawOwnerButton(Data: PDrawItemStruct);
var Flags:integer; // How the button looks like (pressed or not pressed)
BitmapHandle: HBITMAP; // Handle of the button glyph
OldBitmapHandle: HBITMAP; // Handle of the provious bitmap in hdcNewBitmap
HdcNewBitmap: HDC; // Device context of the new Bitmap
OldFontHandle: HFONT; // Handle of previous font in hdcNewBitmap
BitmapBuf: BITMAP; // Buffer for bitmap
XDestBitmap: integer; // X coordinate of destination rectangle for bitmap
YDestBitmap: integer; // Y coordinate of destination rectangle for bitmap
TextSize: SIZE; // For computing the length of button caption in pixels
NewBitmap: HBITMAP; // Handle of the new bitmap
ButtonCaption: string; // Text written on the button
XDestText: integer; // X coordinate of destination rectangle for caption
YDestText: integer; // Y coordinate of destination rectangle for caption
BitmapFlags: integer; // flags for glyph (enabled or disabled)
TextFlags: integer; // flags for caption (enabled or disabled)
begin
ButtonCaption := TBitBtn(Sender).Caption;
NewBitmap := CreateCompatibleBitmap(Data^._HDC, Data^.rcItem.Right - Data^.rcItem.Left + 1, Data^.rcItem.Bottom - Data^.rcItem.Top + 1);
HdcNewBitmap := CreateCompatibleDC(Data^._HDC);
OldBitmapHandle := SelectObject(hdcNewBitmap, NewBitmap);
OldFontHandle := SelectObject(hdcNewBitmap, TBitBtn(Sender).Font.Handle);
BitmapHandle := TBitBtn(Sender).Glyph.Handle;
Windows.GetObject(BitmapHandle, sizeof(BitmapBuf), @BitmapBuf);
GetTextExtentPoint32(Data^._HDC, LPSTR(ButtonCaption), length(ButtonCaption), TextSize);
case TBitBtn(Sender).Layout of
blGlyphLeft: begin
XDestBitmap := Data^.rcItem.Left + ((Data^.rcItem.Right - Data^.rcItem.Left) - (TextSize.cx + BitmapBuf.bmWidth + 2)) shr 1;
YDestBitmap := Data^.rcItem.Top + ((Data^.rcItem.Bottom - Data^.rcItem.Top) - BitmapBuf.bmHeight) shr 1;
XDestText := XDestBitmap+BitmapBuf.bmWidth + 2;
YDestText := (Data^.rcItem.Bottom - Data^.rcItem.Top - TextSize.cy) shr 1;
end;
blGlyphRight: begin
XDestBitmap := Data^.rcItem.Right - ((Data^.rcItem.Right - Data^.rcItem.Left) - (TextSize.cx + BitmapBuf.bmWidth + 2)) shr 1 - BitmapBuf.bmWidth;
YDestBitmap := Data^.rcItem.Top + ((Data^.rcItem.Bottom - Data^.rcItem.Top) - BitmapBuf.bmHeight) shr 1;
XDestText := XDestBitmap - 2 - TextSize.cx;
YDestText := (Data^.rcItem.Bottom - Data^.rcItem.Top - TextSize.cy) shr 1;
end;
blGlyphTop: begin
XDestBitmap := Data^.rcItem.Left + ((Data^.rcItem.Right - Data^.rcItem.Left) - BitmapBuf.bmWidth) shr 1;
YDestBitmap := Data^.rcItem.Top + ((Data^.rcItem.Bottom - Data^.rcItem.Top) - (TextSize.cy + BitmapBuf.bmHeight + 2)) shr 1;
XDestText := (Data^.rcItem.Right - Data^.rcItem.Left - TextSize.cx) shr 1;
YDestText := YDestBitmap + BitmapBuf.bmHeight + 2;
end;
blGlyphBottom: begin
XDestBitmap := Data^.rcItem.Left + ((Data^.rcItem.Right - Data^.rcItem.Left) - BitmapBuf.bmWidth) shr 1;
YDestBitmap := Data^.rcItem.Bottom - ((Data^.rcItem.Bottom - Data^.rcItem.Top) - (TextSize.cy + BitmapBuf.bmHeight + 2)) shr 1 - BitmapBuf.bmHeight;
XDestText := (Data^.rcItem.Right - Data^.rcItem.Left - TextSize.cx) shr 1;
YDestText := YDestBitmap - 2 - TextSize.cy;
end;
end;
Flags := DFCS_BUTTONPUSH;
BitmapFlags := DST_BITMAP;
TextFlags := DST_PREFIXTEXT;
if (Data^.itemState and ODS_DISABLED) <> 0 then
begin
BitmapFlags := BitmapFlags or DSS_DISABLED;
TextFlags := TextFlags or DSS_DISABLED;
end;
if (Data^.itemState and ODS_SELECTED) <> 0 then
begin
inc(XDestBitmap);
inc(YDestBitmap);
inc(XDestText);
inc(YDestText);
Flags := Flags or DFCS_PUSHED;
end;
DrawFrameControl(HdcNewBitmap, Data^.rcItem, DFC_BUTTON, Flags);
SetBkMode(HdcNewBitmap, TRANSPARENT);
DrawState(HdcNewBitmap, 0, nil, BitmapHandle, 0, XDestBitmap, YDestBitmap, 0, 0, BitmapFlags);
DrawState(HdcNewBitmap, 0, nil, LPARAM(LPSTR(ButtonCaption)), 0, XDestText, YDestText, 0, 0, TextFlags);
SelectObject(HdcNewBitmap, OldBitmapHandle);
SelectObject(HdcNewBitmap, OldFontHandle);
DrawState(Data^._HDC, 0, nil, NewBitmap, 0, 0, 0, 0, 0, DST_BITMAP);
DeleteDC(HdcNewBitmap);
DeleteObject(NewBitmap);
end;
procedure DrawCheckListBoxItem(CheckListBox: TCheckListBox; Data: PDrawItemStruct); procedure DrawCheckListBoxItem(CheckListBox: TCheckListBox; Data: PDrawItemStruct);
var var
Selected: Boolean; Selected: Boolean;
@ -331,10 +253,6 @@ begin
begin begin
with TLMDrawItems(Message) do with TLMDrawItems(Message) do
begin begin
if Sender is TBitBtn then
begin
DrawOwnerButton(DrawItemStruct);
end else
if Sender is TCheckListBox then if Sender is TCheckListBox then
begin begin
// ItemID not UINT(-1) // ItemID not UINT(-1)
@ -3065,6 +2983,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.119 2004/06/18 19:55:43 micha
fix xp themes drawing image on bitbtn
Revision 1.118 2004/06/17 21:33:01 micha Revision 1.118 2004/06/17 21:33:01 micha
fix scroll message handling for comboboxes fix scroll message handling for comboboxes