Delphi自定义窗口过程WinProc

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);

Delphi自定义窗口过程WinProc

上一篇:k8s cpu 高负载排查


下一篇:GetWindowRect和GetClientRect比较学习