Solved

Simulation of Variant type property

Posted on 1997-08-23
4
209 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
Comment Utility
via Pointer
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 200 total points
Comment Utility
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
Comment Utility
Hi
What happened ? Any questions ?
0
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
another man on holliday.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

10 Experts available now in Live!

Get 1:1 Help Now