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文檔中的描述相同。它只暗示,但實際上並沒有記錄記錄記錄的正確語法。 –
當然可以。您只需遞歸閱讀文檔。 –