I would use a message as a preferred choice.
However, there is a mor ebasic method. In the initialization code of FormA,
you initialize a variable of type Form in FormX.
Then FormX looks at this form variable to see if its houdl update that form.
You can go further by making the variable of type TWInControl and write the
forma.label into it.
----- Original Message -----
From: "Mike Osborne" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Tuesday, 24 April 2001 12:33
Subject: Re: [DUG]: Basic OO/Delphi Question
> Thanks but this is a level above what I'm looking for.
>
> I'm trying to communicate between two forms in the same program but do it
in
> a generic way so that I can re-use one form in many
> projects without having to use conditional directives to explicitly state
> the name of the other forms.
>
> Less theoretically - I have a form that allows a user to write comments
> about some entered data.
>
> I want to use that same form in a data entry program (they can enter
> comments as they enter data) and in a reporting/summary view
> program (they can add the comments later) and maybe other views later. In
> each program I want to show on the entry form or the summary form an
> indicator to show that comments exist for this data item. The existence
> depends on whether the user adds or deletes
> comments in the comments form.
>
> I can set a boolean property on the comments form HasComments := True or
> HasComments := False.
>
> How do I get the entry or summary form to immediately recognise that the
> property on the comments form has changed? Can I create an event on the
> comments form - like OnCommentsChange - and have the entry and summary
forms
> respond to that event? If so, how do I do that?
>
>
>
>
> ----- Original Message -----
> From: "James Low" <[EMAIL PROTECTED]>
> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
> Sent: Tuesday, April 24, 2001 12:21 PM
> Subject: RE: [DUG]: Basic OO/Delphi Question
>
>
> > Have a look at this ... communicating with messages. There may be more
> > elgant solutions, but if you "own" both applications (ie other programs
> > don't need to query interfaces etc) this is probably the best way to
deal
> > with interprogram (same machine) coms.
> >
> > Check out the TMessage type and be careful with your use of the Windows
> > constants ... but otherwise messaging between two programs can be pretty
> > straightforward.
> >
> > RECEIVING PROGRAM
> >
> > unit Unit1;
> > interface
> > uses
> > SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
> > Forms, Dialogs, StdCtrls;
> > type
> > TForm1 = class(TForm)
> > Label1: TLabel;
> > private
> > procedure WMDEBUG(var Msg:TMessage); message WM_USER+2000;
> > public
> > end;
> > var
> > Form1: TForm1;
> > implementation
> > {$R *.DFM}
> > procedure TForm1.WMDEBUG(var Msg:TMessage);
> > begin
> > label1.Caption := 'Received '+PString(Msg.lParam)^;
> > end;
> > end.
> >
> >
> > SENDING program:
> >
> > uses WinCrt,WinTypes,Messages,WinProcs;
> > var
> > S : String;
> > begin
> > repeat
> > Readln(S);
> > SendMessage(HWND_BROADCAST,WM_USER+2000,0,Longint(@S));
> > until S='';
> > end.
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: 24 April 2001 11:46
> > To: Multiple recipients of list delphi
> > Subject: Re:[DUG]: Basic OO/Delphi Question
> >
> >
> > I may have the wrong end of the stick, as I am not totally sure what you
> are
> > after, but...
> >
> > If FormX does not have the lable or caption, you cannot write code (in
> > FormX) to
> > modify the lable or caption that it does not know about.
> >
> > Regarding the setting / Getting of a Property - you can write access
> methods
> > for
> > Properties, which if desired, you can override in descendant Forms. That
> > should
> > produce the desired effect.
> >
> >
> >
> > Regards
> > Paul McKenzie
> >
> > =========================
> > Paul McKenzie
> > Jetbet II Developer
> > =========================
> > [EMAIL PROTECTED]
> > Ph: (04) 576-6822
> >
> > T.A.B. National Office
> > 106-110 Jackson Street
> > Petone
> > New Zealand
> >
> >
> >
> > ____________________Reply Separator____________________
> > Subject: [DUG]: Basic OO/Delphi Question
> > Author: [EMAIL PROTECTED]
> > Date: 24/04/2001 11:32
> >
> >
> >
> > I have a form FormX that I want to use in a number of projects.
> >
> > In, say, Project A I have a form FormA with a label and caption.
> > When a change is made to some list or variable on FormX I want to
> > modify
> > the
> > FormA.label.caption
> >
> > I don't want to do this by writing FormA.label.caption := 'Foo'; in
> my
> > FormX
> > unit
> >
> > because that won't work when I want to do a similar thing from
FormX
> to
> > FormB in ProjectB.
> >
> > I know that being able to do this is the benefit of OO but I'm
stuck
> in
> > my
> > procedural mindset.
> >
> > I can make the value I change a property of FormX - but how does
> FormA
> > or
> > FormB know the property has changed?
> >
> > I'm sure it's simple - just can't see it.
> >
> > Ideas please.
> >
> > TIA
> > Mike
> >
> >
>
> --------------------------------------------------------------------------
> -
> > New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"(See attached file: att1.eml)
> >
>
> --------------------------------------------------------------------------
> -
> > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> >
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"