首页 > 代码库 > Delphi自定义窗口过程WinProc

Delphi自定义窗口过程WinProc

unit ScWndProc;interfaceuses Forms, Messages;const    DDGM_FOOMSG = WM_USER;  //自定义消息implementationuses 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);

Delphi自定义窗口过程WinProc