David Marcus 1 Posted December 29, 2022 The Help for Vcl.Graphics.TCanvas.Font says: "The Canvas.Font property is only guaranteed to equal the Font property if you have an owner-drawn listbox (where you are expected to use the canvas). Even in that case, it is only guaranteed to equal the Font property once the first paint message is underway. If you use a canvas inside an ownerdraw event, everything should work as expected. Using the canvas for a reason outside the scope of its intended usage may give unpredictable results." https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Graphics.TCanvas.Font What does this mean? If I'm using the Canvas property of a control, do the properties of the Canvas (e.g., Handle, Font) agree with the control's? Share this post Link to post
Lajos Juhász 293 Posted December 29, 2022 As in the documentation it's going to be set in the paint event. Otherwise it's not guaranteed to be the same. Share this post Link to post
Remy Lebeau 1398 Posted December 30, 2022 On 12/28/2022 at 5:17 PM, David Marcus said: What does this mean? If I'm using the Canvas property of a control, do the properties of the Canvas (e.g., Handle, Font) agree with the control's? Only while the control is actively processing a paint operation invoked by the OS - ie, during a WM_PAINT or NM_CUSTOMDRAW or equivalent window message. Before the control's virtual Paint() method is called, or its public OnPaint/OnDraw... events are fired, both allowing user code to handle custom drawing, the relevant control properties are assigned to the Canvas. Outside of an active paint operation, the Canvas's properties are not guaranteed to match the control's properties, and likely will be defaults instead. Share this post Link to post