I have a thread and a Progress Routine (a function) inside it (in my thread class).
I try to do this inside the thread:
CopyFileEx(pchar(ListToCopy.Strings[Loop]),pchar(TN+ExtractFileName(ListToCopy.Strings[Loop])), @ProgressRoutine, nil, nil, 0);
But I get an error: “Variable required” (the error is in this: @ProgressRoutine). If to make the function ProgressRoutine outside the thread then all will be normal.
How to use that function inside thread?
Thanks.
When you say “outside the thread” and “inside the thread”, do you mean “as a standalone function” and “as a member of the thread object”? Because if a function is a member of an object, its signature is different, so it doesn’t match what the compiler is expecting.
The way you can resolve this is to pass
SelftoCopyFileExas thelpDataparameter. This gives it a pointer that it will pass back to the callback. Write your callback as a standalone function that interprets thelpDataparameter as a thread object reference and uses that to call the method on your thread object with the same parameters.EDIT: Simple example. Let’s say that the callback only has two parameters, called “value” and “lpData”: