mayusod Posted March 20, 2015 Share Posted March 20, 2015 when I change the Font size of a label, width does not change. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 20, 2015 Administrators Share Posted March 20, 2015 Yes, many changes on web side are not reflected back to the server. Link to comment Share on other sites More sharing options...
mayusod Posted March 20, 2015 Author Share Posted March 20, 2015 can you tell me some solution? Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 20, 2015 Administrators Share Posted March 20, 2015 Main question here is that why you need to get width of label? Link to comment Share on other sites More sharing options...
mayusod Posted March 23, 2015 Author Share 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 Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 23, 2015 Administrators Share 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. Link to comment Share on other sites More sharing options...
mayusod Posted March 23, 2015 Author Share Posted March 23, 2015 Ok, back to beginning , does not change width after label rendered on the cliente screen. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 23, 2015 Administrators Share 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. Link to comment Share on other sites More sharing options...
mayusod Posted March 23, 2015 Author Share Posted March 23, 2015 This Works: UniImage1.pIcture.bitmap.Canvas.TextWidth('Hello World') Link to comment Share on other sites More sharing options...
eduardoA Posted March 10, 2016 Share 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. Link to comment Share on other sites More sharing options...
eduardoA Posted March 21, 2016 Share 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; Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now