mayusod Posted March 20, 2015 Posted March 20, 2015 when I change the Font size of a label, width does not change. Quote
Administrators Farshad Mohajeri Posted March 20, 2015 Administrators Posted March 20, 2015 Yes, many changes on web side are not reflected back to the server. Quote
Administrators Farshad Mohajeri Posted March 20, 2015 Administrators Posted March 20, 2015 Main question here is that why you need to get width of label? Quote
mayusod Posted March 23, 2015 Author Posted March 23, 2015 to place objects on the screen at runtime. you have some method to indicate the width in pixel of a text Delphi example: canvas.textwidth('Hello') or Canvas.textHeigth('Wordl')? thanks for you help Quote
Administrators Farshad Mohajeri Posted March 23, 2015 Administrators Posted March 23, 2015 Label width is determined on the client and you can only get it after label is rendered on the client screen. Quote
mayusod Posted March 23, 2015 Author Posted March 23, 2015 Ok, back to beginning , does not change width after label rendered on the cliente screen. Quote
Administrators Farshad Mohajeri Posted March 23, 2015 Administrators Posted March 23, 2015 Correct. Width changes are not reflected back to the server. You need to design your app regardless of runtime width of components. Or you can set the AutoSize to False and set a fixed width. Quote
mayusod Posted March 23, 2015 Author Posted March 23, 2015 This Works: UniImage1.pIcture.bitmap.Canvas.TextWidth('Hello World') Quote
eduardoA Posted March 10, 2016 Posted March 10, 2016 Hi Friends, I too need to change my controls width a lot, and a automatic solution would be very nice. We understand that sometimes we want to make better looking screens, so the controls must respond better to user commands and to run-time changes we made in the code. I found a way that is working very well to me. After you made any change that requires other controls to rearrange themselves, just put the code above: Self.With := Self.With +1; Self.With := Self.With -1; Example of use: we put 2 panels and a splitter between then. They move fine, but if we have other controls inside those panels, and those controls are aligned with right, left or client, they won't resize unless you use the code I just mention. Farshad Mohajeri did a great job with his framework, but he can't understand that simple issue is real. Quote
eduardoA Posted March 21, 2016 Posted March 21, 2016 function TPaginaPrincipal.TextWidth(s: TUniLabel): Integer; var c: TBitmap; f: TFont; begin { uma forma de calcular o tamanho de um texto na janela se o canvas não atualiza via ajax } c := TBitmap.Create; f := TFont.Create; Result := 8 * Length(s.Caption); f.Height := s.Font.Height; f.Size := s.Font.Size; f.Name := s.Font.Name; f.Style := s.Font.Style; try c.Canvas.Font.Assign(f); Result := c.Canvas.TextWidth(s.Caption); finally c.Free; end; end; 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.