As I wrote it the title I have a problem with AV caused by FTouchManager when runtime themes are enabled. On main form I have a frame with one button. OnClick event calls main form method which has to destroy frame. If I click on that button I got AV in 'Vcl.Controls'. When I disable runtime themes everything will work ok. How can I solve this problem?
Thank you in advance, Tim
Tested on: Delphi XE3, XE6 Platform: Win32
Vcl.Controls:
procedure TWinControl.WndProc(var Message: TMessage);
...
WM_MOUSEFIRST..WM_MOUSELAST:
with FTouchManager do
if (GestureEngine <> nil) and (efMouseEvents in GestureEngine.Flags) then // <-- here I get AV error because FTouchManager = nil
GestureEngine.Notification(Message);
...
end;
FrameUnit:
constructor TFrame2.Create(AOwner: TWinControl);
begin
inherited Create(AOwner);
Parent := AOwner;
end;
destructor TFrame2.Destroy;
begin
Parent := nil;
inherited;
end;
procedure TFrame2.Button1Click(Sender: TObject);
begin
Form1.DestroyFrame;
end;
MainFormUnit:
procedure TForm1.FormShow(Sender: TObject);
begin
Frame2 := TFrame2.Create(Form2);
end;
procedure TForm1.DestroyFrame;
begin
FreeAndNil(Frame2);
end;
You are destroing the frame and thus the contained button during its OnClick event. So every code inside the button and/or frame instance following the OnClick event references a destroyed self. That doesn't look quite sane to me.
Better post a message to the form (PostMessage
) that calls DestroyFrame in a message handler.