var
tmpForm: TForm; procedure tmpFormClose(Sender: TObject;
var Action: TCloseAction);
begin
showmessage('');
end; function getshareForm: TForm;
var
tmpForm: TForm;
Begin
Result := Nil;
tmpForm := TForm.Create(application);
tmpForm.OnClose := tmpFormClose;//此处报错5~5555~
Result := tmpForm;
End;
错误信息:
[Error] DM.pas(220): Incompatible types: 'method pointer and regular procedure'
请问该怎么改呀?谢谢!~
tmpForm: TForm; procedure tmpFormClose(Sender: TObject;
var Action: TCloseAction);
begin
showmessage('');
end; function getshareForm: TForm;
var
tmpForm: TForm;
Begin
Result := Nil;
tmpForm := TForm.Create(application);
tmpForm.OnClose := tmpFormClose;//此处报错5~5555~
Result := tmpForm;
End;
错误信息:
[Error] DM.pas(220): Incompatible types: 'method pointer and regular procedure'
请问该怎么改呀?谢谢!~
var Action: TCloseAction);
begin
showmessage('');
end;函数要放到你的Form类里面。
但是我的Form是动态生成的呀:(
并定义onclose事件为你的tmpFormClose之后你的代码就可以这样写了var
tmpForm: TmyForm; function getshareForm: TmyForm;
var
tmpForm: TmyForm;
Begin
Result := Nil;
tmpForm := TmyForm.Create(application);
Result := tmpForm;
End;
TO: sunmingdong() 根据你的提示,写了一个类,但是会出现下面的错误:
Project Ogl.exe raised exception class EResNotFound with message 'Resource TShareForm not found'. Process stopped. Use Step or Run to continue.
是不是还得先注册一个这个类呢?该怎样注册?
unit uCreateShareForm;interfaceuses
Forms, ExtCtrls, ParentForm, Dialogs, ActnList, Controls;Type
TShareForm = Class(TForm)
private
FNeedQuery: Boolean;
procedure tmpFormClose(Sender: TObject; var Action: TCloseAction);
procedure tmpExitExecute(Sender: TObject);
procedure ShareFormCloseQuery(Sender: TObject;
var CanClose: Boolean);
public
procedure InitializeValue;
published End; procedure CustomFShowPanel(FPanel: TPanel;FNeedQ: Boolean;FForm: TForm);
implementationprocedure CustomFShowPanel(FPanel: TPanel;FNeedQ: Boolean;FForm: TForm);
var
H,W: integer;
tmpShareForm: TShareForm;
function getshareForm: TShareForm;
Var
tmpShareForm: TShareForm;
Begin
tmpShareForm := TShareForm.Create(application);
tmpShareForm.initializeValue;
tmpShareForm.OnClose := tmpShareForm.tmpFormClose;
tmpShareForm.OnCloseQuery := tmpShareForm.ShareFormCloseQuery;
End;
begin
H := FPanel.Height;
W := FPanel.Width;
try
tmpShareForm := getShareForm;
tmpShareForm.FNeedQuery := FNeedQ;
tmpShareForm.Height := FPanel.Height + 10;
tmpShareForm.Width := FPanel.Width + 10; FPanel.Parent := tmpShareForm;
FPanel.Align := alClient;
FPanel.Visible := true;
tmpShareForm.ShowModal;
finally
FPanel.Align := alNone;
FPanel.Height := H;
FPanel.Width := W;
FPanel.Parent := FForm;
FPanel.Visible := false;
tmpShareForm.Destroy;
end;
end;procedure TShareForm.tmpExitExecute(Sender: TObject);
begin
IF FNeedQuery Then
Tf_ParentForm(CurrentForm).Button3Click(nil);
end;procedure TShareForm.InitializeValue;
begin
FNeedQuery := False;
end;procedure TShareForm.tmpFormClose(Sender: TObject;
var Action: TCloseAction);
beginend;procedure TShareForm.ShareFormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
IF FNeedQuery Then
Tf_ParentForm(CurrentForm).Button3Click(nil);
end;end.