delphi-2009

How to start building a searchable garbage collector in Delphi (2009-2010)

I'm looking for a way to control all business objects I create in my applications written in Delphi. As an article on Embarcadero's EDN (http://edn.embarcadero.com/article/28217) states, there are basically three ways to do this. I'm mostly interested in the last one, using interfaces. That way, when the business object is no longer bei...

Does Delphi handle format string parameters automatically if different string encodings are used?

In other words: Does this work, i.e. is the encoding of the parameter taken into account when generating the unicode string result? function Test: string; var Pattern: string; Parameter: UTF8String; begin // ... Result := Format(Pattern, [Parameter]); end; Or is it necessary to explicitly cast the parameters? Result := Format...

How to achieve smaller size of the executable?

Hello everyone! Very recently I have come back to Delphi after a long pause and written a rather straightforward utility app my client requested to support an older release... I know these days the size does not matter much, but it struck me as odd that the one-unit application, when compiled, amounted to 1'084'416 b executable. The on...

How to escape special characters in SQL strings from Delphi?

Hi, How to escape the special characters when executing an SQL query, when it is executed from Delphi using TADOQuery or TADOCommand etc.. For example the "scope operator". Query looks like this. GRANT CONTROL ON SCHEMA :: dbo TO supervisor Thanks & Regards, Pavan. ...

How do I run all projects in a project group?

Hello, I have a project group containing two projects that share one source folder,but do different things.What I find strange is the use of 'project group',but I don't want to turn this a subjective question,thereby I directly ask you: How do I run all the projects in a project group - is there a short way? Thank you in advance! ...

How can I check whether an object reference is still valid?

I have an issues where I am trying to determine if a reference to an object is valid. But it seems to be returning strange results. procedure TForm1.Button1Click(Sender: TObject); var form1 : TForm; ref2 : TControl; begin form1 := TForm.Create(nil); form1.Name := 'CustomForm'; form1.Parent := self; //Main Form form1.Sh...

Application.Restore does not get me to where I was before, why?

Hello there, The application I am now trying to support (a former creation of mine) is a complete mess, and so I programmed an extension to it as a separate executable which I then launch, call application.minimize; and WaitForSingleObject (the recently created process). Right after that I call application.restore to get me back to wher...

How do I get a remote SQLConnection for TDSProviderConnection.SQLConnection?

With DataSnap 2009 i seems to be possible to use a remote database connection in the client datamodule, using a TDSProviderConection and an associated TSQLConnection. The client side is easy to set up, I drop a TSQLConnection on the form and link it to the TDSProviderConnection component. But what are the steps in the remote datamodule ...

Call UPS Parcel Tracking Web Service with Delphi?

Delphi 2009 imported the UPS WSDL without any errors, and I managed to invoke the web service with my account information and an example parcel ID. The response from the server is: <detail> <err:Errors xmlns:err="http://www.ups.com/XMLSchema/XOLTWS/Error/v1.1"&gt; <err:ErrorDetail> <err:Severity>Hard</err:Severity> <er...

Why do interface implementations based on TComponent leak memory?

This Delphi code will show a memory leak for an instance of TMyImplementation: program LeakTest; uses Classes; type MyInterface = interface end; TMyImplementation = class(TComponent, MyInterface) end; TMyContainer = class(TObject) private FInt: MyInterface; public property Impl: MyInterface read FInt write FI...

How to identify unicode keys on key press?

Hi, My application uses unicode characters and i have several text fields where i want to restrict user from inputing special characters like :'"; begin if not (Key in ['a'..'z','A'..'Z',' ','0'..'9',#13,#8]) then Key := #0; if Key = #13 then bOk.Click; end; So at this point it lets user add spaces and use a b...

External Exception EEFFACE in Delphi

While debugging my application with Delphi 2009, I sometimes get the following exception occurring: This only happens occasionally, but after pressing OK, then my IDE and program both may freeze. If I am lucky I can sometimes do a File/SaveAll in Delphi, but sometimes I can't. Either way I am stuck and then the only thing I can do is ...

How to make a controll stick to its parent borders on resize?

Hi, I have a TGroupBox as a parent and i want to place a button inside it, and make it so the button would stick to the top right corner of groupbox. The problem is, TGroupBox does not have the method OnResize, so i don't know how to tell a button where should it move after groupbox was resized. Is there any way to make it happen? T...

ActiveX control not processing arrow keys correctly when hosted in Delphi application

I have an ActiveX control hosted in our application. The control was imported using Delphi Import component menu. The ActiveX control contains an edit box for user input. When I run the control in its own sandbox application(not a Delphi app) the arrow keys work as expected moving the cursor within the edit control. However when I run...

Why can't I register this method with the PascalScript compiler?

My question is below. Here is my setup: interface uses windows, {...,} uPSComponent_Default, uPSComponent, uPSRuntime, uPSComponent_Controls; TForm1 = class(TForm) //... PSScript1: TPSScript; PSImport_Classes1: TPSImport_Classes; PSImport_Controls1: TPSImport_Controls; procedure PSScript1Compile(Sender: TPSSc...

Delphi 2009 - Detect if component installed

Hi there, I got some code that I share with another developer. I have a nice debugging module which I leave through out the unit tests but he doesn't have this, so it's a battle of adding and remove the code constantly. Would be nice if there was a way we could use a condition (much like Delphi version or Unicode) like {$IfDef MYCom...

How to extend the parameter list of a method (ie OnClick) and use it?

Hi, I'm developing the app which has input fields and whenever user enters the controll, extra panel is being generated with the buttons. The buttons have captions representing special symbols like degree, greek symbols. When the button is pressed, corresponding special character should be added to the input fields TEdit existing text...

Changing editor fonts in RAD Studio 2009

I can change the editor font in RAD Studio 2009 under the [Tools][Options] Editor Options/Display settings form, but the list of fonts is very limited and does not show all the installed fonts. Is there any way to add fonts to the selection ? There is a work around by setting the font name in the registry, under [HKEY_CURRENT_USER\Softw...

Delphi 2009 button.enabled shows error in structure but still compiles

I'm just wondering if anyone else has come across this rather obtuse error. I have a procedure that looks loosely like this: procedure dostuff(); begin if session_started = true then // global var begin // do bunch of calculations // goes on for a while // then at the end we enable the save button save_score.enabled := ...

Why does MSHTML_TLB.pas produce warnings?

I am trying to get rid of lots of warnings in a project after converting it from BDS 2006 to Delphi 2009. The project needs a type library named MSHTML_TLB. The source file mshtml_tlb.pas is an incredibly large file (about 16MB and >440.000 lines of code) which is generated when the Type Library is imported into Delphi 2009. This f...