Hi everyone
I have a form (MainForm) which calls a function in a unit I'm creating,
called DatabaseUtils. I want this unit to be able to have access to the
public variables etc. of the calling form, without needing to hardcode into
the DatabaseUtils unit, uses MainForm. Any form could have called
pass a Sender parameter
Regards
Paul McKenzie
Analyst Programmer
SMSS ltd.
- Original Message -
From: [EMAIL PROTECTED]
To: Multiple recipients of list delphi [EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 10:07 AM
Subject: [DUG]: How do I refer back to a calling form?
Hi
I have a form (MainForm) which calls a function in a unit I'm creating,
called DatabaseUtils. I want this unit to be able to have access to the
public variables etc. of the calling form, without needing to hardcode
into the DatabaseUtils unit, uses MainForm. Any form could have
called my new
Hi Paul
Yes I thought it was that basic, but it doesn't work for me. :-(
Some code snippets from MainForm.pas:
type
TMainForm = class(TForm)
UV: TUVObjects;
...
procedure TMainForm.UpdateWMS(PolNum: string);
...
NewCorrKey := WriteNewCorrRecord(Sender,CORR,CORI,PolNum); // this calls
Type sender as TMainForm(Sender).uv etc
Why not pass UV directly ?
Rob
Software engineer
Wild Software Ltd
Ph 03 377-0495
- Original Message -
From: [EMAIL PROTECTED]
To: Multiple recipients of list delphi [EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 10:38 AM
Subject: RE:
If you are doing this sort of thing - i.e. accessing objects contained in
the Form
Code from DatabaseUtils.pas:
function WriteNewCorrRecord(Sender: TObject; CORR, CORI: integer;
PolNum:
string): string;
begin
if Sender.UV.ReadRecord(CORI,PolNum) then...
Why not pass the object UV
further to what Rob said:
it is not clear from your main form code snippet what 'sender' is so try
something like:
NewCorrKey := WriteNewCorrRecord(Self.UV,CORR,CORI,PolNum); // this
calls DatabaseUtils.pas
Code from DatabaseUtils.pas:
function WriteNewCorrRecord(UV: TUVObjects;
Thanks everyone. I've worked with Robert's comments on avoiding tight
coupling and Paul's comments below, and changed my approach. I now only pass
PolNum and my datamodule gets its own UV object to work with (UV contains
all the procedures and methods for writing to our Universe database).
So now
Dave,
Robert Martin is right in that you probably shouldn't be doing this. If
DatabaseUtils accesses MainForm then it isn't really generic database
utilities at all. I think you should probably pass parameters you need, such
as UV, into the procedure instead.
To answer your question tho... there
Sounds good to me :)
Rob
Software engineer
Wild Software Ltd
Ph 03 377-0495
- Original Message -
From: [EMAIL PROTECTED]
To: Multiple recipients of list delphi [EMAIL PROTECTED]
Sent: Wednesday, February 26, 2003 11:40 AM
Subject: RE: [DUG]: How do I refer back to a calling form?
To answer your question tho... there isn't really any way that you can get
the code in DatabaseUtils.pas to directly access properties declared in
TMainForm without having MainForm.pas in your uses clause (which obviously
you don't want for generic database utilities). Having said that there are
[EMAIL PROTECTED] wrote:
Thanks everyone. I've worked with Robert's comments on avoiding tight
coupling and Paul's comments below, and changed my approach. I now only pass
PolNum and my datamodule gets its own UV object to work with (UV contains
all the procedures and methods for writing to our
Rohit Gupta asked:
I have a component descended from TCustomPanel. Its keydown
just does not see the arrow keys what gives. I have examined
other controls but can not figure out the missing magic.
The arrow keys are being eaten by the TCustomForm.CMDialogKey processing. If
you want to
Myles,
This is not quite correct?
Mmmm, maybe I am just being pedantic but further on my email did actually
mention that you could achieve this by using RTTI. However I don't think it
is a good solution as it is comparitively slow, bypasses the normal type
checking and is just generally messy.
Hi all just figured it out for myself:
RxTrayIcon1.Icon.Assign(RxTrayIcon1.icons[0]); //desired icon within []
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website:
Hello Matt,
Thanks! But of course it is always a better feeling to suss it out yourself.
MD RxTrayIcon1.Icon := RxTrayIcon1.Icons[ x ];
BTW appreciate comments from others on Q I asked before. Sorry I am not
contributing much knowledge in this group but over the last years my skills have
Hi all just figured it out for myself:
RxTrayIcon1.Icon.Assign(RxTrayIcon1.icons[0]); //desired icon within []
Just make sure you've already created and assigned an Icon to
RxTrayIcon1.Icon, otherwise the call to assign will fail. (I think :-)
Passing command line to the app is easy. But unfortunately there is a problem
that the form is not created yet, so you cannot pass parameters to the component
settings (my parameter contains a bunch of settings).
The obvious easy solution would be to start a timer in the program which fires a
You could intergegate the paramstr's in the dpr file before the
application.createform bit etc.
Jeremy
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Alistair George
Sent: Wednesday, 26 February 2003 19:19
To: Multiple recipients of list delphi
Subject:
Hi Alistair,
You are able to call paramstr() anywhere in your app so why not just use
it in the constructor or show event of your form?
HTH,
Chris
Alistair George wrote:
Passing command line to the app is easy. But unfortunately there is a problem
that the form is not created yet, so you
Hello Chris,
CM You are able to call paramstr() anywhere in your app so why not just use
CM it in the constructor or show event of your form?
CM HTH,
Realised that, but I think the SHOW event is actually before the form is shown.
Anyway, it doesnt work there!
Ta, Al+
21 matches
Mail list logo