?
Solved

Simulation of Variant type property

Posted on 1997-08-23
4
Medium Priority
?
220 Views
Last Modified: 2013-11-23
Do you know how to simulate a VARIANT Type on published property ?
0
Comment
Question by:dsam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Expert Comment

by:sassas081597
ID: 1342302
via Pointer
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 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