06-09-2017, Saat: 23:07
Birinci Form
İkinci Form
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
//Declare the message body name
const
Mymsg= 'delphican';
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
WProc: Pointer;
DelphicanMmsg: cardinal;
implementation
{$R *.dfm}
function NewWndProc(Handle: hWnd; Msg, wParam, lParam: Cardinal): LongInt; stdcall;
begin
if Msg= DelphicanMmsg then
begin
MessageBox(handle, 'Uygulama Mesajı', '', MB_OK);
Result:= 1;
end else
Result := CallWindowProc(WProc, Handle, Msg, wParam, lParam);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Sleep(30000);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DelphicanMmsg:= RegisterWindowMessage(Mymsg);
end;
initialization
WProc := Pointer(SetWindowLong(Application.Handle, gwl_WndProc,
Integer(@NewWndProc)));
end.
İkinci Form
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
const
Mymsg= 'delphican';
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
DelphicanMmsg: cardinal; //This is the actual handle of the message
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(HWND_BROADCAST, DelphicanMmsg, 0, 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DelphicanMmsg:= RegisterWindowMessage(Mymsg);
end;
end.

