C
charles2002
Unregistered / Unconfirmed
GUEST, unregistred user!
在D5开发人员指南的第13章是有一段关于子类化的程序<br><br>procedure TMainForm.HandleAppMessage(var Msg: TMsg; var Handled: Boolean);<br>{ OnMessage handler for Application object. }<br>begin<br> if Msg.Message = DDGM_FOOMSG then<br> ShowMessage(Format('Message seen by OnMessage! Value is: $%x',[Msg.Message]));<br>end;<br><br>procedure TMainForm.WndMethod(var Msg: TMessage);<br>begin<br> if Msg.Msg = DDGM_FOOMSG then<br> ShowMessage(Format('Message seen by WndMethod! Value is: $%x', [Msg.Msg]));<br> with Msg do<br> { Pass message on to old window procedure. }<br> Result := CallWindowProc(OldWndProc, Application.Handle, Msg, wParam,<br> lParam);<br>end;<br><br>procedure TMainForm.SendBtnClick(Sender: TObject);<br>begin<br> SendMessage(Application.Handle, DDGM_FOOMSG, 0, 0);<br>end;<br><br>procedure TMainForm.PostBtnClick(Sender: TObject);<br>begin<br> PostMessage(Application.Handle, DDGM_FOOMSG, 0, 0);<br>end;<br><br>procedure TMainForm.FormCreate(Sender: TObject);<br>begin<br> Application.OnMessage := HandleAppMessage; // set OnMessage handler<br> WndProcPtr := MakeObjectInstance(WndMethod); // make window proc<br> OldWndProc := Pointer(SetWindowLong(Application.Handle, GWL_WNDPROC,<br> Integer(WndProcPtr)));<br>end;<br><br>procedure TMainForm.FormDestroy(Sender: TObject);<br>begin<br> SetWindowLong(Application.Handle, GWL_WNDPROC, Longint(OldWndProc));<br> FreeObjectInstance(WndProcPtr);<br>end;<br>1、里面的MakeObjectInstance()是创建了一个窗口过程吗<br>2、OldWndProc := Pointer(SetWindowLong(Application.Handle, GWL_WNDPROC,<br> Integer(WndProcPtr)))有什么作用<br>