How to compare value a variable containing a pointer to a function with the address of the function?
I support some code and it does not work in Delphi 2007. Declaration:
var
EditorFrameWindow: Function: HWnd Of Object = Nil;
In the form activation, I have:
procedure TEditForm.FormActivate(Sender: TObject);
begin
EditorFrameWindow := GetFrameWindow;
end;
And in the deactivation form, I have:
procedure TEditForm.FormDeactivate(Sender: TObject);
begin
if EditorFrameWindow = GetFrameWindow then
EditorFrameWindow := nil;
end;
So what happens is that the form is deactivated twice, and it fails because nothing else is activated. Called FormDeactivate, it matches, and global EditorFrameWindow - (nil, nil) (according to the debugger). Then it is called again, and the function stored in the variable is called, but, of course, it is not, so it jumps over nil and throws an exception.
What should I do to stop this? (The frame was changed to a tabbed system, so the operation probably changed.)