procedure WmActivate(var Msg:TWMActivateApp); message WM_ACTIVATEAPP;
上面的message WM_ACTIVATEAPP;我不明白这中写法,它是参数吗?

解决方案 »

  1.   

    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 handlersThe 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 dispatchingMessage 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.
      

  2.   

    message   WM_ACTIVATEAPP; 
    说明它响应  WM_ACTIVATEAPP 这个消息
    也就是说
    窗体收到这个消息
    会调用这个过程
      

  3.   

    message关键字说明是消息方法,
    对WM_ACTIVATEAPP消息响应