unit unit1;
inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls;
type
tform1 = class(tform)
button1: tbutton;
procedure formcreate(sender: tobject);
procedure button1click(sender: tobject);
private
msg: longint;
protected
procedure wndproc(var message: tmessage); override;
public
end;
varform1: tform1;
implementation
procedure tform1.formcreate(sender: tobject);
begin
msg := registerwindowmessage('wm_mymessage');
self.bringtofront;
end;
procedure tform1.wndproc(var message: tmessage);
begin
if message.msg = msg then begin
caption := '';
showmessage('收到訊息了');
endelse begin
inherited;
end;
end;
procedure tform1.button1click(sender: tobject);
varm: tmessage;
b: dword;
begin
m.msg := msg;
b := b**_allcomponents;
broadcastsystemmessage(bsf_postmessage, @b , m.msg, m.wparam, m.lparam );
end;
end.
視窗檔案
object form1: tform1
left = 192
top = 107
width = 696
height = 480
caption = 'form1'
color = clbtnface
font.charset = default_charset
font.color = clwindowtext
font.height = -11
font.name = 'ms sans serif'
font.style =
oldcreateorder = false
oncreate = formcreate
pixelsperinch = 96
textheight = 13
object button1: tbutton
left = 204
top = 84
width = 75
height = 25
caption = 'button1'
taborder = 0
onclick = button1click
endend
程序間傳遞訊息
使用自定義訊息 1 首先定義訊息 例如 define wm yourmesg wm user 100 2 加入訊息響應巨集,在響應該訊息的類中 c c code?1 2 3 4 5 begin message map cchiliddlg,cdialog afx msg map end messag...
MFC 程序間訊息傳遞
在涉及到將乙個程序的資訊傳送到另乙個程序的訊息,並讓另乙個進行訊息處理,通常需要涉及到程序間通訊。分別在兩個程序間定義訊息 在要接受的程序間定義訊息對映 在傳送訊息的程序進行訊息觸發 在進行傳送訊息的程序首先獲取到接受程序的控制代碼,通過定義的訊息進行傳送訊息,在接受程序定義對應的訊息對映 在傳送程...
kafka 訊息傳送和接收
傳送 例項 public class kafkaproducerdemo extends thread override public void run else catch interruptedexception e catch executionexception e num try catc...