dingcheng
asked on
Can Console applications use VCL?
In the console applications , can I still use VCL such as NMSMTP and NMPOP3?
Floris is right, but you have to create an instance of the component yourself (normally this is done by dropping the component on your form). Something like this:
NMSMTP1 := TNMSMTP.Create(...);
Now you can use it.
Regards, Madshi.
NMSMTP1 := TNMSMTP.Create(...);
Now you can use it.
Regards, Madshi.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Datamodule = unneccesairy overhead I expect.
Madshi is right too. To make it complete: use it like the tstringlist example in the Delphi help; with a free...:-)
procedure TForm1.FormCreate(Sender: TObject);
var
MyList: TStringList;
Index: Integer;
begin
MyList := TStringList.Create;
try
MyList.Add('Animals');
MyList.Add('Flowers');
MyList.Add('Cars');
MyList.Sort; { Find will only work on sorted lists! }
if MyList.Find('Flowers', Index) then
begin
ListBox1.Items.AddStrings( MyList);
Label1.Caption := 'Flowers has an index value of ' + IntToStr(Index);
end;
finally
MyList.Free;
end;
end;
Madshi is right too. To make it complete: use it like the tstringlist example in the Delphi help; with a free...:-)
procedure TForm1.FormCreate(Sender: TObject);
var
MyList: TStringList;
Index: Integer;
begin
MyList := TStringList.Create;
try
MyList.Add('Animals');
MyList.Add('Flowers');
MyList.Add('Cars');
MyList.Sort; { Find will only work on sorted lists! }
if MyList.Find('Flowers', Index) then
begin
ListBox1.Items.AddStrings(
Label1.Caption := 'Flowers has an index value of ' + IntToStr(Index);
end;
finally
MyList.Free;
end;
end;
Hi Flor,
Datamodules, haven a specific function. If you have many components and/or properties to set. If you want modularity over OOP concepts, this is the right way.
I my use, I prefer manualy create the instances and change the properties values. But when doing a WEB app is inevitabily the use of Datamodules.
T++, Radler.
Datamodules, haven a specific function. If you have many components and/or properties to set. If you want modularity over OOP concepts, this is the right way.
I my use, I prefer manualy create the instances and change the properties values. But when doing a WEB app is inevitabily the use of Datamodules.
T++, Radler.
After including Psock and NMsmtp to your uses list, you can add a var:
NMSMTP1: TNMSMTP;
It will work the same as if you dropped the component on the form.
Floris.