delphi-2009

How do I declare a TDictionary enumerator?

I've got a TDictionary that stores a bunch of objects indexed by name, and I'd like to be able to examine all of the objects. So I tried this: var enumerator: TMyObject; begin for enumerator in myDictionary do But that wouldn't compile. "Incompatible types: 'TMyObject' and 'TPair' So I tried it a bit differently: var enumerator:...

Why is CharInSet faster than Case statement?

I'm perplexed. At CodeRage today, Marco Cantu said that CharInSet was slow and I should try a Case statement instead. I did so in my parser and then checked with AQTime what the speedup was. I found the Case statement to be much slower. 4,894,539 executions of: while not CharInSet (P^, [' ', #10,#13, #0]) do inc(P); was timed at 0...

Converting Integer value into AnsiString in Delphi 2009

IntToStr() function returns string which is Unicode now. I want converting to AnsiString. Can I use AnsiString(IntToStr(I)) safely? ...

D2009 VCL unit that won't compile.

I found a bug in Delphi 2009's implementation of TFields and wrote a quick patch. I copied DB.pas to my projects folder and added it to the project's file list, but now I can't get it to compile. The first two error messages don't even make any sense when I go to the indicated places in the code. Surely if anything can be counted on t...

Can I use a closure on an event handler (ie, TButton OnClick)

Hello, If I try to use a closure on an event handler the compiler complains with : Incompatible types: "method pointer and regular procedure" which I understand.. but is there a way to use a clouser on method pointers? and how to define if can? eg : Button1.Onclick = procedure( sender : tobject ) begin ... end; Thanks! ...

How do I override methods of nested types?

I've got a custom TObjectList descendant in Delphi 2009, and I'd like to play with its enumerator a bit and add some filtering functionality to the MoveNext method, to cause it to skip certain objects. MoveNext is called by DoMoveNext, which is a virtual method, so this shouldn't be difficult to override... except for one thing. The TEn...

How Can I Best Guess the Encoding when the BOM (Byte Order Mark) is Missing?

My program has to read files that use various encodings. They may be ANSI, UTF-8 or UTF-16 (big or little endian). When the BOM (Byte Order Mark) is there, I have no problem. I know if the file is UTF-8 or UTF-16 BE or LE. I wanted to assume when there was no BOM that the file was ANSI. But I have found that the files I am dealing wit...

How can I make Delphi 2009 open my application in the second monitor by default?

When debugging I always want Delphi to open my application in the second monitor but it always open in the first one, I know I can save the application placement before closing but I want it to always open in the second monitor when in debug mode. Is there some way to configure delphi 2009 to do that? ...

Is WideString identical to String in Delphi 2009

I'm getting some weird behaviour recompiling some applications in 2009 that used widestrings at various points. In a Delphi 2009 App is Widestring identical to String? ...

How does acrobat encode annotations added as sticky notes to pdfs?

We have been reading and writing Sticky Notes/Annotations/Comments to pdfs via an activex control in our application for a number of years. We have recently upgraded to Delphi2009 with Unicode Support. The following is causing problems. When we call CAcroPDAnnot.GetContents The results seem to be rather strange and we lose our Uni...

Is it possible to turn off Unicode support in RAD Studio 2009?

Hi guys, I have a little trouble with RAD Studio 2009. As you know, it is possible to switch Unicode support off in MSVS (right click on solution->properties->character set=not set). I need to find this feature in RAD Studio, I know it exists but do not know where exactly. It`s the only thing that stops my work on a Socket Chat universit...

Generics: What's a "CONSTRUCTOR constraint"?

I made a custom TObjectList descendant designed to hold subclasses of a base object class. It looks something like this: interface TMyDataList<T: TBaseDatafile> = class(TObjectList<TBaseDatafile>) public constructor Create; procedure upload(db: TDataSet); end; implementation constructor TMyDataList<T>.Create; beg...

How do I make a generic object list work from a specific base class?

TMyDataList<T: TBaseDatafile, constructor> = class(TObjectList<TBaseDatafile>) public constructor Create; procedure upload(db: TDataSet); end; I read in a blog post (I don't remember where now) that this is the way to declare a generic-based class with a specific base type for the generic object. And the compiler ...

Interesting stack overflow! compiler bug???

i wonder if i've found a compiler bug? i was removing some old code from my app and now i get stackoverflow at "begin" (see code & disassembly below). procedure TfraNewRTMDisplay.ShowMeasurement; var iDummy, iDummy2, iDummy3:integer; begin // STACK OVERFLOW BEFORE MY CODE STARTS iDummy:=0; iDummy2:=0; case iDummy2 of 1:...

Form designer inconsistent in control display style for updated project

I've got a project that I started in Turbo Delphi, which I recently updated to D2009, and I've noticed a bit of a quirk in the form designer. All the old forms have a Win98 style applied to them. The buttons are gray with sharp square edges, for example. But any new form I've created since the upgrade displays its controls in WinXP styl...

MD5 Hashing in Delphi 2009

In borland delphi 7 and even in delphi 2007 everything worked, but in delphi 2009 it just returns the wrong hash! I use wcrypt2 script (http://pastebin.com/m2f015cfd) Just have a look: string : "123456" hash: Delphi 7 : "e10adc3949ba59abbe56e057f20f883e" - real hash. Delphi 2007 : "e10adc3949ba59abbe56e057f20f883e" - real hash too....

Has anyone experience with porting a D2007 + TntControls application to D2009?

I have a rather large (freeware) project written with Delphi 2007 which is using both the TntUnicodeControls and the TntLXControls library and I'm planning to move to Delphi 2009. Unfortunatly I'm using those libraries everywhere in my project: Replacement for VCL controls to provide Unicode capability Win32 API wrappers (mostly for c...

Any information on a Turbo Delphi 2009 release?

Individually, the Turbo Delphi releases and the new improvements added in Delphi 2009 are two of the best things that have happened to Delphi in a long time. But currently you can only get one or the other. Does anyone know if Embarcadero has any plans to release a Turbo Delphi 2009? I'm a paying customer with my own copy of D2009, bu...

Finding System Fonts with Delphi

What is the best way to find all the system fonts a user has available so they can be displayed in a dropdown selection box? I would also like to distinguish between Unicode and non-Unicode fonts. I am using Delphi 2009 which is fully Unicode enabled, and would like a Delphi solution. ...

Delphi 2009 ShellTreeView/ShellListView Fix

When a Delphi 2009 project is closed with ShellTreeView/ShellListView on the mainform in the IDE Index out of bounds(0) exceptions are generated. Is there a fix for ShellTreeView/ShellListView so the exceptions can be eliminated? ...