【发布时间】:2014-06-06 21:45:19
【问题描述】:
Helo,我有以下内容:selectedPanel 应该获取点击的面板对象,如果点击了表单,selectedPanel 应该是“null”、nada、empty 等 :)
var
selectedBlock: Tpanel; <== fixed typo
...
procedure TForm1.stubPanelMouseDown(Sender: TObject...
begin
...
Panel:= Sender as TPanel;
if (*selectedBlock is not null*) then
begin
// ie, store the current panel
selectedBlock:= Panel;
end
else
begin
// empty the selection
*selectedBlock:= null*;
end;
所以问题是:我如何将该变量设置为“null”?执行 selectedBlock:= Unassigned 会引发错误。
谢谢
编辑:这仍然会引发错误:访问冲突
if (selectedBlock=nil) then <= fixed and works
begin
selectedBlock:= Panel;
end
else
begin
selectedBlock:= nil;
end;
【问题讨论】:
-
错误是“未定义的标识符'selectedBlock'”吗?那是因为您已将其声明为“selectedPanel”。
-
否,使用Unassigned时报错:“不兼容的类型:'TPanel'和'Variant'
-
那里有一些奇怪的 sn-ps。如果 selectedBlock = nil 然后 selectedBlock := nil
-
天哪!我现在开始工作了!...咖啡太多了,我没看到那个。谢谢 Sertac!