Solved

Access my own procedure

Posted on 2002-06-16
10
147 Views
Last Modified: 2010-04-04
In my component I have :

procedure TimerProc(uTimerID, uMessage: cardinal; dwUser, dw1, dw2: integer); stdcall;
begin
 CallMyProcedure;
end;

procedure TMyClass.CallMyProcedure;
begin
 DoSomething...
end;

How to do this call ?
I try with TMyClass(Self).CallMyProcedure but Self is unknown .
0
Comment
Question by:ginsonic
  • 5
  • 3
  • 2
10 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7083002
Hello
 
  Is there an instance of your class?
var
  MyClass : TMyClass;
begin
  MyClass := TMyClass.Create;
  MyClass.CallMyProcedure;
  MyClass.Free;
end;

Best regards
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7083030
or just do

  with TMyClass.Create do
    CallMyProcedure;
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 7083270
maybe you should transport your
object-pointer in the dwUser-flag
(if not needed for other things)

then it could show

procedure TimerProc(uTimerID, uMessage: cardinal; dwUser, dw1, dw2: integer); stdcall;
begin
TMyClass(Pointer(dwUser)).CallMyProcedure;
end;

meikl ;-)

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 9

Author Comment

by:ginsonic
ID: 7083481
That is it. Done now .
Thanks again,
Nick
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7083551
Ups, problems :(
How I know the next code is ok so the problem is from call ????

I try to add an event in my procedure but get an ugly error message alike access violation at ...

FOnDone : TNotifyEvent;
............
protected
procedure NowDone(Value: TNotifyEvent);
............
property OnDone: TNotifyEvent read FOnDone write NowDone;
............

procedure TMyClass.CallMyProcedure;
begin
 if Assigned(FOnDone) then FOnDone(Self); /// here is the problem .

end;

procedure TMyClass.NowDone(Value: TNotifyEvent);
begin
 FOnDone:=Value;
end;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7083556
I try with
property OnDone: TNotifyEvent read FOnDone write FOnDone;
same problem.
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7083575
procedure TimerProc(uTimerID, uMessage: cardinal; dwUser, dw1, dw2: integer); stdcall;
begin
   TMyClass(Pointer(dwUser)).Done;
end;

Think that here is the problem.

I test with

procedure TMyClass.Done;
begin
FD:=FDelay;
end;

Same problem.

For procedure TMyClass.Done;
begin
FD:=10;
end;

Is OK.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7083578
looks like ok,
closer look this evening
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7083583
?getting no notification from your last post
0
 
LVL 9

Author Comment

by:ginsonic
ID: 7083601
Is a server problem . No notifications for PAQ.
Hmm, what to do with my problem ?
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question