unit fmDemoMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

const
  MY_BASE                   = $BD00;
  DELPHIMSG                 = MY_BASE + 1;
  CBUILDERMSG               = MY_BASE + 2;
  SIDEWINDERMSG             = MY_BASE + 3;
  JBUILDERMSG               = MY_BASE + 4;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Panel1: TPanel;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure RunCommandLine(const sProduct : String);
    procedure AppMsg(const sStr : String);
    procedure DelphiHandler(var Message: TMessage); message DELPHIMSG;
    procedure CBuilderHandler(var Message: TMessage); message CBUILDERMSG;
    procedure SideWinderHandler(var Message: TMessage); message SIDEWINDERMSG;
    procedure JBuilderHandler(var Message: TMessage); message JBUILDERMSG;
  end;

  TDMethod = procedure of object;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AppMsg(const sStr: String);
begin
  Memo1.Lines.Add(sStr);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RunCommandLine(Edit1.Text);
end;

procedure TForm1.CBuilderHandler(var Message: TMessage);
begin
  AppMsg('Borland将推出新一代的C/C++开发工具!');
end;

procedure TForm1.DelphiHandler(var Message: TMessage);
begin
  AppMsg('Delphi 8在2003年底将推出!');
end;

procedure TForm1.JBuilderHandler(var Message: TMessage);
begin
  AppMsg('JBuilder 9是最新的Java IDE!');
end;

procedure TForm1.RunCommandLine(const sProduct : String);
var
  aMessage : TMessage;
begin
  if (UpperCase(sProduct) = 'DELPHI') then
    aMessage.Msg := DELPHIMSG
  else
    if (UpperCase(sProduct) = 'CBUILDER') then
      aMessage.Msg := CBUILDERMSG
    else
      if (UpperCase(sProduct) = 'SIDEWINDER') then
        aMessage.Msg := SIDEWINDERMSG
      else
        if (UpperCase(sProduct) = 'JBUILDER') then
          aMessage.Msg := JBUILDERMSG;

    SendMessage(Self.Handle, aMessage.Msg, 0, 0);
end;

procedure TForm1.SideWinderHandler(var Message: TMessage);
begin
  AppMsg('Borland在.NET下的最新开发工具!');
end;

end.
