Monday, September 15, 2008

Delphi 2009 Generics

In order to use TList TStack, you need to add "generics.collections" into the uses list. For example,

uses generics.collections;

Monday, June 2, 2008

How To Pass A Class Into Function/Procedure?

define the class type as follow... assuming that you are going to pass in a generic TFrame.

type TFrameClass=class of TFrame;

procedure TForm1.CreateSomething(FrameClass: TFrameClass; const Caption: String);
var
F: TFrame;
begin
F := FrameClass.Create(Self);
F.Label1.Caption := Caption;
end;

...
...

begin
CreateSomething(TMyFrame, 'Test);
end.

Sunday, February 24, 2008

How To Open MS Access database in CGI?

I have encountered a problem to open MS Access database from Delphi executable CGI. I always end up with the error "Unspecified error". I figured it out that it must be security issue. MS Access will create a temporary file whenever it is opened. The question is where? After surfing the internet, I found that the temporary file would be created in %temp% folder. But under which profile? After some trial and error, my executable CGI worked after I have granted folder "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp" with full control right to "IUSR".

MS Access ADO Connection String

Use the syntax below to connect to MS Access database without maintaining DNS (ODBC)

ADOConnection.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + MDBFileName;

How to run Executable CGI in IIS7.0 (Vista)

Step 1. Go to Control Panel and click on Programs
Step 2. Choose "Turn Windows Features On or Off"
Step 3. Check World Wide Web Services and CGI

Step 4. Go to Administrative Tools and open up IIS Manager.
Step 5. Add a virtual application folder, name it "CGI" or "CGI-BIN".
Step 6. Point to the Root Item (your PC name) and choose "ISAPI and CGI Restriction".
Step 7. Click Edit Feature Settings and check "Allow unspecified CGI modules".
Step 8. Click the "CGI" or "CGI-BIN" folder and choose "Handler Mappings".
Step 9. Click "Edit Handler Permission", uncheck "Read" and check "Execute".
Step 10. Double click on "cgi-exe" to change the property if necessary. Example, change request path to *.cgi (from *.exe) if your cgi extension is .cgi instead of .exe.

Tuesday, December 18, 2007

Format, String.Format and StringBuilder.AppendFormat

Format is Delphi's C-like format function. For example, Format('%s = %d',[MyString, MyInteger]).

String.Format and StringBuilder.AppendFormat are using FCL formatting. For example, String.Format('{0} = {1}', [MyString, MyInteger]).

Refer to http://msdn2.microsoft.com/en-us/library/hdekwk0b.aspx for further FCL Format information.

Monday, December 17, 2007

How to enable Glass Effect in Delphi 2007 for .Net (and Win32)

You will see the glass effect in Vista with Aero only. It appears to be a normal form if your OS does not support Aero.

Set the properties of the form as follow.



Then, write the following codes in OnCreate of the form.

And, tada.... here is the output.