message 是什么东西?怎样使用?(100分)

  • 主题发起人 主题发起人 gislabecnu
  • 开始时间 开始时间
G

gislabecnu

Unregistered / Unconfirmed
GUEST, unregistred user!
请各位大虾告诉小弟 message从何而来?为何有他?怎样正确使用message?请给我资料,谢了!!!xhf263@263.net
 
您是华师大gislab的?
来自:delphi help
Message handlers are methods that implement responses to dynamically dispatched messages. Delphi抯 VCL uses message handlers to respond to Windows messages.
A message handler is created by including the message directive in a method declaration, followed by an integer constant between 1 and 49151 which specifies the message ID. For message handlers in VCL controls, the integer constant must be one of the Windows message IDs defined, along with corresponding record types, in the Messages unit. For example,

type

TTextBox = class(TCustomControl)
private
procedure WMChar(var Message: TWMChar); message WM_CHAR;
...
end;

A message handler must be a procedure that takes a single var parameter.
A message handler does not have to include the override directive to override an inherited message handler. In fact, it doesn抰 have to specify the same method name or parameter type as the method it overrides. The message ID alone determines which message the method responds to and whether it is an override.

Implementing message handlers

The implementation of a message handler can call the inherited message handler, as in this example:

procedure TTextBox.WMChar(var Message: TWMChar);

begin
if Chr(Message.CharCode) = #13 then
ProcessEnter
else
inherited;
end;

The inherited statement searches backward through the class hierarchy and invokes the first message handler with the same ID as the current method, automatically passing the message record to it. If no ancestor class implements a message handler for the given ID, inherited calls the DefaultHandler method originally defined in TObject.
The implementation of DefaultHandler in TObject simply returns without performing any actions. By overriding DefaultHandler, a class can implement its own default handling of messages. The DefaultHandler method for VCL controls calls the Windows DefWindowProc function.

Message dispatching

Message handlers are seldom called directly. Instead, messages are dispatched to an object using the Dispatch method inherited from TObject:

procedure Dispatch(var Message);

The Message parameter passed to Dispatch must be a record whose first entry is a field of type Cardinal containing a message ID. See the Messages unit for examples.
Dispatch searches backward through the class hierarchy (starting from the class of the object where it is called) and invokes the first message handler for the ID passed to it. If no message handler is found for the given ID, Dispatch calls DefaultHandler.
 
消息吗!
 
MESSAGE是WINDOWS进程间通讯的基础,也是各资源对象的响应系统的主要途径。
MESSAGE利用WINDOWS全局内存存储它的数据与结构,有一个全局消息队列,而且
每个程序也有自己的消息队列,关于消息系统,WINDOWS PROGRAMMER REFERENCE说的很详细,请自己查询。最好是有一本关于WINDOWS编程的书。
基于一个特定的操作系统编程,就要对这个系统的工作原理清楚。
 
整个windows就是消息驱动的...
本论坛以前讨论过,请搜索待答问题
 
是Windows进程通讯的中介,用法如messagedlg() 或者 showmessage() ......
 
正如WAIWAI所说,你直接用messagedlg()试一下,你就会明白的,例如
messgaedlg('字符串',mtwarning,[mbok],0);
showmessage('字符串');
 
waiwai又在误导群众了
“Windows进程通讯的中介”和 “messagedlg() 或者 showmessage() ”
是2回事嘛
 
非也,非也!不是我误导群众,只是想说明怎样简单的调用示范一下以便理解。
 
PiPi批评的对,waiwai那两个算什么吗,
人家问的是windows的消息,不是提示程序消息
 
message在操作系统中是一种进程之间传递信息的机制,称做"消息机制".
而微软的PC操作系统正是采用了这种机制,而我们在WINDOWS平台上做应用
时就可以使用这种机制,既可自己定义消息,也可捕捉系统的消息,来完成
特定的功能.
顺便问一句:这儿有多少是华东师大的?
 
; 本人同意qf0421的说法,message是windows系列的系统进程之间传递信息的
一种方式,大家称之为"消息".Delphi中的事件正是通过它来捕捉系统传来的
信息,从而响应用户发出的指令.你可以看一看Delphi源程序中说明事件的方法
.当然,用户也可以通过消息自定义某元件的事件,即建立自己的组件.
 
那末多,save下来,慢慢看。
 
呵呵,不用save,下载离线包更好
 
接受答案了.
 
后退
顶部