delphi-2009

Delphi interface inheritance: Why can't I access ancestor interface's members?

 ̄綄美尐妖づ 提交于 2019-11-28 00:56:05
Assume you have the following: //Note the original example I posted didn't reproduce the problem so //I created an clean example type IParent = interface(IInterface) ['{85A340FA-D5E5-4F37-ABDD-A75A7B3B494C}'] procedure DoSomething; end; IChild = interface(IParent) ['{15927C56-8CDA-4122-8ECB-920948027015}'] procedure DoSomethingElse; end; TGrandParent = class(TInterfacedObject) end; TParent = class(TGrandParent) end; TChild = class(TParent, IChild) private FChildDelegate: IChild; public property ChildDelegate:IChild read FChildDelegate implements IChild; end; TChildDelegate = class

Delphi 2009 - create a TPanel at runtime and change its color

£可爱£侵袭症+ 提交于 2019-11-28 00:55:52
got a strange problem: I create a TPanele at runtime and change its color - however, the color is still clBtnFace. Here' the code: procedure TForm1.Button1Click(Sender: TObject); var pnlTest : TPanel; begin pnlTest := TPanel.Create(Form1); pnlTest.Parent := Form1; pnlTest.Width := 100; pnlTest.Height := 100; pnlTest.Color := clRed; end; Any ideas? Thanks! When you want to have colored panels under a themed OS you have to set ParentBackground to False. user5512468 Try this :-) procedure TForm1.Button1Click(Sender: TObject); var pnlTest : TPanel; begin pnlTest := TPanel.Create(Form1); pnlTest

How to recompile a specific unit from the VCL?

邮差的信 提交于 2019-11-27 23:56:08
I want to apply a fix from QC to a Delphi 2009 unit (DBClient as it happens). I know I need to copy the unit to another directory and make the change to the copy. How do I then get Delphi to compile that unit and use it in favour of the DCU that already exists? If you don't want to modify the original .Pas file, I do this by copy the .Pas file into my application folder, then choose built project, it will create new dcu file in my application folder, which will be used instead of the original one. It's kind of a last resort (and not supported by CodeGear), but I do something similar to

Conditional behaviour based on concrete type for generic class

回眸只為那壹抹淺笑 提交于 2019-11-27 22:53:36
Since my question from yesterday was perhaps not completely clear and I did not get the answer I wanted, I will try to formulate it in a more general way: Is there a way to implement special behaviour based on the actual type of an instantiated generic type either using explict conditional statements or using some kind of specialization? Pseudocode: TGenericType <T> = class function Func : Integer; end; ... function TGenericType <T>.Func : Integer; begin if (T = String) then Exit (0); if (T is class) then Exit (1); end; ... function TGenericType <T : class>.Func : Integer; begin Result := 1;

Why is CharInSet faster than Case statement?

时光怂恿深爱的人放手 提交于 2019-11-27 20:10:17
I'm perplexed. At CodeRage today, Marco Cantu said that CharInSet was slow and I should try a Case statement instead. I did so in my parser and then checked with AQTime what the speedup was. I found the Case statement to be much slower. 4,894,539 executions of: while not CharInSet (P^, [' ', #10,#13, #0]) do inc(P); was timed at 0.25 seconds. But the same number of executions of: while True do case P^ of ' ', #10, #13, #0: break; else inc(P); end; takes .16 seconds for the "while True", .80 seconds for the first case, and .13 seconds for the else case, totaling 1.09 seconds, or over 4 times as

How to achieve smaller size of the executable?

只愿长相守 提交于 2019-11-27 19:51:53
Very recently I have come back to Delphi after a long pause and written a rather straightforward utility app my client requested to support an older release... I know these days the size does not matter much, but it struck me as odd that the one-unit application, when compiled, amounted to 1'084'416 b executable. The one and only .pas unit I wrote is some 20.8k large, mostly because of the richness of the gui. The uses clause is as follows: uses Windows, Messages, SysUtils, Variants, Classes, Controls, Forms, strutils, Dialogs, ADODB, DB, DBGrids, ExtCtrls, DBCtrls, StdCtrls, Grids, Menus,

Delphi dbExpress and Interbase: UTF8 migration steps and risks?

﹥>﹥吖頭↗ 提交于 2019-11-27 18:51:50
问题 Currently, our database uses Win1252 as the only character encoding. We will have to support Unicode in the database tables soon, which means we have to perform this migration for four databases and around 80 Delphi applications which run in-house in a 24/7 environment. Are there recommendations for database migrations to UTF-8 (or UNICODE_FSS) for Delphi applications? Some questions listed below. Many thanks in advance for your answers! are there tools which help with the migration of the

Delphi MSBuild Build Configurations From Command Line

谁都会走 提交于 2019-11-27 18:00:25
Delphi 2009 uses build configurations . When you create a new project you have two default build configurations "Debug" and "Release". Now I asked myself how to automate builds using MSBuild (which is supported by Delphi since version 2007). You can start the "msbuild" command in the "RAD Studio Command Prompt" in some Delphi project directory and it will build the default build configuration (the last activated build configuration inside the Delphi IDE). Now, I want to specify a certain (non-default) build configuration by a command line parameter. The Delphi help asserts that the parameter

Why are my units “compiled with a different version” of my own files?

一世执手 提交于 2019-11-27 17:50:51
问题 I'm building a program that uses plugins. Unfortunately, the plugin framework's dynamic linking forces the RTL and VCL out of my project EXE and into the BPL versions, and they don't have debug info enabled. So I built a testing framework that links to my plugins statically so I can actually see what I'm doing while tracing through the code. But now, every time I try to recompile, I get an error: "unit turbu_skills was compiled with a different version of turbu_database.GDatabase" I've seen

Delphi Enterprise: how can I apply the Visitor Pattern without circular references?

99封情书 提交于 2019-11-27 14:32:29
With Delphi 2009 Enterprise I created code for the GoF Visitor Pattern in the model view, and separated the code in two units: one for the domain model classes, one for the visitor (because I might need other units for different visitor implementations, everything in one unit? ' Big ball of mud ' ahead!). unit VisitorUnit; interface uses ConcreteElementUnit; type IVisitor = interface; IElement = interface procedure Accept(AVisitor :IVisitor); end; IVisitor = interface procedure VisitTConcreteElement(AElement :TConcreteElement); end; TConcreteVisitor = class(TInterfacedObject, IVisitor) public