有没有试过向子窗体发送消息请求ADOQUERY的状态,子窗体接受消息后,将ADOQUERY的状态信息发送给主窗体。
定义一个消息
CONST
WM_DOCANCLOSE = WM_USER + 101; //子窗体向主窗体发出的是否能关闭的消息
主窗体参考代码
假设子窗体发回的消息Msg.WParam=1表示可以关闭,Msg.WParam=0不能关闭;
TFORM1 = CLASS(TFORM)
...
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
PRIVATE
WM_QUESTIONCLOSE: Integer; //向子窗体发送的请求是否能关闭的全局消息的ID
FCANCLOSE: Boolean;
procedure DoCanClose(var Msg: Tmessage); message WM_DOCANCLOSE;
PUBLIC
...
END;
implementation
procedure TForm6.DoCanClose(var Msg: Tmessage);
begin
FCanClose := Msg.WParam = 1;
end;
procedure TForm6.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
FCanClose := False;
//向BPL包内的子窗体发送消息要用广播消息才行,广播的消息要先注册
SendMessage(HWND_BROADCAST, WM_QUESTIONCLOSE, 0, 0);
CanClose := FCanClose;
end;
Initialization
QUESTIONCLOSE := RegisterWindowMessage('QUESTION_CANCLOSE');
子窗体接收到WM_QUESTIONCLOSE消息后
SendMessage(Application.MainForm.Handle, WM_DOCANCLOSE, Canclose{0 or 1}, 0)
也许我把问题搞复杂了,但动态调用BPL我实在也想不出好办法,呵呵。