delphi

What is your favorite Delphi mocking library?

I want to start using mock objects on my Delphi projects. After a quick google I've found those: Delphi Mock Wizard PascalMock So my question is what one is your favourite and why? ...

Counting the rows in a TDbGrid

I have a TDbGrid, and I can easily tell how many columns are in it at runtime with the FieldCount property, but there doesn't seem to be a corresponding RowCount property to display how many records are being displayed. How can I find this out? ...

What event fires every time a TDbGrid's selected location is changed?

I've got a TDbGrid in my project, and I'm trying to have an event go off every time I change the selected row. Any change in row already updates all the data-aware controls linked to the same DataSource, but there are other changes to be made too, that I need an event handler for. I thought OnColEnter would work. According to the help...

Cross-application drag-and-drop in Delphi.

I would like to create a Delphi application for Windows XP which allows dropping of files dragged from Windows Explorer (the Desktop or folder windows) or other applications which support this operation (such as Total Commander). What about vice-versa? When the user drags an icon from my application, I should be able to set the contents ...

Delphi: Delete visual component references from inherited forms

When I delete a visual component in a base form, and forget any references in inherited forms, my application only breaks in runtime. What I normally do is to use a search tool to find references in .DFM, but I'm not completely satisfied with this method. Do you have any better recommendations? ...

Delphi 2007 - Undeclared identifier: clHightlightText

I can not get clHightlight and clHightlightText colours to work in Delphi 2007, when I compile I get the errors: [DCC Error] GlobalFunctions.pas(412): E2003 Undeclared identifier: 'clHightlightText' [DCC Error] GlobalFunctions.pas(413): E2003 Undeclared identifier: 'clHightlight' But I have included the Graphic unit and in the same f...

How to set a GUID as ADO query parameters from Delphi?

MS Access allows the numeric type GUID (in German it's called 'Replikations-ID', so I guess in English that would be 'replication id') which is stored as a 16 byte binary field in the database. I found how to access these fields in Delphi with TAdoQuery/TAdoTable using TGuidField(...).AsGuid, but now I want to execute an SQL-Query like ...

How to call a Delphi DLL from VB6

Given the following Delphil DLL declaration function csd_HandleData(aBuf: PChar; aLen: integer): integer; stdcall; what would be the VB6 declaration to use it? I've tried a variety of declarations, e.g. Declare Function csd_HandleData Lib "chsdet.dll" (ByVal aBuf As String, ByVal aLen As Integer) Declare Function csd_HandleData Lib ...

How do I format an Integer using current locale in Delphi.

var i : integer; i := 1234567; Given the above, I want the string "1,234,567" as output (assuming UK locale). IntToStr just gives me "1234567". I'm sure there's a one-liner for this, but I can't find it... ...

safe(st) way rename a delphi Project

Im sure this will be a simple one but have a project that started as a test. When it was created it was saved as "Project2.dpr" Now the test is no longer a 'test', i would like to change the projects name to something more meaningful. whats the best way to do this? Any issues with just changing the file name and the Program line to t...

How to show Vista style balloon hints in Delphi?

On input validation, I'm using balloon tips instead of message boxes. My problem is that on Vista, they have the old XP style with the rounded corners, not the newer more rectangle like appearance. I've tried creating them using CreateWindowEx and tooltips_class32 or showing the Edit's associated balloontip using SendMessageW and EM_SHO...

How can a function with 'varargs' retrieve the contents of the stack?

Normally, in Delphi one would declare a function with a variable number of arguments using the 'array of const' method. However, for compatibility with code written in C, there's an much-unknown 'varargs' directive that can be added to a function declaration (I learned this while reading Rudy's excellent 'Pitfalls of convering' document...

What do I have to do to make my WH_SHELL or WH_CBT hook procedure receive events from other processes?

I'm trying to use SetWindowsHookEx to set up a WH_SHELL hook to get notified of system-wide HSHELL_WINDOWCREATED and HSHELL_WINDOWDESTROYED events. I pass 0 for the final dwThreadId argument which, according to the docs, should "associate the hook procedure with all existing threads running in the same desktop as the calling thread". I a...

Is there a TDBComboBox equivalent that goes by ItemIndex?

In the helpfile entry for TDBComboBox, it says that the text of the selected option becomes the new value for the field. Is there any similar control that goes by ItemIndex instead of text? (To represent an enumerated type, for example.) ...

Porting a unicode enabled Delphi 2006 application to Delphi 2009

I have an application which is fully unicode compatible in Delphi 2006. I had replaced all AnsiStrings with WideStrings, replaced all VCL controls with TNT controls, and changed all string functions from AnsiStrings to WideStrings. It looks like all that work was for nothing, because I'm going to have to reverse it all. Is there anyway t...

Counterpart of .NETs NetworkStream / SslStream in Delphi 7

I have written a secure TCP server in .NET. This was basically as simple as creating a TcpListener instance and wrapping the connected client's NetworkStreams with SslStreams. Now I need to access this TCP server with Delphi 7 (alternatively: Delphi 2007). I haven't found anything in the help, and a Google search shows up lots of compl...

What's the simplest way to call Http GET url using Delphi?

There's a web services I want to call in my application, I can use it with importing the WSDL or by just use "HTTP GET" with the URL and parameters, so I prefer the later because it's simple thing. I know I can use indy idhttp.get, to do the job, but this is very simple thing and I don't want to add complex indy code to my application. ...

What’s the simplest way to call Http POST url using Delphi?

Inspired by the question What’s the simplest way to call Http GET url using Delphi? I really would like to see a sample of how to use POST. Preferably to receive XML from the call. Added: What about including an image or other file in the post data? ...

Do you use regular builds as a coding tool?

We have a large (about 580,000 loc) application which in Delphi 2006 builds (on my machine) in around 20 seconds. When you have build times in seconds, you tend to use the compiler as a tool. i.e. write a little code, build, write some more code and build some more etc etc As we move some of our stuff over to C#, does anyone have a compa...

How does one escape characters in Delphi string

Delphi strings use single quotes, for example 'a valid string'. How does one specify the ' character within a literal string? How would one refer to the null byte (Unicode code point U+0000)? ...