Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Additional Controls/TBitBtn    [ Add a report in this area ]  
Report #:  92149   Status: Closed
When changed Windows theme (Classic) at runtime while application is running, the image of TBitBtn is vanished.
Project:  Delphi Build #:  15.0.3953.35171
Version:    15.1 Submitted By:   Hideaki Tominaga
Report Type:  Basic functionality failure Date Reported:  3/9/2011 2:34:45 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   282157
Resolution: Fixed (Resolution Comments) Resolved in Build: : 16.0.4180.40356
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
2.00 out of 5
Total Votes: 11
Description
When changed Windows theme (Classic) at runtime while application is running, the image of TBitBtn is vanished.

Please see Steps.
Steps to Reproduce:
1.Enable Windows themes.
2.Run test.exe. (Attachments)
3.Disable Windows themes at runtime while test.exe is running. (Window Classic)


EXP:
The image is displayed.

ACT:
The image is not displayed.
Workarounds
None
Attachment
source.zip
Comments

Tomohiro Takahashi at 3/9/2011 5:38:52 AM -
Could you please attach entire sample project to reproduce your issue?

Hideaki Tominaga at 3/9/2011 5:46:44 AM -
Added it.

Ahto Tanner at 4/9/2011 8:03:47 AM -
Fix is very simple, buttons.pas must be modified in 2 places. The issue is that painting routine sets TButtonGlyph(FGlyph).FThemesEnabled := true if themed paint is used but if themes are turned off TButtonGlyph(FGlyph).FThemesEnabled remains true. The following fix sets it to false before non-themed paintting is used.

1) procedure TSpeedButton.Paint;

At the end of procedure there is line:
TButtonGlyph(FGlyph).Draw(Canvas, PaintRect, Offset, Caption, FLayout, FMargin,
      FSpacing, FState, Transparent, DrawTextBiDiModeFlags(0));

Add one line before it so it reads:
    TButtonGlyph(FGlyph).FThemesEnabled := false;
    TButtonGlyph(FGlyph).Draw(Canvas, PaintRect, Offset, Caption, FLayout, FMargin,
      FSpacing, FState, Transparent, DrawTextBiDiModeFlags(0));


2) procedure TBitBtn.DrawItem(const DrawItemStruct: TDrawItemStruct);

About 13 lines before end of procedure there is line:

TButtonGlyph(FGlyph).Draw(FCanvas, R, Point(0,0), Caption, FLayout, FMargin,
      FSpacing, State, False, DrawTextBiDiModeFlags(0) or WordBreakFlag[WordWrap]);

Add one line before it so it reads:

TButtonGlyph(FGlyph).FThemesEnabled := false;
TButtonGlyph(FGlyph).Draw(FCanvas, R, Point(0,0), Caption, FLayout, FMargin,
      FSpacing, State, False, DrawTextBiDiModeFlags(0) or WordBreakFlag[WordWrap]);

Tomohiro Takahashi at 4/11/2011 5:36:24 PM -
Thanks for the information. I will update the internal status of this report.

Server Response from: ETNACODE01