Re: [Lazarus] Custom control with stepwise size adjustment
Thanks for the hint but I found a solution. I've moved code to
ChangeBounds method and it looks like it works correctly with Anchors.
There is still a problem with form designer, but I can live with it - I
simply use object inspector instead of using a mouse.
W dniu 2018-09-19 o 15:17, Vojtěch Čihák via Lazarus pisze:
> Try set Constraints - set MinHeight=MaxHeight=your calculated height,
> and the same for Width.
> But it will maybe fool Lazarus autosizing mechanism.
> > Od: "gabor via Lazarus" <[hidden email]>
> > Komu: [hidden email] > > Datum: 19.09.2018 14:29
> > Předmět: [Lazarus] Custom control with stepwise size adjustment
> How to properly create a control with step-size adjustment? I mean a
> control whose width is a multiple of, eg. 16 (16,32,48...).
> In delphi, I simply override TCustomControl.SetBounds method.
> procedure TMyControl.SetBounds(aTop, aLeft, aWidth, aHeight: Integer);
> aWidth := (aWidth div 16) * 16;
> if aWidth = 0 then
> aWidth := 16;
> aHeight := (aHeight div 16) * 16;
> if aHeight = 0 then
> aHeight := 16;
> inherited SetBounds(aTop, aLeft, aWidth, aHeight);
> Unfortunately, the same does not work well with LCL. Especially in
> connection with Anchors or in form designer.
> So how to deal with it?
> Regards, Michał.
> Lazarus mailing list
> [hidden email] > https://lists.lazarus-ide.org/listinfo/lazarus >