'Invalid variant type conversion' in TEdit

;) I'm trying to use the 'PasswordChar'-Property of a TEdit class.
Always when starting the script, i get the error 'invalid variant type conversion'.

How can i solve the problem without adding a new special class?

Comments

  • edited 5:11AM
    Fix the fs_iinterpreter.pas file:
    function TfsPropertyHelper.GetValue: Variant;
    var
      p: PPropInfo;
      Instance: TObject;
    begin
      Result := Null;
      Instance := TObject(Integer(ParentValue));
    
      if FIsPublished then
      begin
        p := GetPropInfo(Instance.ClassInfo, Name);
        if p <> nil then
          case p.PropType^.Kind of
            tkInteger, tkSet, tkEnumeration, tkClass:
              Result := GetOrdProp(Instance, p);
    
            tkFloat:
              Result := GetFloatProp(Instance, p);
    
            tkString, tkLString, tkWString:
              Result := GetStrProp(Instance, p);
    
            tkChar, tkWChar:
              Result := Chr(GetOrdProp(Instance, p));
    
            tkVariant:
              Result := GetVariantProp(Instance, p);
          end;
      end
      else if Assigned(FOnGetValue) then
        Result := FOnGetValue(Instance, FClassRef, AnsiUpperCase(Name));
    
      if Typ = fvtBool then
        if Result = 0 then
          Result := False else
          Result := True;
    end;
    
    procedure TfsPropertyHelper.SetValue(const Value: Variant);
    var
      p: PPropInfo;
      Instance: TObject;
      IntVal: Integer;
    begin
      if IsReadOnly then Exit;
      Instance := TObject(Integer(ParentValue));
    
      if FIsPublished then
      begin
        p := GetPropInfo(Instance.ClassInfo, Name);
        if p <> nil then
          case p.PropType^.Kind of
            tkInteger, tkSet, tkEnumeration, tkClass:
            begin
              if Typ = fvtBool then
                if Value = True then
                  IntVal := 1 else
                  IntVal := 0
              else
                IntVal := Integer(Value);
              SetOrdProp(Instance, p, IntVal);
            end;
    
            tkFloat:
              SetFloatProp(Instance, p, Extended(Value));
    
            tkString, tkLString, tkWString:
              SetStrProp(Instance, p, String(Value));
    
            tkChar, tkWChar:
              SetOrdProp(Instance, p, Ord(String(Value)[1]));
    
            tkVariant:
              SetVariantProp(Instance, p, Value);
          end;
      end
      else if Assigned(FOnSetValue) then
        FOnSetValue(Instance, FClassRef, AnsiUpperCase(Name), Value);
    end;
    
  • edited 5:11AM
    ;) Thank you Admin.
    If changed the thing, tested it, and it worked.

Leave a Comment