2
我可以定义记录常数是这样的:记录常量可以记录在Delphi 6中的记录吗?
const
dialoghdr: DLGTEMPLATE =
(style: 1; dwExtendedStyle: 2; cdit: 3; x: 4; y: 5; cx: 6; cy: 7);
dialogitem: DLGITEMTEMPLATE =
(style: 8; dwExtendedStyle: 9; x: 10; y: 11; cx: 12; cy: 13; id: 14);
,我可以明确的记录,像这样的记录:
type
template = packed record
header: DLGTEMPLATE;
item: DLGITEMTEMPLATE;
end;
,尽管编译器会接受这样的:
const mytemplate: template =(); // compiles!
有没有一种方法可以将常量放入()中?像
const mytemplate: template =
(header.style: 1; header.dwExtendedStyle: 2; header.cdit: 3...,
item.style: 8; item.dwExtendedStyle: 9; item.x: 10...);
或
const mytemplate: template =
((style: 1; dwExtendedStyle: 2; cdit: 3; x: 4; y: 5; cx: 6; cy: 7),
(style: 8; dwExtendedStyle: 9; x: 10; y: 11; cx: 12; cy: 13; id: 14));
东西记录常数可记录的记录,或者不是?我使用的是Delphi 6.(我意识到解决方法是将模板重新定义为字段的单级记录。)
您可以从文档中学习如何执行此操作:http://docwiki.embarcadero.com/RADStudio/en/Declared_Constants#Record_Constants –
这与Delphi 6文档中的描述相同。它只暗示,但实际上并没有记录记录记录的正确语法。 –
当然可以。您只需递归阅读文档。 –