帮助表明将gboGroupStyle添加到TButtonGroup上的ButtonOptions "指定按钮应继承容器上设置的组样式." 但这种解释仍然让我迷失 - 任何想法?
如果(在Delphi中)我这样做
Panel1.ManualFloat(Rect(500,500,600,600));
Run Code Online (Sandbox Code Playgroud)
面板不是浮动在指定的Rect位置,而是浮动在某种窗口的默认位置.如何让面板(或其他控件)浮动到指定位置.但它似乎确实具有正确的形状.我需要设置一些其他属性才能使其正常工作吗?
编辑:只是为了清楚.我希望上面的代码使得面板相对于屏幕的左上角位于(500x500)的100x100正方形,而不是.形状是正确的,但位置不正确.如果后续控件浮动,则它们在屏幕上级联.
编辑2:这在Delphi 7中似乎不是问题,但在Delphi 2007中通过XE2(可能更早)
我想让Drag和Dock在我的应用程序中也能像在Delphi IDE中那样工作(即能够在Object Inspector/Structure View中拖动它们并将它们停靠在合适的站点上).将表格对接到PageControl我已经取得了相当不错的成功,但是想知道是否有人知道如何使用小关闭按钮和引脚等工作.
我也有兴趣了解Delphi IDE使用哪些组件来实现这一目标.
可以在TForm上设置对齐,比如将一个表单设置为alTop,将另一个表单设置为alClient - 这两个表单以明显的方式占据整个屏幕区域.这在申请中是否合理?
我还注意到锚点暴露在表格上 - 但我不能想到它们会对它们有用(分辨率变化?MDI应用程序?)任何想法?
我想要反转TClientDataSet中索引的顺序,下面的代码看起来应该做的伎俩但什么都不做.有没有一种很好的方法来扭转索引的顺序?
procedure TForm8.Button1Click(Sender: TObject);
var
index: TIndexDef;
begin
index := ClientDataSet1.IndexDefs.Find('LengthIndex');
if ixDescending in index.Options then
index.Options := index.Options - [ixDescending]
else
index.Options := index.Options + [ixDescending];
end;
Run Code Online (Sandbox Code Playgroud) 如果我在一个表单上实现一个接口,TMyForm = class(TForm, IMyInterface)当没有更多的接口引用时,该对象是否会自行释放?似乎没有,虽然我无法弄清楚如何计算TForm(如果有的话).当接口引用超出范围时,我担心表单被释放,但这似乎不会发生.
我想这个问题有两个部分,首先是一个表单是否可能意外释放(真正的问题),其次是表单是如何计算引用的.
我已经构建了一个简单的日志记录类,并希望确认它是线程安全的.基本上Log,RegisterLogger并将UnRegisterLogger从不同的线程调用. Log将被称为很多(来自许多不同的线程),RegisterLogger并且UnRegisterLogger很少.
基本上我的问题可归结为:" TList<x>线程读取是否安全?",也就是说我可以让多个线程同时访问a TList.
IExecutionCounterLogger是一个具有Log方法的接口(具有相同的签名TExecutionCounterServer.Log)
Type
TExecutionCounterServer = class
private
Loggers : TList<IExecutionCounterLogger>;
Synchronizer : TMultiReadExclusiveWriteSynchronizer;
public
procedure RegisterLogger(Logger : IExecutionCounterLogger);
procedure UnRegisterLogger(Logger : IExecutionCounterLogger);
procedure Log(const ClassName, MethodName : string; ExecutionTime_ms : integer);
constructor Create;
destructor Destroy; override;
end;
constructor TExecutionCounterServer.Create;
begin
Loggers := TList<IExecutionCounterLogger>.Create;
Synchronizer := TMultiReadExclusiveWriteSynchronizer.Create;
end;
destructor TExecutionCounterServer.Destroy;
begin
Loggers.Free;
Synchronizer.Free;
inherited;
end;
procedure TExecutionCounterServer.Log(const ClassName, MethodName: string; ExecutionTime_ms: …Run Code Online (Sandbox Code Playgroud) 我一直在使用cnPack和PascalAnalyzer Lite来清理一些大型项目中的uses子句,而且我保守地做了.特别是我没有删除任何有initialization节的东西.PascalAnayser给出了诸如此类的提示
==> COMMAND unnecessary (used by unit with init)
Run Code Online (Sandbox Code Playgroud)
我假设这是说当前单位不使用此单位,但它由具有initialization截面的单位使用.
该单元是否COMMAND完全可以安全删除,或者是否存在某些情况下删除它可能会导致某种运行时错误?
我注意到 Delphi 中支持一些表情符号和特殊字符作为变量名称,例如
\n\nvar\n \xe2\x9d\xa4 : string;\n \xe2\x85\x96 : double;\nbegin\n \xe2\x9d\xa4 := 'My heart';\n ShowMessage(\xe2\x9d\xa4);\n \xe2\x85\x96 := 0.4;\n ShowMessage(\xe2\x85\x96.ToString);\nend;\nRun Code Online (Sandbox Code Playgroud)\n\n有谁知道可以使用的有趣字符的完整列表吗?\n可以通过Win+[.](Windows 键加点)在 Win10 中调出表情符号字符。
\n当在 VCL 控件上调用 TRttiContext.GetType 时,为什么某些属性会重复(例如Action和Align),而其他属性则不会 ( AlignWithMargins)?
uses
System.RTTI,
System.Generics.Collections,
System.Generics.Defaults;
//....
procedure TForm11.btnShowPropertiesClick(Sender: TObject);
var
R: TRttiContext;
Props: TArray<TRttiProperty>;
Prop : TRttiProperty;
begin
memo1.Clear;
R := TRttiContext.Create;
Props := R.GetType(Sender.ClassType).GetProperties;
//Sort properties by name
TArray.Sort<TRttiProperty>(props,
TComparer<TRttiProperty>.Construct(
function(const Left, Right: TRttiProperty): Integer
begin
result := CompareText(Left.Name, Right.Name);
end
)
);
for prop in Props do
begin
try
Memo1.Lines.Add(
Prop.Name + ' : ' +
Prop.PropertyType.ToString + ' = ' +
Prop.GetValue(Sender).ToString);
except
Memo1.Lines.Add(Prop.Name + ' …Run Code Online (Sandbox Code Playgroud)