Classes / Forms re-use
From: Ryan (ryanofford_at_hotmail.com)
Date: 01/25/05
- Next message: Maarten Wiltink: "Re: Converting a userspecific VCL-component to an ActiveX-control"
- Previous message: Hellricky1: "Help About wmsdk 9.5"
- Next in thread: Maarten Wiltink: "Re: Classes / Forms re-use"
- Reply: Maarten Wiltink: "Re: Classes / Forms re-use"
- Reply: VBDis: "Re: Classes / Forms re-use"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Jan 2005 03:20:35 -0800
I'm having a play with creating classes in Delphi (5). I've managed to
create the class which works almost as expected (code below - will name
things better if I use this properly).
I can call the class and get the form to display, but...
How do I add the class without having to add the original form to my
project ?
Basically, I want to store this form somewhere and call the class from
it, but I don't want to see the form itself. I just need to use the
various methods and properties as you would expect. In the main
application code it shows : Email in '..\CBFA\Email.pas' {frmEmail};
And I have the form name in the Project Manager, but if I remove it
from the Project Manager, I can't create the class. I'm close, but not
there yet. What am I missing ?
Thanks in advance.
//Class Code
unit Email;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
lmdcctrl, lmdctrl, lmdeditb, lmdeditc, lmdbredt, StdCtrls, wwdblook,
Buttons, ExtCtrls, lmdextcS, msmsg, Mssocket, msSmtp;
type
TfrmEmail = class; // Forward type declaration
// New class for defining emails
TCBFAEmail = class(TObject)
private
strInitialRecipient : string;
strSubject : string;
strFrom : string;
strMsgBody : string;
protected
public
constructor Create(strRec, strFrm, strSub, strMsg : string);
published
property InitialRecipient : string read strInitialRecipient;
property Subject : string read strSubject;
property From : string read strFrom;
property MsgBody : string read strMsgBody;
end;
TfrmEmail = class(TForm)
filBackground: TLMDFill;
imgLogo: TImage;
lblTitle: TLabel;
lblRecipients: TLabel;
lblFrom: TLabel;
lblSubject: TLabel;
lblAttachment: TLabel;
lblRecipCount: TLabel;
lblAttachCount: TLabel;
btnSend: TBitBtn;
btnCancel: TBitBtn;
btnAdd: TButton;
memDetail: TMemo;
edtFrom: TEdit;
edtSubject: TEdit;
cmbAttachments: TLMDFileOpenEdit;
cmbRecipients: TwwDBLookupCombo;
msSMTP: TmsSMTPClient;
msMessage: TmsMessage;
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmEmail: TfrmEmail;
implementation
{$R *.DFM}
constructor TCBFAEmail.Create(strRec, strFrm, strSub, strMsg : string);
begin
// Numpty stuff just to test it works.
strSubject := strSub;
strInitialRecipient := strRec;
strFrom := strFrm;
strMsgBody := strMsg;
MessageDlg(strSubject, mtInformation, [mbOK], 0);
MessageDlg(strInitialRecipient, mtInformation, [mbOK], 0);
MessageDlg(strFrom, mtInformation, [mbOK], 0);
MessageDlg(strMsgBody, mtInformation, [mbOK], 0);
frmEmail.ShowModal;
end;
end.
// This is where I need the guidance I think.
// Main application which will use the class has :
procedure TfrmMain.btnWRAcknowledgeClick(Sender: TObject);
var
myEmail : TCBFAEmail;
begin
myEmail := TCBFAEmail.Create('Recipient', 'From', 'Subject',
'Hello');
myEmail.Free;
end;
- Next message: Maarten Wiltink: "Re: Converting a userspecific VCL-component to an ActiveX-control"
- Previous message: Hellricky1: "Help About wmsdk 9.5"
- Next in thread: Maarten Wiltink: "Re: Classes / Forms re-use"
- Reply: Maarten Wiltink: "Re: Classes / Forms re-use"
- Reply: VBDis: "Re: Classes / Forms re-use"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]