delphi

How to avoid circular unit reference?

Imagine the following two classes of a chess game: TChessBoard = class private FBoard : array [1..8, 1..8] of TChessPiece; ... end; TChessPiece = class abstract public procedure GetMoveTargets (BoardPos : TPoint; Board : TChessBoard; MoveTargetList : TList <TPoint>); ... end; I want the two classes to be defined in two separate ...

Delphi: Program Execution and internal procedure/function calling from CMD or using Doubleclick on associated extension

So - recently I run on some problems determining from which way program was called, if in both times parameters is the same - like: /something /something. I associate icon with program at runetime and i can use cmd to call it, but, whenever i doubleclikc on associated file ( with the icon ), progam simply opens, but does not calls neede...

Delphi Function to Display Number of Bytes as Windows Does

This is a simple one (I think). Is there a system built in function, or a function that someone has created that can be called from Delphi, that will display a number of bytes (e.g. a filesize), the way Windows displays in a file's Properties box? e.g. This is how Windows property box displays various sizes: 539 bytes (539 bytes) 35....

What is the most common way to create a folder selection dialog using Delphi?

There doesn't appear to be a simple component available to create a folder selection dialog in Delphi 2009, although a file selection dialog is provided by way of the TOpenDialog. What is the most common way to create a modern folder selection dialog using Delphi? ...

Converting a Double to an Integer for GetHashCode in Delphi

Delphi 2009 added the GetHashCode function to TObject. GetHashCode returns an Integer which is used for hashing in TDictionary. If you want an object to work well in TDictionary, you need to override GetHashCode appropriately such that, in general, different objects return different integer hash codes. But what do you do for objects c...

TTabSet vs. TTabControl vs. TPageCtrl/TTabSheet?

Hello I was wondering why Delphi (2007) provides three widgets that seem to do the same thing, and what the advantages/disadvantages are for each. On the same topic, if I want to display different sets of controls, why should I favor eg. PageControl + TabSheets + Frames, instead of just displaying different frames directly on the paren...

TListView.Clear freezes my application,how do i fix it?

Hello, I have a ListView:TListview on my form ,and, I add many values(approximately 25k TListViewItem) ,which works quite fast,but when I call Listview.Clear,the program freezes.I checked it with debugger,it won't step that line. My question is,how do I solve my problem? If creating so many items in less than a second is possible,why d...

How to change a subitem in a listview?

Hello, I used Listview.items.item[X].caption for changing the first column in a listbox,but now I have to change further at runtime.The only way I see is getting the item from listbox as TListItem ,editing it,add it and change position,but that doesn't suit it,because I have many items on the listview. Is there a simpler way to accompl...

What is the best way to serialize Delphi application configuration?

I will answer this question myself, but feel free to provide your answers if you are faster than me or if you don't like my solution. I just came up with this idea and would like to have some opinions on that. Goal: a configuration class that is readable (like an INI-file) but without having to write (and adapt after a new configuration...

Why doesn't my form's OnKeyDown event handler fire?

I'm using Delphi 2009 and I followed a tutorial at delphi.about.com, but I couldn't set it. I created an event OnKeyPress/OnkeyDown and set a breakpoint to see if the event is called, but it's not being called in any way. Where is the problem? EDIT: procedure TFormMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState)...

What should I do or don't do to avoid Delphi "push dword" bug.

I found that Delphi 5 generates invalid assembly code in specific cases. I can't understand in what cases in general. The example below produces access violation since a very strange optimization occurs. For a byte in a record or array Delphi generates push dword [...], pop ebx, mov .., bl that works correctly if there are data after thi...

Checking for Copy vs. Move in Delphi Drag and Drop

Using the 'standard' VCL drag and drop events OnDragOver and OnDragDrop, how can I distinguish between "Copy" and "Move" operations? I don't seem to have a TDragType available, and the keyboard Shift state isn't passed to these events. ...

How do you add a lookup field to a dataset?

I've got a dataset that I need a lookup field for. Problem is, this dataset's structure is defined by the result of a query. I can't add the field as a TFieldDef before setting .Active = true; because it gets overwritten, and I can't add it after running the query because you can't alter the structure of an open dataset. There has to ...

Delphi: how to access another application's controls?

I want to "view" information displayed by another application and "click" different buttons to automate a process. Have never done this before and would appreciate any advice on where to start and/or links. ...

Including resource file in a project by .RC file rather than .RES file

I remember reading an article or post somewhere years ago that suggested including a resource file in a project by referencing the .rc file instead of an already compiled .res file so that the resource is built as part of the project's build process. I have a glyphs.rc file that I currently compile using the command brcc32 glyphs.rc. In...

tatukgis, save & load layer properties

If someone have some experiences with TatukGIS developer kernel product, can you explain how to programmatically save and load layer properties like in their free TatukGIS viewer product? The environment i use were Delphi 7 and BDS 2006 thanks Edit, this code don't work: var lyrPeta: TGIS_LayerSHP; begin MapPath:= ExtractFilePat...

Fake modal dialog using Show ?

My application have several modules, each in one tab on the mainform. When using a dialog it is convenient to call ShowModal because you know when the dialog is finished. But for the user it is not good as it lock the whole program until the dialog closes. I want to have a locally modal dialog. So one module can open a dialog and it loc...

Any good, new Delphi books?

I've noticed that the number of good Delphi books is slowly going down to zero. Of course, there are plenty of books that explain the basics but good titles like the "Tomes of Delphi" series seem to have stopped. What I am looking for are recent, new book titles about Delphi that are useful for Delphi experts, not newbies. There are ple...

Delphi to PHP, Java or Ruby?

We're starting to think about the next stage of our company information strategy. At the moment various departments have Delphi VCL applications that focus on the information that they manage about their Projects. Behind the scenes we've been making sure that the thinking joins up. We're now at the point where we want to give people t...

How to specify Delphi interface GUID in Enterprise Architect?

I'm using Enterprise Architect code generation feature to export my models to Delphi code. Is there a way to specify interface GUIDs in EA so that interfaces are completely defined in the output code? Example: ILogger = interface procedure Log(AMessage: ILoggerMessage); end; should be ILogger = interface ['{16B77CF4-4219-412D-B1F3...