Saturday, May 9, 2009

Execute a Delphi Method (Procedure/Function) by Name

When you need to convert an integer to a string, you would use the IntToStr Delphi function. When you need to display a form modally you would use the ShowModal method of a form object.

In short, functions, procedures and methods are called by their name. Ok, I know you knew that.

What if you need to call a function by its name as a string variable value? What if you need to use a code like:

ExecMethod(Form1, 'ShowModal');



type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject) ;
procedure CallMeByName(Sender: TObject) ;
private
procedure ExecMethod(OnObject: TObject; MethodName: string) ;
end;

var
Form1: TForm1;

type
TExec = procedure of object;

procedure TForm1.ExecMethod(OnObject: TObject; MethodName: string) ;
var
Routine: TMethod;
Exec: TExec;
begin
Routine.Data := Pointer(OnObject) ;
Routine.Code := OnObject.MethodAddress(MethodName) ;
if NOT Assigned(Routine.Code) then Exit;
Exec := TExec(Routine) ;
Exec;
end;

procedure TForm1.CallMeByName(Sender: TObject) ;
begin
ShowMessage('Hello Delphi!') ;
end;

procedure TForm1.Button1Click(Sender: TObject) ;
begin
ExecMethod(Form1, 'CallMeByName') ;
end;

Friday, May 8, 2009

How to Remove the "Today" Mark from the TDateTimePicker

The TDateTimePicker component displays a list box for entering dates or times. By design it displays the label "today" at the bottom of the control allowing a user to quickly select the today's date.

Here's how to remove the "today" marker from the TDateTimePicker. Handle the OnDropDown event as:

uses CommCtrl, ...

procedure TForm1.DateTimePicker1DropDown(Sender: TObject) ;
var
wnd: HWND;
style: Integer;
begin
wnd := DateTime_GetMonthCal(DateTimePicker1.Handle) ;
if wnd <> 0 then
begin
style := GetWindowLong(wnd, GWL_STYLE) ;
SetWindowLong(wnd, GWL_STYLE, style or MCS_NOTODAY or MCS_NOTODAYCIRCLE) ;
end;
end;

Finalizing DelphiLive Material

Well today I am putting the finishing touches on my DelphiLive presentations.

I will be presenting:
  • Power of the RTTI In Delphi
  • Moving from BDE to DBX

I have this love hate relationship with PowerPoint, sometimes I find its the best way to communication information. However as soon as things get technical I really dislike seeing a bunch of code on slides.

In My Power of the RTTI in Delphi Session I currently I have grand total of 3 Slides for this presentation the rest is code.

I will be covering:

  • Interacting with Published Information
  • Dynamic Method Invocation
  • Dynamic Class Creation
  • Ideas on how you might use it your applications.

In My BDE to DBX Session, I have several slides, but don't worry I have plenty of code and examples to show.

One of the things I like the best about this presentation won't come till near the end, but at the State of Utah we wrote a simple DFM parser and combined it with Martin Waldenburg Delphi Parser (TmwPasLex) and wrote a simple but effective conversion utility. It saved us tons of time when converting a BDE Application to DBX. The application we converted was not a simple demo program, It has 650+ DFMs. And several more units 500+ with no associated dfm. That does not count any third party code, or our own internally developed components.

I have updated the conversion utility to be slightly more generic as the original was specific to our needs. I will share that code with the attendees.

I hope to see you there!

Thursday, May 7, 2009

UK firm splashes out to buy Borland and Compuware

One of the grandees of the IT industry for the past 30 years, Borland Software, has been acquired by British software company Micro Focus International, in a cash deal worth £50 million ($75 million).

At the same time, Micro Focus said it is also acquiring the application testing and automated software quality business of Compuware Corporation for £53 million ($80 million).

Micro Focus said the two deals would give it a leading market position in the testing and automation market.

Borland was founded way back in 1981 by three Danish citizens, but soon moved to the United States where it was headed up by the flamboyant Philippe Kahn, who led the company for most of the 1980s and 1990s.

Borland developed a series of well-regarded software development tools during its existence, and is probably most associated with Turbo Pascal, Quattro Pro (spreadsheet), and Paradox (database). The company was also known for acquiring Ashton-Tate back in September 1991, a deal that netted it the dBase and InterBase databases, and for a time Borland was counted as a serious rival to both Microsoft and Oracle.

But it soon found itself squeezed by its rivals and in 1998, Borland changed its name to Inprise Corporation in an effort to appeal to the enterprise applications development market. The idea was to integrate Borland's tools, Delphi, C++ Builder, and JBuilder with enterprise environment software. But the move backfired, and in January 2001, the Inprise name was abandoned and the company reverted to the "Borland" name once more.

In February 2006 Borland announced the divestiture of its IDE division, including Delphi, JBuilder, and InterBase. At the same time it announced the planned acquisition of Segue Software, a maker of software test and quality tools. The spinoff was called CodeGear.

From 2007, Borland concentrated on Application Lifecycle Management (ALM) and in May 2008 it sold its CodeGear division to Embarcadero Technologies.

The deal to acquire Borland means that Micro Focus will expand its presence in the application testing market, where it already operates with its Data Express product.

"Micro Focus's proposed acquisition of Borland represents the next logical stage in Micro Focus's growth journey," said Stephen Kelly, CEO of Micro Focus, in a statement. "Our organic performance remains strong as reflected in our trading statement also released today, and this transaction will add new scale and breadth to further develop our customer proposition, in an attractive adjacent market to our existing business."

Newbury, Berkshire-based Micro Focus was founded back in the 1970s and is best known as a software provider that helps companies move older legacy software to more modern business systems.

The UK company is also acquiring the application testing and automated software quality business of Compuware for $80 million, again also in cash. Compuware made its name in the testing, development and management software for programs running on mainframe computer and client-server systems.

Micro Focus feels its products are "highly complementary to Micro Focus' core solutions as they address a logically adjacent portion of the software development and deployment value chain."

"Acquiring the Compuware Testing and ASQ business is a logical extension to our existing application management proposition, and we see strong growth potential in this market," said Kelly.

Both deals have been approved by the relevant boards, but still need shareholder and regulator approval. Micro Focus also said its group revenues for 2009 were expected to grow year on year by approximately 20 percent.

Silverpoint MultiInstaller

Silverpoint MultiInstaller is a multi component package installer for CodeGear Delphi and C++Builder, it was created to ease the components installation on the IDE.

Silverpoint MultiInstaller can help you install multiple component packs in a few clicks.
Just download the zips and select the destination folder, all the components will be uninstalled from the IDE if they were previously installed, unziped, patched, compiled and installed on the Delphi IDE.

Getting Started
To install a component pack with MultiInstaller you have to follow these steps:
1) Read the licenses of the component packs you want to install.
2) Get the zip files of component packs.
3) Get the Silverpoint MultiInstaller.
4) Get the Setup.ini file for that component pack installation or create one.