delphi

Problem setting parented to new form in DLL.

Please explain the difference between: ChildForm := TForm.CreateParented(AOwner) ChildForm := TForm.CreateParentedControl(AOwner) ChildForm := TForm.Create(AOwner); ChildForm.ParentWindow := AOwner.Handle This example may be complicated and convoluted, I'd really just like an overview of when people use the different kinds of Creat...

TFlowPanel. Adding controls at run-time.

Hi Does anybody know how to add controls, say a TImage, to a TFlowPanel at runtime? Regards, Pieter ...

ADO Database Table Boolean Column

Hello everyone. I am having a bit of trouble with ADO. I have deployed a database application, which uses Access. With the release of different versions database tables have different fields, some added others deleted etc. What I can't get to work is how to add a BOOLEAN field in the database. For upgrade purposes I use the standart sq...

*Sometimes* get an error when assigning to a constant in Delphi

I am using Delphi 2007 with all patches and updates. I have a file which is used by two different projects. In that file is a procedure, which I will simplify as follows: procedure MyProcedure; const UniqueValue: integer = 0; begin //some code Inc(UniqueValue); //some more code end; The Inc() command should fail, because you...

How to flush a TFileStream?

TFileStream provides buffered output, which is great in most cases, but in some cases (especially during debugging) it's nice to flush the buffer immediately. Thing is, I don't know of any way to do that except calling Free, which is kind of counterproductive. Is there a better way to do it? ...

Class Type Expected error on TableAdapter constructor

I am using Delphi Prism to connect to an Advantage Database Server. I created a connection using the server explorer to the database. I added a dataset object to my project and added a table to the dataset. Everything works fine in the IDE, however, I get an error in the generated designer code on the table adapter constructor. The erro...

How to use .Net assembly from Win32 without registration?

I'd like to dynamically load and use a .Net assembly created in C# from a Delphi Win32 application. My classes and interfaces are marked as ComVisible, but I would like to avoid registering the assembly. Is this possible? P.S. I found here link text another good discussion on the topic, but it is more around hosting the CLR. Which begs ...

Convert string with commas to float

Is there a built-in Delphi function which would convert a string such as '3,232.00' to float? StrToFloat raises an exception because of the comma. Or is the only way to strip out the comma first and then do StrToFloat? Thanks. ...

Declaring external functions depending on whether they exist

Hi. I would like to declare an external function from the kernel32.dll library whose name is GetTickCount64. As far as I know, it is defined only in Vista and in later Windows versions. This means that when I define the function as follows: function GetTickCount64: int64; external kernel32 name 'GetTickCount64'; I will certainly not ...

Row cannot be found for Locate?

Hi, I'm converting existing Advantage Database Server application to SQL Server 2005 using D2009, dbGo (ADO). Sometimes i experience the error row cannot be found for locating. I had googled it, according to results i needed to set Update Criteria property of each ADOTable and set cursor location to dynamic. I did so, but sometimes i sti...

Delphi - Sharing violation opening text file

I'm trying to open a text file for reading in a Delphi 7 app, but am getting I/O error 32 (sharing violation) because another application already has the file open. I've tried setting FileMode to "fmOpenRead or fmShareDenyNone" but now realise this doesn't apply to text files anyway. Is there a way of reading text files that are open by...

How can I detect if a Delphi class has a virtual constructor?

For example, is there a way to find out that this class has a virtual constructor (at runtime)? TMyClass = class(TObject) MyStrings: TStrings; constructor Create; virtual; end; For example, in this code I would like to test if the class referenced by Clazz has a virtual constructor: procedure Test; var Clazz: TCl...

How can I create an Delphi object from a class reference and ensure constructor execution?

How can I create an instance of an object using a class reference, and ensure that the constructor is executed? In this code example, the constructor of TMyClass will not be called: type TMyClass = class(TObject) MyStrings: TStrings; constructor Create; virtual; end; constructor TMyClass.Create; begin MyStrings := ...

Reference object instance created using "with" in Delphi

Hi, is there a way to reference an object instance that is created using the "with" statement? Example: with TAnObject.Create do begin DoSomething(instance); end; Where DoSomething would use the instance reference as if you were passing an instance from a variable declared reference to the object created. Example: AnObject := TAn...

.NET remoting and Delphi win32

Hi, Is it possible (and feasible) to use .NET Remoting interface with Delphi win32 application? I need communication between .NET application and Delphi win32 application, so .NET remoting would be native for other end of the pipe. Any other solutions, as close to native as possible, for both ends without 3rd party libraries? Applicat...

Pointer to generic type

In the process of transforming a given efficient pointer-based hash map implementation into a generic hash map implementation, I stumbled across the following problem: I have a class representing a hash node (the hash map implementation uses a binary tree) THashNode <KEY_TYPE, VALUE_TYPE> = class public Key : KEY_TYPE; Value ...

Derive from specialized generic types

Is it possible to derive a class from a specialized generic type: TGenericBase <T> = class // ... end; TSpecializedDerived = class (TGenericBase <String>) // ... end; Just wondering if this is possible at all... EDIT Code works fine when I put it in a new project. Must be due to some other mistake; sorry about that ...

Checking Printer Messages using OPOS Drivers in Delphi

I'm trying to open a Point of Sale (POS) printer using the OPOS Drivers in Delphi (BDS2006), but don't have a clue on how to check the printer status. How would I check for messages like Check Paper and Paper Jam from the printer? ...

How to shell to another app and have it appear in a delphi form

In Delphi I've used ShellExecute for years to launch (and optionally wait for) other applications. Now though, I need to have one of these applications appear in one of my Delphi app forms. I've tried the code below as a simple test to open notepad (which it does) and to display the result within PAnel1 on my form (which it doesnt). Can ...

Should I use unsigned integers for count members?

I just spent an hour tracking an integer overflow in my code, so I decided to share that -most people on here will know that of course, but perhaps I can save someone some time. So, here's the question: Should I use unsigned integers for my count class members? Answer For example, assume a class TList <T> = class private FCount : C...