gpt4 book ai didi

delphi - 如何在delphi中创建聊天标注

转载 作者:行者123 更新时间:2023-12-01 23:42:53 24 4
gpt4 key购买 nike

我想创建一个聊天气球,就像通过 FireMonkey TCalloutPanel 所做的那样,那么我该如何通过给它一个文本作为参数,然后根据给定的文本调整标注大小来实现这一点 ^^

提前致谢

最佳答案

我很快就写完了。可以以此为例来满足您的特定需求/愿望。另外,我强烈建议采用这种方式的自定义样式路线,将 TControls 添加到 TListBoxItem (尽管有效)会使 TListbox 滚动变得可怕。

procedure TForm1.LoadMessage(SelfSent:Boolean;msg:String;var LItem:TListBoxItem);
var
panel:Tcalloutpanel;
memo:TMemo;
begin
panel:=TCalloutPanel.Create(LItem);
panel.Parent:=LItem;
panel.Align:=TAlignLayout.Client;
panel.Margins.Left:=5;
panel.Margins.Right:=5;
panel.Margins.Top:=5;
panel.Margins.Bottom:=5;
if selfSent=true then
panel.CalloutPosition:=TCalloutPosition.right
else
panel.CalloutPosition:=TCalloutPosition.Left;
panel.CalloutOffset:=10;
memo:=TMemo.Create(panel);
memo.Parent:=panel;
memo.Align:=TAlignLayout.Contents;
memo.Margins.Left:=15;
memo.Margins.Right:=15;
memo.Margins.Top:=5;
memo.Margins.Bottom:=5;
memo.HitTest:=false;
memo.Text:=msg;

LItem.Height:=memo.ContentBounds.Height+30;
if LItem.Height<60 then
LItem.Height:=70;
end;

关于delphi - 如何在delphi中创建聊天标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30158938/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com