程序代码如下
 with  tform(frmid) do //frmid是传递的表单参数
  begin
    for i:= ComponentCount   -1 downto 0   do 
      begin
         if   (Components[i]   is   TAction)   then
            (Components[i]   as   TAction).Enabled:=false;
      end;
   end; 
下面代码是在主程序过程中可以正常运行,然后我把它做成dll过程过就不能了。编译也不会出错,可程序运行中出现错误
1、先是(Components[i]   is   TAction)找不到taction
2、我把 if (Components[i].classname='TAction') then 这样后,下面的(Components[i] as TAction).Enabled:=false;就出现了转换错误。

解决方案 »

  1.   

    传递的参数是怎么写的?改成var如:procedure X(var frmid:TForm)
      

  2.   

    过程参数的地方是:procedure X(frmid:TForm) 没有var,不过有这个VAR这句跟下面有关系吗,用跟踪调试的时候Components[i].name也可以看到各个控件名称的呀。
      

  3.   

    用if (Components[i].classtype.classname='taction')
      

  4.   

    其它的都没有问题,关键是(Components[i] as TAction).Enabled:=false这句出错了
      

  5.   

    其它的都没有问题,就是(Components[i] as TAction).Enabled:=false这句出错了提示"invalid class typecast",因为有加if进行判断是不是这种类型,我觉得应该不是什么类型转换出错的呀。