• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

Access my own procedure

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
ginsonic
Asked:
ginsonic
  • 5
  • 3
  • 2
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
Hello
 
  Is there an instance of your class?
var
  MyClass : TMyClass;
begin
  MyClass := TMyClass.Create;
  MyClass.CallMyProcedure;
  MyClass.Free;
end;

Best regards
0
 
Mohammed NasmanSoftware DeveloperCommented:
or just do

  with TMyClass.Create do
    CallMyProcedure;
0
 
kretzschmarCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ginsonicAuthor Commented:
That is it. Done now .
Thanks again,
Nick
0
 
ginsonicAuthor Commented:
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
 
ginsonicAuthor Commented:
I try with
property OnDone: TNotifyEvent read FOnDone write FOnDone;
same problem.
0
 
ginsonicAuthor Commented:
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
 
kretzschmarCommented:
looks like ok,
closer look this evening
0
 
kretzschmarCommented:
?getting no notification from your last post
0
 
ginsonicAuthor Commented:
Is a server problem . No notifications for PAQ.
Hmm, what to do with my problem ?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now