Board index » delphi » Newbie question - sender and postscript

Newbie question - sender and postscript

Hello,

I'm having trouble using the Sender variable. In a procedure 'B' a want to
see if another procedure 'A' called it. I thought it could be done by:

if Sender=B then....

but it doesn't work. Isn't a procedure an object?

Another question. Does anybody know if there is some freeware that I can use
in Delphi 4 to preview a Postscript file?

Thanks in advance,

Dennis

 

Re:Newbie question - sender and postscript


You MUST define an interface to your procedures.  Each procedure must have
EXCATLY the same interface.  Once you've done that you can then proceed to
assign pointers to these procedures.  What's nice about this is it allows
you to define two different procedures in two units and then use pointers to
pass them between classes.  This makes it possible for two units to use each
other without delcaring the other it it's USES clauses.

Rough Example:

Type

TChildFormCallBack = Procedure(MyMessage,MyData: String;MyPointer: Pointer)
of Object;

.
.
.
Class
.
.
  Procedure ChildFormCallBack1(MyMessage,MyData: String;MyPointer: Pointer);
 .
.
.
Class2
   Procedure ChildFormCallBack2(MyMessage,MyData: String;MyPointer:
Pointer);

Class3

  MyPointerToProcedure1 : TChildFormCallBack ;
  MyPointerToProcedure2 : TChildFormCallBack ;

.
.
.
Somewhere in your code..

// This is legal and works just dandy!

MyPointerToProcedure1 := Class.ChildFormCallback1;
MyPointerToProcedure2 := MyPointerToProcedure1;

Result := MyPointerToProcedure2('Hello World','User1',Nil);

Den the Man <nos...@spam.com> wrote in message
news:7sv6fd$2gf$1@news.tudelft.nl...

Quote
> Hello,

> I'm having trouble using the Sender variable. In a procedure 'B' a want to
> see if another procedure 'A' called it. I thought it could be done by:

> if Sender=B then....

> but it doesn't work. Isn't a procedure an object?

> Another question. Does anybody know if there is some freeware that I can
use
> in Delphi 4 to preview a Postscript file?

> Thanks in advance,

> Dennis

Re:Newbie question - sender and postscript


Hello...

No, the Sender variable are only used in event-handlers to find out witch
object had activated that event.

For Example :

Let's say your writing a calculator application, where's there 10 (0..9)
buttons; exept writing a event for etch button, you can write one
event-handler that all the button's can respond to. You can use the "Tag"
property of all the button's to know witch button is witch.

{Buttons event-handler}

begin
  case (TButton(Sender).Tag) of
    0 : ......
    1 : ......
    2 : ......
    .
    .
end;

In this code you know that it's a button (TButton) object, but the Sender
variable knows witch one of the button's it is (Button1, Button2, etc).

Regards,

Lennie De Villiers

Quote
Den the Man wrote in message <7sv6fd$2g...@news.tudelft.nl>...

|Hello,
|
|I'm having trouble using the Sender variable. In a procedure 'B' a want to
|see if another procedure 'A' called it. I thought it could be done by:
|
|if Sender=B then....
|
|but it doesn't work. Isn't a procedure an object?
|
|Another question. Does anybody know if there is some freeware that I can
use
|in Delphi 4 to preview a Postscript file?
|
|Thanks in advance,
|
|Dennis
|
|

Other Threads