delphi

What is a good naming convention for a routine that sets a global variable in the same class

Code Complete (Chapter 7, Section 3) says that a good function should be named for the value it returns and a good procedure name in a class should be named for what it does. When I write synchronized methods in Delphi (pre 2009) I sometimes need to use them to set global variables, a seemingly bad programming practice, but a necessar...

Distributing a design-time package w/third-party UI elements

Now that I am learning more about design time aspects of component development, I have what may turn out to be a couple of IDE "plugins" targeting Delphi 2007 (+ others if compatible). The forms / UI for these, ideally, will utilize some of the third party components I use regularly. Assuming the licensing is okay to distribute those c...

JclDotNet, and some odd calling patterns using assembler

We have our own glue-layer-code-thingamajig that allows us to host the .NET runtime in our Win32 Delphi program. This has allowed us to do a gradual transition to .NET over time. But, we have some problems with it from time to time, and yesterday I saw an answer here on SO that referred to Jcl's .NET host implementation, so I thought I'...

Standard URL encode function?

Is there a Delphi equivalent of .net's Url.UrlEncode()? ...

Should I use a TMemoryStream as an efficient buffer before writing to a file?

Hi, I am using D6 Professional and need to create a text file in a specific format from lots of small strings already in memory. For performance reasons, I am considering using a TMemoryStream to collate the file data, and then write it out to disk in one go via a TFileStream. But I have a half forgotten memory (probably from pre-D6 da...

How to get the property type name for custom properties?

In Delphi 2007, I added a new string type to my project: type String40 = string; This property is used in a class: type TPerson = class private FFirstName = String40; published FirstName: string40 read FFirstName write FFirstName; end; During runtime, I want to get the name of the property FirstName by using RTTI....

Bug in Delphi 2009? -> *.res not found in project search path (works in Delphi 2006)

Hi, I have a problem migrating from Delphi 2006 to Delphi 2009. A Project which uses the JVCL complains that jvconsts.res is missing. The file is definitly there. The project search path includes the directory where the file is located. (Note: I don't have JVCL in my global search path to make it more portable) But the file should be f...

How to tell what types are defined in a Delphi DCU?

I have a set of compiled Delphi dcu files, without source. Is there a way to determine what types are defined inside that dcu? ...

Determine when running in a virtual machine

Is there an official way for an application to determine if it is running in VMWare or Virtual PC (or whatever Microsoft is calling it now)? The code I have seen is usually a hack that took advantage of some odd behavioral side effect in a specific version of VMWare or Virtual PC. Ideally Delphi code, but if you can link to an offici...

Is the memory not reclaimed for Delphi apps running on Windows Server 2008 (sp1) ?

We have a D2007 application whose memory footprint grows steadily when running on Windows Server 2008 (x64, sp1). It behaves normally on Windows Server 2003 (x32 or x64), XP, etc... where it goes up and down as expected. We have tried with the included Memory Manager or the latest FastMM4 4.92 with the same results. Has anyone tried t...

Why is TestComplete so slow ?

We are using TestComplete from AQTime to test the GUI at client with our Client/Server application. It is compiled with Delphi 2007. The source of client is about 1.4 millions sourcelines. The hardware is a Intel dualcore 2.13 Mhz, 2 GB RAM using Windows XP Pro. I compile the application with all debug options and also link in TCOpenApp...

Organizing the search path

We create via "Tools | Options | Environment Variables" Variables like that: $(Sources) = D:\Sources\Delphi $(OurLib) = $(Sources)\OurLib\Src $(OurApp1) = $(Sources)\Applications\App1\3.x $(ThirdParty) = $(Sources)\ThirdPartyComponents We use these Variables in the project search path like that: ($OurApp1)\Src\Core;($OurApp1)\Src\GU...

Number of items stored in Bucket list

I was wondering how to get the number of items stored in a TBucketList. As far as I can see there is only the number of buckets and the bucket array available, so all I can think of is Count := 0; for I := 0 to BucketList.BucketCount - 1 do Inc (Count, BucketList.Buckets [I].Count); That does work but it seems odd to me, that I have...

Reference-counting for objects

Hi. In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did type TFileInfo = class (TInterfacedObject, IInterface) and removed all my manual calls to TFileInfo.Free. Unfortunately Delphi reported a lot of memory leaks. Sear...

Problem with setting Browsing Path in Delphi option page

Hi, I have a problem with setting Browsing Path in Delphi 2009: When I install a new component, I add DCU path to Delphi's Library Path, and source path to Delphi's Browsing Path. The application compiles fine, but holding Ctrl and clicking on any of the unit names for that component does not open the source file! It seems the only w...

Windows Messages Minimize App on Minimize Child

Hi all, I have a delphi application where the main form is a login form - this contains various database and user objects necessary for the program. Once the user logs in, I hide this form and open another. My issue is, how do I cause the application to minimize when the child form is minimized? I figured out how to restore the chi...

Why most Delphi examples use FillChar() to initialize records?

I just wondered, why most Delphi examples use FillChar() to initialize records. type TFoo = record i: Integer; s: string; // not safe in record, better use PChar instead end; const EmptyFoo: TFoo = (i: 0; s: ''); procedure Test; var Foo: TFoo; s2: string; begin Foo := EmptyFoo; // initialize a record // Danger ...

username and password prompt when trying to do SQL queries when connecting Microsoft Access to Delphi 7

As part of my university coursework, I was asked to design and create an HCI for a shop. Part of it is to connect Delphi 7 to MS Access and run SQL queries. I have the database connected to Delphi, but when I run the program and enter the query it prompts me to enter a username and password to access the database. Does anyone have any id...

HTML Doc Tool for Delphi 2009

Is there any free HTML creating documentation tool that fully understands Delphi 2009 features like generics and anonymous methods? I tried DelphiCodeToDoc but it crashes while parsing the source code. ...

When trying to run an SQL query in delphi using a button click nothing happens!!

Hello, I am trying to run SQL queries using a button click in Delphi, the database is successfully connected everything compiles fine when i enter the query i.e. "Select * from StaffDetails" and then click on run expecting it to show me the results in the DBGrid nothing happens at all the code for the button is as follows procedu...