Help to create a component lazarus / 31-LCL ---------------------------------------------------------------------- José Mejuto · 2014-05-21 14:45 Hello, I'm trying to create a component like the groupbox, this means that the client area should be smaller than the control real area. I can write a component that autosize inside controls as expected, but I can freely move a component outside expected "client area". I try using a panel inside my component located as the expected "client area" but now I can not drop visual components inside, they are added to the master component box, and if I remove the "csAcceptControls" from master component, I can not drop controls inside, not in master nor in the inlay TPanel. I was trying to investigate how "TTabControl" creates inlay "TTabSheets" so we can drop controls inside the sheet and not in the tab control but without success. Can anyone help me in this task ? Ideally several drop areas inside a component would be ideal (using panels in example) but a limited client area would be enought in this case. Just to test the idea a dropped control inside with Left:=0 and Top:=0 would be located 10 pixels from top of component area. Regards,   Jose ---------------------------------------------------------------------- Blaazen · 2014-05-21 14:58 QuoteI can write a component that autosize inside controls as expected, but I can freely move a component outside expected "client area".So you want that inserted components cannot be moved at design- time? Then you can anchor them. You can override method "InsertControl" and do anchoring there. ---------------------------------------------------------------------- Bart · 2014-05-21 16:59 Maybe override the AdjustClientRect procedure? This is form my experiments with an asymmetrical panel: Code: [Select]procedure TCustomAsymPanel.AdjustClientRect(var aRect: TRect); begin   inherited AdjustClientRect(aRect);   Inc(ARect.Left, FLeftBevelWidth);   Inc(ARect.Top, FTopBevelWidth);   Dec(ARect.Right, FRightBevelWidth);   Dec(ARect.Bottom, FBottomBevelWidth); end; Bart ---------------------------------------------------------------------- José Mejuto · 2014-05-21 18:38 Quote from: Blaazen on May 21, 2014, 04:58:31 pmQuoteI can write a component that autosize inside controls as expected, but I can freely move a component outside expected "client area".So you want that inserted components cannot be moved at design-time? Then you can anchor them. You can override method "InsertControl" and do anchoring there. Hello, No, controls can be moved freely inside client area (the smaller one) without anchoring. I'll try to create a bit of ascii art Code: [Select]------------ |          | |          | |          | |  ----    | |  |X |    | |  |  |    | |  ----    | ------------ A button located at the X position should have a Left:=0, Top:=0. I hope this little art explains my needs. ---------------------------------------------------------------------- José Mejuto · 2014-05-21 18:44 Quote from: Bart on May 21, 2014, 06:59:22 pmMaybe override the AdjustClientRect procedure? This is form my experiments with an asymmetrical panel: Code: [Select]procedure TCustomAsymPanel.AdjustClientRect(var aRect: TRect); begin   inherited AdjustClientRect(aRect);   Inc(ARect.Left, FLeftBevelWidth);   Inc(ARect.Top, FTopBevelWidth);   Dec(ARect.Right, FRightBevelWidth);   Dec(ARect.Bottom, FBottomBevelWidth); end; Bart Hello, I had already tested that solution. It works well for anchoring, autosizing, etc, but I can still put a control with Top:=0 just outsize the adjusted client rect. Just take a TGroupbox (on windows at least) and try to put a control just over the GroupBox title, you can not because the client area excludes the border. I was unable to find a way to do it with a TControl descendant. ---------------------------------------------------------------------- howardpc · 2014-05-21 19:04 Quote from: José Mejuto on May 21, 2014, 08:44:56 pmJust take a TGroupbox (on windows at least) and try to put a control just over the GroupBox title, you can not because the client area excludes the border. My experience differs. On Windows I can place controls (children of the groupbox) which completely obscure the groupbox title. ---------------------------------------------------------------------- Blaazen · 2014-05-21 19:30 I tried AdjustClientRect, BorderWidth and BorderSpacing.InnerBorder and nothing works (TCustomControl). ---------------------------------------------------------------------- José Mejuto · 2014-05-21 19:33 Quote from: howardpc on May 21, 2014, 09:04:00 pmQuote from: José Mejuto on May 21, 2014, 08:44:56 pmJust take a TGroupbox (on windows at least) and try to put a control just over the GroupBox title, you can not because the client area excludes the border. My experience differs. On Windows I can place controls (children of the groupbox) which completely obscure the groupbox title. Hello, Yes, but with negative Top axis value. Anyway the ideal solution would be a panel with just 2, 3, .. n panels inside (non overlapping) and where I can drop controls, but can not drop controls in master component, something like TTabControl which way of work I was unable to replicate ---------------------------------------------------------------------- Blaazen · 2014-05-21 19:44 Quote component, something like TTabControl which way of work I was unable to replicateDon't you mean TPageControl ? It's probably native control. ---------------------------------------------------------------------- howardpc · 2014-05-21 21:24 Have you tried basing your component on TFrame and using the OnDragDrop event to force positioning of a dropped control to restricted locations? ---------------------------------------------------------------------- José Mejuto · 2014-05-22 08:52 Quote from: howardpc on May 21, 2014, 11:24:41 pmHave you tried basing your component on TFrame and using the OnDragDrop event to force positioning of a dropped control to restricted locations? Hello, OnDragDrop should only run in runtime not design time, but anyway the problem is not move the child controls to restricted locations, the problem is "how to do the task in a clean/standard way" but maybe there is "no way" in the LCL API to perform this task and  some "tricks" may be used. Thank you to everybody for trying to help ---------------------------------------------------------------------- José Mejuto · 2014-05-22 08:54 Quote from: Blaazen on May 21, 2014, 09:44:35 pmQuote component, something like TTabControl which way of work I was unable to replicateDon't you mean TPageControl ? It's probably native control. Hello, I think it is completly own draw but for sure the creation of TabSheets is controlled by the component. I'll ask for help by mail to one of the people that submited code for such piece. Thank you.