delphi

Delphi and finalization in a unit

I have two units unitA and unitB. Class TFoo is declared in unitB. Is it allways safe to call B.Free in finalization of unitA? How does it depend on in which order unitA and unitB are in dpr? Can I be sure that unitB exists when unitA finalization is executed? unit unitB; interface type TFoo = class // code... end; // code.....

Is there a I/O completion port based component for Delphi?

I am aware of Indy, ICS, Synapse and Clever InetSuite, none of which support IOCP. Is there anything else out there? Edit: I found iocpclasses , It's written in Delphi5. Better than nothing I suppose. ...

UseLatestCommonDialogs in Delphi 2010 leaks resources?

I have an application in where I let the user select a file from a TOpenDialog. When I have UseLatestCommonDialogs set to true (default), my application will crash after the user has click the button 10-15 times. The problem is isolated to this unique function, it the user avoids this step the application will not crash. When it crashe...

Delphi dbExpress and Interbase: UTF8 migration steps and risks?

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 UNICO...

"key violation" autoincrement field in ClientDataSet [Delphi]

Hi, this is my third question here, so far excellent responses ^^ I'm having no problems in browsing, editing the data, but insertions... Here is my doubt: In a finance/stock software i have a form to create a new order, naturally i need to insert a new row in t_orders table and insert items in t_orderitems table with orderId field lin...

Delphi OpenGL Drawing

I'm setting up my window like this: glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0, form1.Width, form1.height, 0, 0, 1); glMatrixMode (GL_MODELVIEW); glDisable(GL_DEPTH_TEST); And my drawing routine looks like this: tempdist:=0.3 / distance(i,0,1,2); xunit:=1 div 90; zunit:=1 div 74; glBegin(GL_LINE_LOOP); case players[i...

Nested record information hiding in Delphi

I have a relatively complicated data structure to model. I would like to do this with a record structure in Delphi, and the structure is complicated enough to justify splitting this into nested records. A simplified example: type TVertAngle = record strict private fDecDegrees: Double; fDegrees: integer...

Delphi Drawing Focus

I'm using the following code to make my form entirely transparent so that clicks can go "through" it to other windows. SetWindowPos( handle, HWND_TOPMOST, 0, 0, 0,0, SWP_NOSIZE or SWP_NOMOVE ); SetWindowLong(form1.handle,GWL_EXSTYLE,WS_EX_TOPMOST or WS_EX_LAYERED); SetLayeredWindowAttributes(form1.handle,RGB(0,0,0),2...

How to use external fonts?

Hello, Is it possible to use a font directly from resources in Delphi and how? I have a problem with the very first steps.Example I cannot include Segoe UI Light font in resources of a project,an exception occurs.And that is only if the file's extension is 'ttf'. If the written above is not possible then how do I use an external font ...

How to properly access query-results created in background thread?

I want to execute a database query in a background thread. The OmniThread library will help me with all the thread stuff, but there is one thing I don't understand so far: Every thread needs a separate database connection. The background thread therefore creates the DB connection, creates the query and then executes it. Now I could acc...

convert string charecter to ascii in delphi

How can i convert string character (123-jhk25) to ASCII in Delphi7 ...

Delphi "array of const" to "varargs"

Please help! I need this conversion to write wrapper for some C headers for Delphi. As an example: function pushfstring(fmt: PAnsiChar): PAnsiChar; cdecl; varargs; external; ... function PushString(fmt: AnsiString; const args: array of const): AnsiString; begin Result := AnsiString(pushfstring(PAnsiString(fmt), args)); // it's inco...

Creating a Binary Tree for a Knockout Tournament

I am trying to create a binary tree for use in a knockout tournament. The tree consists of TNodes with Left and Right pointers. This is the code that I have come up with (below); however, it runs into difficulties with the pointers in the CreateTree section. Once this creates an empty tree of large enough size, I need to add the names ...

Reading unicode characters from text file in Delphi 2009

I have the following piece of code to read Japanese Kanji characters from UTF-8 format Text file and then load it into Memo. Var F:textFile; S:string; Begin AssignFile(F,'file.txt'); Reset(F); While not EoF(F) do Begin Readln(F,S); Memo1.Lines.Add(S); End; CloseFile(F); End; But instead of characters I see some set of totall...

Casting anonymous procedures in Delphi 2009

The following code (constructed only to demonstrate the problem) compiles and works in Delphi 2010. In Delphi 2009, compiler fails with "E2035 Not enough actual parameters". program Project50; {$APPTYPE CONSOLE} uses SysUtils; type TMyProc = reference to procedure(param: integer); var a: TProc; b: TMyProc; begin b := proc...

Getting DUnit Test Coverage stats using FinalBuilder and AQTime

We have a large Delphi project (1.5 million lines of code), and we're moving to using agile processes. We already have a continous integration environment (FinalBuilder) which I've updated to include unit tests (dUnit) and code metrics (CodeHealer) in the e-mails to everyone in our development team. Our unit test coverage isn't great...

Existing procedure type for a messaging procedure in Delphi?

I frequently find myself declaring a simple procedure type TMessageProc = procedure(const AMsg: String); in Delphi. The purpose is to allow passing callback procedures to processing functions so that they can update the user interface without having to be aware of the user interface. Surely this must be a common paradigm in Delph...

How to deploy a commercial portable application?

Hi, We plan to sell a Windows portable application. By 'portable' I mean that it can be run from any Windows computer without installing it. For example from an USB stick etc. However the application while (theoretically) it can work anywhere, is targeted to LAN environments. What solutions do you see that while keeping this advantage ...

Package Memory Management

Since I have been running in a lot of difficulties when trying to use DLLs, I decided to try out runtime packages (mainly to avoid the memory manager and type registry problems). From my application I do something like this: HandleList := TList <THandle>.Create; try PackageObj.DoSomething (HandleList); finally FreeAndNil (HandleLi...

Anonymous methods cast as pointers

Hi all, can anyone explain why the code below fails? type TIDEThemeObserverFunc = reference to procedure(foo: integer); var fObserverFuncs: TList<TIDEThemeObserverFunc> function RegisterEventObserver(aObserverFunc: TIDEThemeObserverFunc): Pointer; begin fObserverFuncs.Add(aObserverFunc); Result := @aObserverFunc; // line below ...