我这样做不行:
在中间层中定义一个方法:
procedure SetAllMenuRight(const pForm: WideString); 
var
  _pForm: TForm;
begin
  _pForm := Application.FindComponent(pForm) as TForm;
end;
上面的转化好像会出错,到底在过程中该设什么类型的参数,又要如何转化,请各位高手帮忙啊!

解决方案 »

  1.   

    没有做过
    你传过程不就可以了
    实在不行,用dll
      

  2.   

    例如我想通过中间层一个接口函数,参客户端的每个FORM上通过此函数来判断按钮的权限
    因此想传一个FORM给中间层:
    如下:
    procedure SetAllBtnRight(UserCode, MenuCode: string; vself: string);
    var
      _RightName: string;
      _i, _S, _E: integer;
      _Caption: string;
      _Self: TForm;
    begin
      _Self := application.findcomponet(vSelf) as TForm;
      _RightName := '';
      with DmLeaderBrowse.Dt_GetRight do
      begin
        Close;
        CommandText :=  ' Declare @s varchar(8000) ' +
                        ' Set @s = '''' ' +
                        ' Select @s = @s + ''['' + r.RightName + '']'' from SmUserMenuRight umr ' +
                                            ' Left Join SmRight r on umr.RightCode = r.RightCode ' +
                                            ' where umr.UserCode =   ''' + UserCode + '''   and umr.MenuCode = ''' + MenuCode + '''' +
                        ' Select @s';
        Open;
        _RightName := Fields[0].AsString;
      end;
      
      //主要是用在这里遍历所有组件,如果是按钮则判断它的权限:
      for _i := 0 to _self.ComponentCount - 1 do
      begin
        if Copy(LowerCase(_self.Components[_i].Name), 1, 3) = 'btn' then
        begin
          if _self.Components[_i].ClassType = TButton then
          begin
            _Caption := '[' + trim((_self.Components[_i] as TButton).Caption) + ']';
            if Pos(_Caption, _RightName) > 0 then
              (_self.Components[_i] as TButton).Enabled := true
            else
               (_self.Components[_i] as TButton).Enabled := false;
          end
          else if _self.Components[_i].ClassType = TBitBtn then
          begin
            _Caption := '[' + trim((_self.Components[_i] as TBitBtn).Caption) + ']';
            if Pos(_Caption, _RightName) > 0 then
              (_self.Components[_i] as TBitBtn).Enabled := true
            else
               (_self.Components[_i] as TBitBtn).Enabled := false;
          end
          else if _self.Components[_i].ClassType = TSpeedButton then
          begin
            _Caption := '[' + trim((_self.Components[_i] as TSpeedButton).Caption) + ']';
            if Pos(_Caption, _RightName) > 0 then
              (_self.Components[_i] as TSpeedButton).Enabled := true
            else
               (_self.Components[_i] as TSpeedButton).Enabled := false;
          end
          else if _self.Components[_i].ClassType = TToolButton then
          begin
            _Caption := '[' + trim((_self.Components[_i] as TToolButton).Caption) + ']';
            if Pos(_Caption, _RightName) > 0 then
              (_self.Components[_i] as TToolButton).Enabled := true
            else
               (_self.Components[_i] as TToolButton).Enabled := false;
          end    end;
      end;
    end;