Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
VCL
8-Byte Alignment
Action Classes
Additional Controls
Core VCL Classes
DFM to TEXT
Dialog Controls
Docking
Drag/Drop
Emulation Classes
Exceptions
Gestures
Graphics
MAPI Support
MDI Support
Multi-Monitor Support
OnGesture event
Printing
Property/Type Editors
Registry / INI Objects
Ribbon Controls
Sample Controls
Services
Standard Controls
Styles
Control Hooks
Designer
Other
Style Files
TCustomStyle
TCustomStyleServices
TStyleEngine
TStyleManager
TUxThemeStyle
System Controls
Thread support
Touch Controls
Type Info
Win 3.1 Controls
Win 32 Controls
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/VCL/Styles
[ Add a report in this area ]
Report #:
103962
Status:
Closed
Disabling a button from its OnClick handler fails to update the buttons's visual appearance
Project:
Delphi
Build #:
16.0.4429.46931
Version:
16.4
Submitted By:
David Heffernan
Report Type:
Crash / Data loss / Total failure
Date Reported:
3/6/2012 4:27:36 AM
Severity:
Critical / Show Stopper
Last Updated:
9/5/2012 7:57:23 PM
Platform:
All versions
Internal Tracking #:
26402
Resolution:
Fixed
(Resolution Comments)
Resolved in Build:
:
17.0.4625.53395
Duplicate of:
None
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
2
Description
When using VCL styles, setting the Enabled property of a TButton to False from that button's OnClick handler fails to update the button's visual appearance.
The button is disabled, it can not be clicked. However it still looks like it is enabled. Setting a the Enabled property of a different button (i.e. not the button whose OnClick handler is running) does modify the visuals.
Steps to Reproduce:
Reproduce the problem with the attached project.
The erroneous code is in the Paint method of TButtonStyleHook:
if FPressed then
Details := StyleServices.GetElementDetails(tbPushButtonPressed)
else if MouseInControl then //this condition is triggered even if the button is disabled
Details := StyleServices.GetElementDetails(tbPushButtonHot)
else if Focused then //this condition is triggered even if the button is disabled
Details := StyleServices.GetElementDetails(tbPushButtonDefaulted)
else if Control.Enabled then
Details := StyleServices.GetElementDetails(tbPushButtonNormal)
else
Details := StyleServices.GetElementDetails(tbPushButtonDisabled);
This code should read:
if not Control.Enabled then
Details := StyleServices.GetElementDetails(tbPushButtonDisabled);
else if FPressed then
Details := StyleServices.GetElementDetails(tbPushButtonPressed)
else if MouseInControl then
Details := StyleServices.GetElementDetails(tbPushButtonHot)
else if Focused then
Details := StyleServices.GetElementDetails(tbPushButtonDefaulted)
else
Details := StyleServices.GetElementDetails(tbPushButtonNormal)
Workarounds
If the button's window handle is recreated this is sufficient to produce the correct visuals:
Button1.Perform(CM_RECREATEWND, 0, 0);
Attachment
VclStylesButtonEnabled.zip
Comments
Tomohiro Takahashi at 4/3/2012 7:51:11 PM
-
This report was opened with valid Internal Tracking Number.
Thanks.
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us