Problem with BorderStyle

I have two own VCL ( VCL1 and VCL2 ) where I declare:

TBorderStyle ... (bsNone, bsSingleFlat .. )

Bouth vcls have a BorderStyle property.

When create VCL2 I wish to create a VCL1 inside VCL2.

Create VCL2
begin
  VCL1:=TVCL1,Create(Self);
  VCL.Border := bsNone; // Here I have a problem

The compiler told me that VCL1.BorderStyle isn't compatible with VCL2.BorderStyle ?!?!?

What to do ? The declarations for BorderStyle are the same .
LVL 9
ginsonicAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russell LibbySoftware Engineer, Advisory Commented:

Have you tried using the namespace qualifier?

eg:

Create VCL2
begin
  VCL1:=TVCL1,Create(Self);
  VCL1.Border := VCL1.bsNone; <-- qualifier


Regards,
Russell


0
Russell LibbySoftware Engineer, Advisory Commented:

In truth, if they are the **same**, then it would be better to just declare it once; inside a common unit or whatever, and then put that common unit in the uses clause of the units that will use the declaration. Otherwise, you will need to qualify the identifier with the unit that it comes from. (as I mentioned above)

Russell

0
BlackTigerXCommented:
you should have the base types (BorderStyle, etc) in a third unit, and then use that unit (those types) from both VCL1 and VCL2, then you can use the same "BaseTypes" unit in this one, where you are trying to assign the values and you won't have any problems

is a bad practice to duplicate types in various units
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

ginsonicAuthor Commented:
I try to use a single one but is same with standard, as name, TBorderStyle.

I changed to a single TginBorderStyle but when I create VCL1 and try to assign Border:=ginNone ( instead of bsNone ) I get an error as my VCL1 have no parent. But I use VCL1.Parent:=VCL2.
0
Russell LibbySoftware Engineer, Advisory Commented:

Not sure what the "no parent" error has to do with the border style, or how it even relates to the original question.

Russell
0
ginsonicAuthor Commented:
To be more clear:

unit VCL1

uses ....

type
  TBorderStyle = ( bsNone, bs3D, bsFlatSingle, bsFlatDouble );

type
  TVCL1 = class(TCustomControl)
  FBorder        : TBorderStyle;
  procedure SetBorder(Value:TBorderStyle);
  ................
  property Border         : TBorderStyle  read FBorder       write SetBorder     default bs3D;


unit VCL2

uses ....

type
  TBorderStyle = ( bsNone, bs3D, bsFlatSingle, bsFlatDouble );

type
  TVCL2 = class(TCustomControl)
  FBorder        : TBorderStyle;
  FVCL1          : TVCL1;
  procedure SetBorder(Value:TBorderStyle);
  ................
  property Border         : TBorderStyle  read FBorder       write SetBorder     default bs3D;
  ..............

constructor TVCL.Create(AOwner: TComponent);
begin
  FVCL1 := TVCL1.Create(Self);
  FVCL1.Parent := Self;
  FVCL.Border := bsNone;  //////////  My problem
0
Russell LibbySoftware Engineer, Advisory Commented:
As I have already stated, use the namespace qualifier. For example (using what you have provided so far):

unit vcl1;

interface

uses
  Windows, SysUtils, Classes, Controls, Forms, Dialogs;

type
  TBorderStyle      =  (bsNone, bs3D, bsFlatSingle, bsFlatDouble);

type
  TVCL1             =  class(TCustomControl)
  private
     // Private declarations
     FBorder:       TBorderStyle;
  protected
     // Protected declarations
     procedure      SetBorder(Value: TBorderStyle);
  public
     constructor    Create(AOwner: TComponent); override;
     destructor     Destroy; override;
  published
     property       Border: TBorderStyle read FBorder write SetBorder default bs3D;
  end;

implementation

constructor TVCL1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
end;

destructor TVCL1.Destroy;
begin
  inherited Destroy;
end;

procedure TVCL1.SetBorder(Value: TBorderStyle);
begin
  FBorder:=Value;
end;

end.

---------------

unit vcl2;

interface

uses
  Windows, SysUtils, Classes, Controls, Forms, Dialogs, vcl1;

type
  TBorderStyle      =  (bsNone, bs3D, bsFlatSingle, bsFlatDouble);

type
  TVCL2             =  class(TCustomControl)
  private
     // Private declarations
     FVCL1:         TVCL1;
     FBorder:       TBorderStyle;
  protected
     // Protected declarations
     procedure      SetBorder(Value: TBorderStyle);
  public
     constructor    Create(AOwner: TComponent); override;
     destructor     Destroy; override;
  published
     property       Border: TBorderStyle read FBorder write SetBorder default bs3D;
  end;

implementation

constructor TVCL2.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FVCL1:=TVCL1.Create(Self);
  FVCL1.Parent:=Self;
  FVCL1.Border:=vcl1.bsNone; // <<--- THIS WORKS FINE
end;

destructor TVCL2.Destroy;
begin
  FreeAndNil(FVCL1);
  inherited Destroy;
end;

procedure TVCL2.SetBorder(Value: TBorderStyle);
begin
  FBorder:=Value;
end;

end.

----

If you are running into other problems, such as "control has no parent", then that is a different (not to mention unrelated) problem, but one we would need more code to help you with.

Russell

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BlackTigerXCommented:
if is already declared in a Borland unit, then  you DON'T need to redeclare the types, just reuse the same ones from the Borland Unit
0
Russell LibbySoftware Engineer, Advisory Commented:
BlackTigerX,

The declaration is NOT the same as that from the forms unit

<forms.pas>

type

  TFormBorderStyle = (bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin);

  TBorderStyle = bsNone..bsSingle;

vs.

type
  TBorderStyle      =  (bsNone, bs3D, bsFlatSingle, bsFlatDouble);


I would agree though that a new identifier name should be used, and should be placed in a common unit instead of declaring it twice. (curently in vcl1 and vcl2)

Russell
0
ginsonicAuthor Commented:
Thanks to all for help!

I use same identifier becouse I wish to keep "bs" from border style. if I redeclare to TgnBorderStyle I can't use bsNone for example.

But anyway my vcl work perfect now. Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.