Kast2k Posted January 31, 2018 Share Posted January 31, 2018 Dear colleagues, I placed label on panel and on frame resize i'm sending ajaxevent to panel and server calculates label font size based on panel width and height. if EventName='updatePNRouteSize' then begin a:=Params.Text; w:=StrToIntDef(Params.Values['w'],100); h:=StrToIntDef(Params.Values['h'],100); lblRouteName.Font.Size:=CalcElementFontSize(lblRouteName.Caption,w,h div 4); //OK end; After that i'm trying to place label at the top on the panel. function resize(sender, width, height, oldWidth, oldHeight, eOpts) { console.log('resize lbl'); console.log(frmTest.pnRoute.getWidth()); //panel width (480) console.log((frmTest.pnRoute.getWidth()/2)); //half of panel width (240) console.log(frmTest.lblRouteName.getWidth()); //label width (130) console.log((frmTest.lblRouteName.getWidth()/2)); //half of label width (65) console.log((frmTest.pnRoute.getWidth()/2)-(frmTest.lblRouteName.getWidth()/2)); //label new X coord (175) frmTest.lblRouteName.setX((frmTest.pnRoute.getWidth()/2)- (frmTest.lblRouteName.getWidth()/2)); } In browser i saw strange things: 1. In console it shows that calculations are correct 2. But after frame show the label is placed not in panel center. 3. If i press F12 in browser then the label is placed as it was programmed. After console close the label position doesnt change and shows as needed. Could you please show me my errors? What i'm missing? Thank You. P.S. Of course i can replace label with panel and get the result but because i want to learn more in Unigui and Sencha so i'm trying so. Link to comment Share on other sites More sharing options...
mhmda Posted February 1, 2018 Share Posted February 1, 2018 Too many calculation... You can use layouts for that. What do you want to do? Image if it possible. 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 15, 2019 Share Posted April 15, 2019 hi @mhmda i'm with the same problem. I have a resizeble panel with a label and i'm trying with no success to resize the label togheter the panel. How can i resize the label togheter with the panel? Can you help? Thanks you! Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2019 Share Posted April 15, 2019 2 hours ago, freedowsRoO said: How can i resize the label togheter with the panel? Can you help? Hi, Can you please explain what you wanted? 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 15, 2019 Share Posted April 15, 2019 40 minutes ago, Sherzod said: Hi, Can you please explain what you wanted? Of course! As i said, i have a resizable panel on my application with a label inside him. When i resize the panel in run time i need that the text label resize togheter with the panel. Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2019 Share Posted April 15, 2019 6 minutes ago, freedowsRoO said: i have a resizable panel on my application OK 6 minutes ago, freedowsRoO said: When i resize the panel in run time i need that the text label resize togheter with the panel Sorry, this moment is not very clear to me Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 15, 2019 Share Posted April 15, 2019 1 minute ago, Sherzod said: OK Sorry, this moment is not very clear to me Sorry for my bad english. i'll try to explain.... i attached an example. I need the label to increase and decrease along with the panel. resize label.rar Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2019 Share Posted April 15, 2019 1 hour ago, freedowsRoO said: I need the label to increase and decrease along with the panel. I think there are many solutions for this, I will try to analyze 1 Link to comment Share on other sites More sharing options...
Sherzod Posted April 15, 2019 Share Posted April 15, 2019 One possible solution: 1. CustomCSS: .textCard { text-align: center; font-family: 'Bowlby One SC', cursive; //font-size: 3.5vw !important; } 2. UniLabel1 -> FontSize = 34 3. p1 -> OnResize event: procedure TMainForm.p1Resize(Sender: TUniControl; OldWidth, OldHeight: Integer); begin UniLabel1.Font.Size := Round(p1.Width * 0.08) end; 1 Link to comment Share on other sites More sharing options...
freedowsRoO Posted April 15, 2019 Share Posted April 15, 2019 This work perfectly! Thank you! 1 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