procedure test()
var
   t: ttreeview;
begin
t:=ttreeview.Create(nil);
t.Items.Add(nil, 'asdf');
t.Free;
end;下面是错误信息:
---------------------------
Debugger Exception Notification
---------------------------
Project DOR.exe raised exception class EInvalidOperation with message 'Control '' has no parent window'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------可我真的没有parent window给它,怎么办。

解决方案 »

  1.   

    好像没有办法。不过你如果没有窗口,如何显示TreeView???
      

  2.   

    procedure test()
    var
       t: ttreeview;
    begin
    t:=ttreeview.Create(nil);
    t.parent := form1;
    t.Items.Add(nil, 'asdf');
    t.Free;
    end;
      

  3.   

    必须要有父窗口才行的
    procedure test();
    var
       t: ttreeview;
    begin
      t:=ttreeview.Create(nil);
      t.Parent := Application.MainForm;
      t.Items.Add(nil, 'asdf');
      t.Free;
    end;
      

  4.   

    是这样的,因为我只想使用TTreeNodes这个数据结构。
      

  5.   

    那你就继承TTreeNodes好了,干吗要继承TTreeView呢?
      

  6.   

    create一个临时FORM,
    parent赋值该临时FORM
    不要显示它就得了
      

  7.   

    Handle := Classes.AllocateHWnd(WndProc)
    t.Parent := Handleprocedure TMarqueePanel.WndProc(var Msg: TMessage);
    begin
      Result := DefWindowProc(Handle, Msg, wParam, lParam);  
    end;
      

  8.   

    注意,把上面的TMarqueePanel去掉,
      

  9.   

    to:lzfbird(), crossbow(La Vida Es Amor)
    估计你们俩个连我那段代码什么意思都没看懂,或者根本就是没看,我什么时候在继承对象了?!至少其它人说的,也就是再创建个窗体给它,不是说这方法不可以,但实在太笨,我正因为不想这么做所以才来这问的,不要当我是傻瓜以为我想不到这方法。这里唯一帮助我的是schmodock(愚人码头) ,兄弟,谢谢你的方法,尽管你的三角最少。
      

  10.   

    windindance(风舞轻扬) ,欣赏你的谦虚。