delphi-2009

Faster DirectoryExists function?

Hi, I use DirectoryExists (const PathName : String); to check if a directory is reachable from a computer or not. But if the directory does not exist and the path name is a network path, i.e. \\computer1\Data the method takes a very long time to return. There must be a faster way to determine that a network folder is not reachabl...

How do I fix inconsistencies when converting file dates to/from TDateTime

I'm caching files locally in my 3 tier app. To check whether to read the file from the local cache or from the server I compare file dates. I've found that there when converting file dates to TDateTime and viceversa there are inconsistencies and values that should match rarely do. Here's some code that demostrates the problem procedure ...

How to make control invisible but responsive to mouse events?

I want to create a control (derived from TCustomControl) that is invisible but reacts to normal events (I want to use it to show a hint when moving the mouse over a custom element). I thought overriding the paint method and leaving it empty would do the job but unfortunately a rectangle is drawn where the component is. How can I make th...

app using TIdFTP not migrating from Delphi 5 to Delphi 2009...corrupt uploads

i wrote a Delphi 5 app that uses TIdFTP. it's been working great for years. it's only purpose is to upload an excel file. object ftp: TIdFTP OnStatus = ftpStatus IPVersion = Id_IPv4 AutoLogin = True Host = 'somewhere.ca' Passive = True Password = 'guess' TransferType = ftBinary Username = 'xray' ProxySettings.ProxyTy...

Migrate to Delphi 2009 - Invalid Typecast problem

I'm converting GraphicEx project to Delphi 2009. I have trouble in converting following procedure in unit Scanf_c.pas. Here is the problem: With TscRec(FType) do begin FType is an integer and TscRec is defined: TscRec = packed record // Has size of an integer Case byte of 0: ( Typ : byte; Size : char; Flags : word...

Delphi 2009 - Handle when window is restored via double clicking the SysMenu?

Hi, I need to handle when the user restores the form by double clicking the title bar. I tried handling the WM_SYSCOMMAND window message however this only works if the user restores the form via clicking the restore button in the system menu. I am using DevExpress ribbon form components if this matters. Thanks. ...

Cntl + z in delphi 4.0

Hi I am using Delphi 4 IDE. an major irritant is that i am unable to use "undo/ cntrl+z" more than twice. This is quite worriysome as i am wish to undo my changes as per need. Can one do more that 2-3 times of UNDO in Delphi 4.0? or am i missing something ? any solutions to this? thanks -Vas ...

Delphi 2009 IDE Structure View Collapse function...

Hi, Does anyone know now to collapse all items in Delphi 2009 IDE structure View? I have no idea to collapse all items and that make me hard to find my class from the view. Thanks Terrance ...

How to patch a method in Classes.pas

I need to patch a method in Classes.pas (TReader.ReadString - I want to force it to use a specified codepage, not the system default). If I copy Classes.pas into my project,I will end up having to rebuild the entire VCL. Is there any (easy) way to patch a method at runtime? ...

ZeroConf/Bonjour Code that works in Delphi 7 not working in 2009

I have the following declaration for DNSServiceRegister: function DNSServiceRegister ( var sdRef: TDNSServiceRef; const flags: TDNSServiceFlags; const interfaceIndex: uint32_t; const name: PUTF8String; //* may be NULL */ const regType: PUTF8String; const domain: PUTF8String;...

Conversion of Delphi code to Java

Does a parser exist for delphi which can be used to convert the delphi code into Java code automatically? Please Help!!! ...

Can I map Caps Lock to something useful for the Delphi IDE?

OK, so I know I can remap the Caps Lock key in Windows registry, but is there something useful I can map it to in the Delphi 2009 IDE? I was hoping for Code Completion (Ctrl-Space), is there a way to map the single Caps Lock key to a Ctrl-key combination? ...

TIdTCPServer not reading data from socket sometimes.

Hi I have the following code in the OnExecute of a TIdTCPServer (Delphi 2009 and Indy 10 that came with the installation) which is very similar to other examples on this site; Socket := AContext.Connection.Socket; if Socket.CheckForDataOnSource(10) then begin if not Socket.InputBufferIsEmpty then begin So...

Premature string destruction and how to avoid it?

Hi! I'm using Delphi 2009 and get some strange errors using the following code segment: var Str : AnsiString; CharPtr : PAnsiChar; ... CharPtr := PAnsiChar (Str); ExecuteInBackgroundThread ( procedure begin DoSomething (CharPtr); end); I'm guessing that the string is destructed when falling out of scope and under some ...

What errors / exceptions trigger Windows Error Reporting?

When running a Delphi application outside the debugger most exceptions that occur seem to be silently ignored (like an access violation). Sometimes however there appears the Windows error reporting dialog (send or not send, you probably know what I mean). What exactly does this mean? What errors trigger this behaviour? Additional info: ...

Indy, Send Thread and Destroyed Contexts

I use Indy's TIdTCPServer (D2009, Indy 10) to communicate with client applications. In the OnExecute method I create a task and queue it. A worker thread executes the task and puts it in the send queue. The send queue then sends the response to the client. In the send thread I loop through the server's context list and look for the cont...

convert function to delphi 2009/2010 (unicode)

I'm slowly converting my existing code into Delphi 2010 and read several of the articles on Embarcaedro web site as well as Marco Cantú whitepaper. There are still some things I haven't understood, so here are two functions to exemplify my question: function RemoveSpace(InStr: string): string; var Ans : string; I : Word; ...

Does it make more sense to upgrade to Delphi 2009/2010 or to buy Software Assurance?

If you've purchased the Software Assurance, can you please share your experience? Was it worthwhile? I vaguely remember reading some negative comments about SA maybe 1 or 2 years ago. ...

Any build-in Delphi function like PosEx that finds a sub-string starting from the back of the string?

Is there any Delphi D2010 function like PosEx that finds a sub-string inside a string starting from the end of the string? I'm removing all the calls to the FastStrings library and one of the functions I was using was FastPosBack: function FastPosBack(const aSourceString, aFindString : AnsiString; const aSourceLen, aFindLen, StartPos :...

When and Why Should I Use TStringBuilder?

I converted my program from Delphi 4 to Delphi 2009 a year ago, mainly to make the jump to Unicode, but also to gain the benefits of all those years of Delphi improvements. My code, of course, is therefore all legacy code. It uses short strings that have now conveniently all become long Unicode strings, and I've changed all the old ANSI...