[Lazarus] WorksheetGrid and Frames

Werner Pamler werner.pamler at freenet.de
Fri May 27 17:15:37 CEST 2016


Am 27.05.2016 um 12:43 schrieb Werner Pamler:
>
> As noted by a user in the forum 
> (http://forum.lazarus.freepascal.org/index.php/topic,32754.msg211392.html#msg211392), 
> TsWorksheetGrid (the grid of the fpspreadsheet package) fails if used 
> within frames. I am aware that normally I myself take care of 
> fpspreadsheet, but in this case I am lost because I am not so familiar 
> with the TFrame architecture.
>
> Whoever wants to look into this issue please note that the package 
> laz_fpspreadsheet_visual (from ccr) must be installed.
>
> Run the attached demo to reproduce the bug.
>
> - Click on button  "ShowWorksheetGridFrame". This should open a form 
> with an inserted TsWorksheetGrid. Hower, there is an error message 
> *"Control 'WorksheetGrid_Frame ' has not parent window"*. The fact 
> that you can open the project at all is because I removed the form 
> with the TsWorksheetGrid from the project. With this form included I 
> crashed Lazarus.
>
> - The bug occurs only if the WorksheetGrid is added to the form at 
> designtime. Open unit "main". In "BtnWorksheetGridFrameClick", comment 
> the line "frame := TWorksheetGrid_Frame.Create(self)" and uncomment 
> the line "frame := TWorksheetGrid_Frame_Runtime.Create(self)". This 
> activates code creating the worksheetgrid at runtime. If you run the 
> demo and click the button, everything is ok.
>
> - TsWorksheetGrid inherits from TsCustomDrawGrid, just like 
> TsDrawGrid. Button "ShowDrawGridFrame" inserts a frame containing a 
> design-time-created TDrawGrid. Everything is ok.
>
> The crash happens in "InitInheritedComponent" of classes. Is there 
> anything which has to be initialized in TsWorksheetGrid to pass this 
> test? But then, why is TDrawGrid ok which just publishes inherited 
> properties; all the code is in its ancestor which is shared with the 
> failing TsWorksheetGrid.
>
> Any help would be appreciated.
>
Found it! Always the same error: Using Loaded for something which should 
be done in CreateHandle... In this case, it was the grid methoded 
"Setup" which requires a handle. In the grid's Loaded, however, it does 
not yet have a handle because the frame into which the grid is inserted 
does not yet have its own parent at this moment.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160527/b2e89c76/attachment-0002.html>


More information about the Lazarus mailing list