Frame 的如何得知表單的動作 |
|
zombit
初階會員 發表:63 回覆:39 積分:30 註冊:2004-05-11 發送簡訊給我 |
|
jest0024
高階會員 發表:11 回覆:310 積分:224 註冊:2002-11-24 發送簡訊給我 |
引言: A Form 中有一個 B Frame, B Frame 如何收到 A 的 OnClose 事件, 如果不是在 A 的 OnClose 主動送資訊給 B 的話. 請指教, 謝謝. type TFrame2 = class(TFrame) private { Private declarations } public constructor Create(AOwner: TComponent); override; end; TWndProc = function (Wnd:HWND;uMsg:UINT;wp:WPARAM;lp:LPARAM):LRESULT;stdcall; var fp:TWndProc; implementation uses Unit1; {$R *.dfm} function fWndProc(Wnd:HWND;uMsg:UINT;wp:WPARAM;lp:LPARAM):LRESULT;Stdcall; begin if uMsg=WM_CLOSE then ShowMessage('Close'); Result:=fp(Wnd,uMsg,wp,lp); end; constructor TFrame2.Create(AOwner: TComponent); begin Inherited; fp:=Pointer(SetWindowLong(Form1.Handle,GWL_WNDPROC,LongInt(@fWndProc))); end; |
zombit
初階會員 發表:63 回覆:39 積分:30 註冊:2004-05-11 發送簡訊給我 |
|
jest0024
高階會員 發表:11 回覆:310 積分:224 註冊:2002-11-24 發送簡訊給我 |
type TFrame3 = class(TFrame) CheckBox1: TCheckBox; private { Private declarations } public fp:TWndMethod; constructor Create(AOwner: TComponent); override; procedure fWndProc(var Message: TMessage); end; ... ... procedure TFrame3.fWndProc(var Message: TMessage); begin // if message.Msg=WM_CLOSE Then SHowmessage(Format('%s.Close',[Owner.Name])); if(CheckBox1.Checked)and(Message.Msg=WM_CLOSE)then Message.Msg:=WM_NULL; fp(message); end; constructor TFrame3.Create(AOwner: TComponent); begin Inherited; fp:=TForm(Owner).WindowProc; TForm(Owner).WindowProc:=fWndProc; end;發表人 - jest0024 於 2005/07/09 22:24:23 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |