BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

somethings about Message Handler

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
Pascal
Guest





PostPosted: Sun Nov 16, 2003 8:54 am    Post subject: somethings about Message Handler Reply with quote



I don't understand somethings about Message Handler, hope anybody would like
to answer me:

I know I can write the following statement to be a handler for a message,
but I don't understand what section is the best section to put it? private
or protected is better?

procedure WMSIZE(var Message: TCMCancelMode); message WM_SIZE;

and in the implement code, should I put 'Inherited' as follow?

procedure TMyControl.WMSIZE(var Message: TCMCancelMode);
begin
inherited;
//other codes...........
end;

Thanks.
--Pascal





Back to top
Mike Lischke
Guest





PostPosted: Sun Nov 16, 2003 9:36 am    Post subject: Re: somethings about Message Handler Reply with quote



Pascal wrote:

Quote:
BUT if TMyControl is inherited from TMyParentControl, if I don't use
inherited, will it make TParentControl LOSE WMSIZE message or not?

Yes, this would happen. Message handler do not have the override keyword, they always are virtual and override ancestor implementations if used in a control. Calling inherited is essential unless you don't want the ancestor to handle the message too or you know for sure, there is no ancestor, which will handle the particular message.

Mike
--
www.delphi-gems.com
www.delphi-unicode.net
www.lischke-online.de

Back to top
Finn Tolderlund
Guest





PostPosted: Sun Nov 16, 2003 9:50 am    Post subject: Re: somethings about Message Handler Reply with quote




"Pascal" <dontreply (AT) openfind (DOT) com> skrev i en meddelelse
news:3fb73b4e (AT) newsgroups (DOT) borland.com...
Quote:
I know I can write the following statement to be a handler for a message,
but I don't understand what section is the best section to put it?
private
or protected is better?

private is fine.

Quote:
procedure WMSIZE(var Message: TCMCancelMode); message WM_SIZE;
and in the implement code, should I put 'Inherited' as follow?
procedure TMyControl.WMSIZE(var Message: TCMCancelMode);
begin
inherited;
//other codes...........
end;


Since you are not overriding a procedure there is no point in using
inherited.
--
Finn Tolderlund



Back to top
Pascal
Guest





PostPosted: Sun Nov 16, 2003 10:28 am    Post subject: Re: somethings about Message Handler Reply with quote


"Finn Tolderlund" <no (AT) spam (DOT) dk> ¼¶¼g©ó¶l¥ó·s»D
:3fb74860 (AT) newsgroups (DOT) borland.com...
Quote:

procedure WMSIZE(var Message: TCMCancelMode); message WM_SIZE;
and in the implement code, should I put 'Inherited' as follow?
procedure TMyControl.WMSIZE(var Message: TCMCancelMode);
begin
inherited;
//other codes...........
end;


Since you are not overriding a procedure there is no point in using
inherited.
--
Finn Tolderlund


BUT if TMyControl is inherited from TMyParentControl, if I don't use
inherited, will it make TParentControl LOSE WMSIZE message or not?



Back to top
Peter Below (TeamB)
Guest





PostPosted: Sun Nov 16, 2003 10:47 am    Post subject: Re: somethings about Message Handler Reply with quote

In article <3fb73b4e (AT) newsgroups (DOT) borland.com>, Pascal wrote:
Quote:
I know I can write the following statement to be a handler for a message,
but I don't understand what section is the best section to put it? private
or protected is better?

It really does not matter. Inherited in a message handler works differently
than for a virtual method. For the latter the ancestors method has to have at
least protected visibility, but for message handlers the lookup in the
ancestor is not done via the methods name at compile time, but via the message
code itself, at run-time. This uses a special table in the class record, the
"dynamic message table" (DMT), which associates a message code with a handler
methods address. It ignores the visibility specifiers.

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.