当用户可以在打印表格上书写和制作(如日期)时,我正在寻找打印发票和声明的最佳解决方案.我已经测试了Delphi的所有打印组件,但是没有一个允许最终用户(例如)检查打印时的复选框,而不需要编辑任何东西 - 只需单击即可.也许我错过了什么,你有什么建议?
我有自定义集合属性,当它是我的组件的直接成员时,它工作得很好.
但我想将集合属性移动到我的组件中的TPersistent属性.现在出现问题,它不起作用:双击对象检查器中的集合属性通常会打开集合编辑器,但它不再存在.
所有的拳头 - 我应该传递给TPersistent属性的构造函数?
TMyCollection = class(TCollection)
constructor Create(AOwner: TComponent); // TMyCollection constuctor
...
Run Code Online (Sandbox Code Playgroud)
我无法通过自我,所以我应该通过我的执着主人?
constructor TMyPersistent.Create(AOwner: TComponent);
begin
inherited Create;
fOwner := AOwner;
fMyCollection := TMyCollection.Create(AOwner); // hmmm... doesn't make sense
end;
Run Code Online (Sandbox Code Playgroud)
我想我错过了什么.如果需要更多代码,请评论此帖.

如何将字形属性添加到自定义组件?
Vcl.Buttons声明了类,TButtonGlyph但我不能使用它(Delphi没有在使用列表中看到Vcl.Buttons).
我将创建的对象传递给另一个对象的构造函数,该对象需要该对象实现的接口.
ISomeInterface = interface
['{840D46BA-B9FB-4273-BF56-AD0BE40AA3F9}']
end;
TSomeObject = class(TInterfacedObject, ISomeinterface)
end;
TSomeObject2 = class
private
FSomeInterface: ISomeinterface;
public
constructor Create(SomeObject: ISomeInterface);
end;
var
Form1: TForm1; // main form
SomeObject: TSomeObject;
constructor TSomeObject2.Create(SomeObject: ISomeInterface);
begin
FSomeInterface := SomeObject;
end;
// main form creating
procedure TForm1.FormCreate(Sender: TObject);
var SomeObject2: TSomeObject2;
begin
SomeObject := TSomeObject.Create;
// SomeObject2 := TSomeObject2.Create(nil); // ok
SomeObject2 := TSomeObject2.Create(SomeObject); // not ok
try
// do some things
finally
SomeObject2.Free;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SomeObject.Free; // if …Run Code Online (Sandbox Code Playgroud) 我通过执行以下操作获取当前格式设置:
_FormatSettings := TFormatSettings.Create(GetThreadLocale);
Run Code Online (Sandbox Code Playgroud)
我的系统短日期格式dd.MM.yyyy,但_FormatSettings.shorDateFormat为dd/MM/yyyy。我应该用FormatSettings日期分隔符替换斜线还是我不知道其他东西?
我正在使用带有最新更新的 Windows 10。
我的实际短日期格式是:
我知道 - 我不能,但是.
我希望所有将实现我的接口的类具有相同的所有者(通常在构造函数中定义).这样做的最佳做法是什么?
我应该使用一些基本抽象类或类似的东西吗?
我正在尝试修改VirtualTreeView以在设计模式下查看树节点中的数据.
分配节点内存是私有静态方法,因此我无法做任何事情.我正在尝试重新分配内存以匹配新的大小.
出于测试目的,我正在尝试重新分配相同数量的内存:
ReallocMemory(Node, sizeof(Node^))
Run Code Online (Sandbox Code Playgroud)
但IDE在随机迭代中挂起了大量的AV.由于我对内存分配的了解非常缺乏,我认为我忘记了一些事情.你能指点我吗?
当我对某些查询执行explain analyze时,我已经从一些低值到一些更高的值获得了正常的成本.但是当我试图通过将enable_seqscan切换为false来强制使用表上的索引时,查询成本会跳转到疯狂的值,如:
Merge Join (cost=10064648609.460..10088218360.810 rows=564249 width=21) (actual time=341699.323..370702.969 rows=3875328 loops=1)
Merge Cond: ((foxtrot.two = ((five_hotel.two)::numeric)) AND (foxtrot.alpha_two07 = ((five_hotel.alpha_two07)::numeric)))
-> Merge Append (cost=10000000000.580..10023064799.260 rows=23522481 width=24) (actual time=0.049..19455.320 rows=23522755 loops=1)
Sort Key: foxtrot.two, foxtrot.alpha_two07
-> Sort (cost=10000000000.010..10000000000.010 rows=1 width=76) (actual time=0.005..0.005 rows=0 loops=1)
Sort Key: foxtrot.two, foxtrot.alpha_two07
Sort Method: quicksort Memory: 25kB
-> Seq Scan on foxtrot (cost=10000000000.000..10000000000.000 rows=1 width=76) (actual time=0.001..0.001 rows=0 loops=1)
Filter: (kilo_sierra_oscar = 'oscar'::date)
-> Index Scan using alpha_five on five_uniform (cost=0.560..22770768.220 rows=23522480 width=24) (actual time=0.043..17454.619 …Run Code Online (Sandbox Code Playgroud) delphi ×7
delphi-2010 ×2
delphi-7 ×2
delphi-xe2 ×2
interface ×2
coding-style ×1
oop ×1
optimization ×1
pointers ×1
postgresql ×1
sql ×1
tpersistent ×1
vcl ×1