我可以像这样定义记录常量:
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。(我意识到一个解决办法是将模板重新定义为字段的一个单一级别的记录。)
发布于 2014-02-08 19:20:55
是的,这是很有可能的,而且你几乎知道怎么做:
const mytemplate: template =
(header: (style: 1; dwExtendedStyle: 2; cdit: 3; x: 4; y: 5; cx: 6; cy: 7);
item: (style: 8; dwExtendedStyle: 9; x: 10; y: 11; cx: 12; cy: 13; id: 14));您只需在每个“级别”上遵循相同的模式。
https://stackoverflow.com/questions/21650653
复制相似问题