Solved

Simulation of Variant type property

Posted on 1997-08-23
4
214 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now