Solved

Simulation of Variant type property

Posted on 1997-08-23
4
215 Views
Last Modified: 2013-11-23
Do you know how to simulate a VARIANT Type on published property ?
0
Comment
Question by:dsam
  • 3
4 Comments
 
LVL 1

Expert Comment

by:sassas081597
ID: 1342302
via Pointer
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 200 total points
ID: 1342303
Yes i know how.

but full implementation is for you.
This is template only and with new button which have variant property. You must decide which variants you need (integer, string, float ...).
You must write own GetValue and SetValue to do conversion from and to string which will shown in Object Inspector.

unit Varcomp;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TTestVariant = class(TButton)
  private
    fVariant : Variant;
  protected {}
  public {}
  published {}
    property TestPropVariant : variant read fVariant write fVariant;
  end;

procedure Register;

implementation

uses
  DsgnIntf;

type
  TVarRecProperty = class(TPropertyEditor)
  public
    function AllEqual: Boolean; override;
    function GetValue: string; override;
    procedure SetValue(const Value: string); override;
  end;

procedure Register;
begin
  RegisterComponents('Samples', [TTestVariant]);
  RegisterPropertyEditor( TypeInfo(Variant), TComponent, '', TVarRecProperty );
end;

function TVarRecProperty.AllEqual: Boolean;
var
  I: Integer;
  V: Variant;
begin
  Result := False;
  if PropCount > 1 then
  begin
    V := GetVarValue;
    for I := 1 to PropCount - 1 do
      if GetVarValueAt(I) <> V then Exit;
  end;
  Result := True;
end;

function TVarRecProperty.GetValue: string;
var Vv : Variant;
begin
  Vv := GetVarValue;
  Result := '12.12';  { here you must change Variant Vv to string }
end;

procedure TVarRecProperty.SetValue(const Value: string);
var V : Variant;
begin
  Vv := 12.12; { here you must change String to Vv Variant Value }
  SetVarValue( Vv );
end;

end.
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1342304
Hi
What happened ? Any questions ?
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1342305
another man on holliday.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question