-5

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;
4

1 回答 1

5

使用nil常量将指针设置为“null” :

selectedBlock := nil;

Null是一个仅适用于Variantand的特殊值OleVariant

于 2014-06-06T21:46:53.733 回答