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 - "Control has no parent window" error if the chart has no parent and you call Draw and then TeeCreateBitmap.
Summary: "Control has no parent window" error if the chart has no parent and you call ...
Status: RESOLVED FIXED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Export (show other bugs)
Version: 140220
Hardware: PC Windows
: Normal enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL: http://www.teechart.net/support/viewt...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-26 11:14 EDT by yeray alonso
Modified: 2023-03-16 09:19 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments
chart without parent can't be drawn and then exported (1.26 KB, application/octet-stream)
2014-03-26 11:14 EDT, yeray alonso
Details

Note You need to log in before you can comment on or make changes to this bug.
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