TControlCanvas.CreateHandle procedure
Ensures that a handle exists for the class instance.
Declaration
procedure CreateHandle; overrideDescription
Calls the inherited method on entry when a value has not been assigned to the Control property.
Otherwise, Control is used to check for an existing device context (HDC) for the class instance. When assigned, its value is copied into the Handle for the control.When not assigned, the HandleNeeded method in TWinControl is called to create the window handle and get its device context. If Control is not derived from TWinControl, its Parent is used to call the HandleNeeded method.
This is done to prevent resource leaks that might occur when directly accessing he window Handle before it has actually been allocated (recursive calls to the method).
If the device context remains unassigned, the GetDeviceContext method in Control is called to get the device context for the window Handle.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
