Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 667

Summary: "Control has no parent window" error if the chart has no parent and you call Draw and then TeeCreateBitmap.
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: ExportAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED FIXED    
Severity: enhancement CC: david
Priority: Normal    
Version: 140220   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: http://www.teechart.net/support/viewtopic.php?p=65469#p65469
Chart Series: --- Delphi / C++ Builder RAD IDE Version:
Attachments: chart without parent can't be drawn and then exported

Description yeray alonso 2014-03-26 11:14:39 EDT
Created attachment 132 [details]
chart without parent can't be drawn and then exported

You can use TeeCreateBitmap to export a chart that has no parent.
But if you force a chart Draw before doing so, you get a "Control has no parent window" error.

And, in some situations you may need to force a chart repaint before exporting it so everything is at the correct place. Ie using CalcXPos/CalcYPos methods to set some element position.

For more details see the thread in the forums.
Comment 1 yeray alonso 2014-03-26 11:20:05 EDT
Note this crashes in TeeChart v8 too
Comment 2 david berneda 2014-03-26 12:53:25 EDT
One possible fix is the following code, using the chart Owner if Parent is nil.

TeeProcs.pas

function TCustomTeePanelExtended.GetDeviceContext(var WindowHandle: HWnd): HDC;
begin
  if Assigned(Parent) then
     WindowHandle:=Handle
  else
  if Assigned(Owner) and (Owner is TWinControl) then
     WindowHandle:=TWinControl(Owner).Handle;

  result:=GetDC(WindowHandle);
end;


If Owner is nil, it should still work, with WindowHandle=0.
Comment 3 yeray alonso 2017-07-31 07:47:21 EDT
This worked between v2014.10 and v2016.18 (both included) but it was broken again from v2016.19 (commit 86010700).
Comment 4 david berneda 2023-03-15 13:23:05 EDT
This should be fixed in the latest build March 23