unit ScWndProc; interface uses Forms, Messages; const DDGM_FOOMSG = WM_USER; //自定义消息 implementation uses windows,sysutils,Dialogs; var WProc : Pointer; function NewWndProc(handle: hWnd; msg,wParam,lParam: LongInt): LongInt ; stdcall; begin if msg = DDGM_FOOMSG then ShowMessage(Format(‘收到自定义消息 $%x‘,[msg])); result := CallWindowProc(WProc,handle, msg,wParam,lParam); end; initialization WProc := Pointer(SetWindowLong(application.Handle,GWL_WNDPROC ,integer(@NewWndProc))); end.
//发送消息
SendMessage(application.Handle,DDGM_FOOMSG,0,0);
时间: 2024-11-13 06:37:13