delphi-5

Enumerations in Delphi with custom values

Hi! It is possible to declare enums with custom values in Delphi 5 like this?: type MyEnum = (meVal1 = 1, meVal2 = 3); // compiler error Thanks! ...

Delphi: Return value might be undefined, despite setting it after begin

Hi, can anyone tell me why I get "Return value ... might be undefined" here: function TXMLAcceptorBCOLSubmission.createRecordsInBCFEEPAR(AXML: TRipXMLElement): String; var ... begin Result := ''; ...

Is there a way to disable font anti aliasing when using TextRect (aka ExtTextOut in GDI32) in Delphi?

I'm using a custom gauge, based on the example that came with Delphi (5 Enterprise). For those that don't know, it's like a smooth progress bar, but displays the percentage or value in the centre (vertically and horizontally) of the component. To make sure the text is readable both when the gauge is filled and when it's empty, the text ...

Converting a string to TDateTime based on an arbitrary format

Hi, Is there any way in Delphi 5 to convert a string to a TDateTime where you can specify the actual format to use? I'm working on a jobprocessor, which accepts tasks from various workstations. The tasks have a range of parameters, some of which are dates, but (unfortunately, and out of my control) they're passed as strings. Since the...

Delphi: At runtime find classes that descend from a given base class?

Is there at way, at runtime, to find all classes that descend from a particular base class? For example, pretend there is a class: TLocalization = class(TObject) ... public function GetLanguageName: string; end; or pretend there is a class: TTestCase = class(TObject) ... public procedure Run; virtual; end; or pretend there i...

Delphi: How to hide ancestor constructors?

Update: gutted the question with a simpler example, that isn't answered by the originally accepted answer Given the following class, and its ancestor: TComputer = class(TObject) public constructor Create(Teapot: string=''); end; TCellPhone = class(TComputer) public constructor Create(Cup: Integer); overload; virtual; co...

Delphi: Understanding constructors

i'm looking to understand virtual override overload reintroduce when applied to object constructors. Every time i randomly add keywords until the compiler shuts up - and (after 12 years of developing with Delphi) i'd rather know what i'm doing, rather than trying things randomly. Given a hypothetical set of objects: TComputer = cla...

Delphi: How to add a different constructor to a descendant?

Update: The example i originally had was kind of complex. Here's a simple 8 line example that explains everything in one code block. The following does not compile gives a warning: TComputer = class(TObject) public constructor Create(Cup: Integer); virtual; end; TCellPhone = class(TComputer) public constructor Create(Cup: Integ...

Delphi: When does reintroduce hide ancestors and when does it show them?

Today Recently on Stackoverflow i learned that: reintroduce is used to hide ancestor constructors reintroduce is used to show ancestor constructors i've been trying to make sense of it all, so here is a another, very specific question, supporting my main question dealing with constructors. Update: replaced the entire question: TC...

Delphi: Overridden virtual constructor descendant not being called by overload

Yet another in my series of questions regarding constructors in Delphi. i have a base class that has has the virtual constructor: TComputer = class(TObject) public constructor Create(Teapot: Integer); virtual; end; The constructor is virtual for the times that someone needs to call var computerClass: class of TComputer; co...

Understanding constructor visibility

Here's two simple classes, initially both have no keywords (virtual, overload, override, reintroduce): TComputer = class(TObject) public constructor Create(Teapot: Integer); end; TCellPhone = class(TComputer) public constructor Create(Teapot: Integer; Handle: string); end; i will represent these above defintions as the slightly...

How to simulate an OnDestroy event on a TFrame in Delphi?

How can i simulate an OnDestroy event for a TFrame in Delphi? i nievely added a constructor and destructor to my frame, thinking that is what TForm does: TframeEditCustomer = class(TFrame) ... public constructor Create(AOwner: TComponent); override; destructor Destroy; override; ... end; constructor TframeEditCustomer.Creat...

How to not have a MainForm in Delphi?

i've been trying to get some modeless forms in my application to appear on the taskbar - taking advantage of the new useful taskbar in Windows 7. There's are many issues with the VCL that need to be undone before a form can exist on the taskbar. But the final issue is that minimizing the form that the VCL has designated the main form c...

Mocks: How to avoid children talking to parents?

i'm trying to test an object by passing a mock owner. Originally PartD would be passed a PartB1 as its owner: PartD partD = new PartD(partB1); Now i want to test a feature of PartD by passing it a mock owner: PartD partD = new PartD(mockPartB1); This works okay, except there are things PartD does that depends on it knowing some sta...

Delphi: How to move a class out of a unit;avoid circular references

Question: i want to split two classes out to their own file, while avoiding circular references. i have a unit with some classes (and some enumerations and constants). Anyone will recognize Click and Clack the tappet brothers: unit Cartalk; interface type TSolution = (solTransmission, solBrakes, solGremlins); TTappetBrothe...