Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Styles/Control Hooks    [ Add a report in this area ]  
Report #:  107867   Status: Closed
StyleHooks change GDI handles of a Canvas under the hood causing wrong painting
Project:  Delphi Build #:  16.0.4504.48759
Version:    16.4 Submitted By:   Andreas Hausladen
Report Type:  Basic functionality failure Date Reported:  8/11/2012 2:58:00 PM
Severity:    Infrequently encountered problem Last Updated: 9/5/2012 7:43:54 PM
Platform:    All versions Internal Tracking #:   30916
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: None
Description
The TStyleHook.WMEraseBkgnd changes the device context's selected GDI handles to TCanvas default handles like "System" font.
If the device handle came from another TCanvas, the original TCanvas will still think that the selected GDI handles are the one that it has in its Font, Brush and Pen objects. Painting with it will give you strange results.

General rule: If you get a DC from somebody else, restore its state before you return.
Steps to Reproduce:
1. Open the attached project
2. Compile and Start the application
3. Press "Button 1"

Expected:
All assertions pass

Actual:
The second assertion fails because Canvas.Font.Name doesn't match the font that is selected into the DC.


4. Open the Project options and switch the style to "Windows"
5. Start the application.

Expected:
All assertions pass

Actual:
All assertions pass
Workarounds
None
Attachment
StyleEraseBkWrongSelectedDCObjects.zip
Comments

Tomohiro Takahashi at 8/13/2012 5:57:30 PM -
This report was opened with valid Internal Tracking Number.
Thanks.

Server Response from: ETNACODE01