Author Topic: Stupid Delphi stuff  (Read 10655 times)

0 Members and 1 Guest are viewing this topic.

drc

  • New Member
  • *
  • Posts: 7
  • Karma: +1/-0
Stupid Delphi stuff
« on: April 10, 2006, 08:09:40 PM »
This piece of code just doesn't work. Calling the procedure from another context works as intended.

Code: [Select]
program crc;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
  Form1.Show;
  Form1.CheckCrc();
end.

Code: [Select]
[...]

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
  public
    procedure CheckCrc();
  end;

[...]

procedure TForm1.CheckCrc();
var
 Buffer: Pointer;
 CRC, TotalB: LongInt;
 Error: Word;
begin
Form1.Label1.Caption := 'Processing...';
Application.ProcessMessages;
if (ParamCount()= 1) then
  begin
    GetMem(Buffer,4092);
    CalcFileCRC32(ParamStr(1),CRC,Buffer,4092,TotalB,Error);
    FreeMem(Buffer);
    Form1.Label1.Caption := 'Checking: ' + ParamStr(1);
    Form1.Label2.Caption := 'CRC: ' + IntToHex(CRC,8);
  end
else
  Form1.Label1.Caption := 'No Parameter given.';
end;

[...]

Could you give me a hint?

GTS

  • Administrator
  • Addicted
  • *****
  • Posts: 524
  • Karma: +2/-0
  • GTSdll Author
    • GTSdll Homepage
Re: Stupid Delphi stuff
« Reply #1 on: April 10, 2006, 08:12:17 PM »
The stuff you want to do has to be before Application.Run:

Code: [Select]
program crc;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Form1.Show;
  Form1.CheckCrc;
  Application.Run;
end.

:)
---> GTSdll Homepage <---

Rogue`

  • n00b
  • GTSdll Staff
  • Getting addicted
  • *****
  • Posts: 265
  • Karma: +0/-0
    • foobar2000
Re: Stupid Delphi stuff
« Reply #2 on: April 11, 2006, 07:24:36 AM »
Welcome to the forums drc  :wave: ^^

GTS

  • Administrator
  • Addicted
  • *****
  • Posts: 524
  • Karma: +2/-0
  • GTSdll Author
    • GTSdll Homepage
Re: Stupid Delphi stuff
« Reply #3 on: April 11, 2006, 12:46:55 PM »
 :D

he could post more ;)
---> GTSdll Homepage <---

chaosblade

  • Searching For My Truth
  • GTSdll Staff
  • Regular
  • *****
  • Posts: 231
  • Karma: +0/-0
  • Searching For My Truth
    • http://www.utorrent.com
Re: Stupid Delphi stuff
« Reply #4 on: April 14, 2006, 09:17:16 PM »
Yes, he could. :p

I am the bone of my sword. Steel is my body, and fire is my blood.
I have created over a thousand blades. Unknown to death, Nor known to life.
Have withstood pain to create many weapons, Yet those hands will never hold anything.



So as I pray... Unlimited Blade Works.