[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problem with BorderStyle

Posted on 2004-10-27
10
Medium Priority
?
323 Views
Last Modified: 2010-04-05
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 .
0
Comment
Question by:ginsonic
[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
  • 5
  • 3
  • 2
10 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 12424511

Have you tried using the namespace qualifier?

eg:

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


Regards,
Russell


0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 12424563

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
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12426021
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 9

Author Comment

by:ginsonic
ID: 12430295
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
 
LVL 26

Expert Comment

by:Russell Libby
ID: 12433322

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
 
LVL 9

Author Comment

by:ginsonic
ID: 12433716
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
 
LVL 26

Accepted Solution

by:
Russell Libby earned 2000 total points
ID: 12433917
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
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12435332
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
 
LVL 26

Expert Comment

by:Russell Libby
ID: 12435992
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
 
LVL 9

Author Comment

by:ginsonic
ID: 12436298
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 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