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 

Implementing OnClick

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Sanyin
Guest





PostPosted: Thu Apr 05, 2007 6:05 pm    Post subject: Implementing OnClick Reply with quote



I want to implement OnClick event from TImage32, working with GR32 library.

In TCustomImage32 on MouseUP i have:
postmessage(image32.handle, LAYER_ONCLICK, integer(ref), 0);

and it sends message (LAYER_ONCLICK) to self:

procedure TCustomImage32.OnClickMessage(var message: tmessage); message
LAYER_ONCLICK;
begin
layer.DoClick.
end;

Should i call SendMessage, or PostMessage, or no message at all?
Should postmessage be called last, because if theres some code below
(repainting), message will never reach destination before that code ends?
Also, when layerclick destroys container (to wich it belongs), I should send
message to other control to destroy it?
Back to top
JD
Guest





PostPosted: Sun Apr 08, 2007 8:11 am    Post subject: Re: Implementing OnClick Reply with quote



"Sanyin" <prevodilac (AT) hotmail (DOT) com> wrote:
Quote:

In TCustomImage32 on MouseUP i have:

You failed to account for default Windows behavior which is
that when the mouse is released, the click is only executed
if the mouse is still within the control. The reason being
is that this behavior provides the user a way to cancel the
click.

Quote:
postmessage(image32.handle, LAYER_ONCLICK, integer(ref), 0);

and it sends message (LAYER_ONCLICK) to self:

PostMessage does not 'Send' a message. It 'Post'(s) it which
is significantly different.

Quote:
[...] Should i call SendMessage, or PostMessage,

PostMessage adds a message to the end of the message queue
and returns while SendMessage waits until the message has
been processed before returning. This is an important
distinction to make.

Let's assume that you're executing a block of code and you
detect that certain condition were reached and you need
certain things need to happen once the block has completed.

You can address this issue by using PostMessage to post a
custom message to a relevent Handle (HWND). How this will
work for you is that (unless you manually pump the message
queue [for example using TApplicationProcessMessages])
messages do not get processed until the application idles.

IOW, while your block of code is executing, the messages are
pending. As soon as your block of code completes, pending
messages get processed. OTOH, if you use SendMessage, your
block of code is interupted and it waits until SendMessage
returns (SendMessage does not add to the queue but rather
the message is processed immediately).

Quote:
or no message at all?

Using SendMessage to Self makes no sense because all that is
is a complicated function call. However, using PostMessage
will delay processing until the current block has finished
executing.

Quote:
Should postmessage be called last,

Where, within the block you call PostMessages makes no
difference (unless you manually pump the queue). The
message will never be processed until *after* your block
has completed execution.

Quote:
because if theres some code below (repainting), message will
never reach destination before that code ends?

When it comes to updating the VCL controls on-screen you have
2 choices. One is to call ProcessMessages (purests object) and
the other is to explicitly Update() a control.

Quote:
Also, when layerclick destroys container (to wich it belongs)
I should send message to other control to destroy it?

No No No!

Please recall that SendMessage waits until it returns. If you
use SendMessage to destroy the object that sent the message,
after SendMessage returns to the caller, it returns to an
object that has been destroyed! In this case, the best that
you could hope for is an Access Violation. You would need
to use PostMessage instead because that way your 'destroy'
message won't be processed until after the block has completed
execution which makes it elligable for destruction.

~ JD
Back to top
Sanyin
Guest





PostPosted: Mon Apr 09, 2007 8:11 am    Post subject: Re: Implementing OnClick Reply with quote



"JD" <nospam (AT) nospam (DOT) com> wrote in message
news:461870b5$1 (AT) newsgroups (DOT) borland.com...
Quote:

"Sanyin" <prevodilac (AT) hotmail (DOT) com> wrote:

In TCustomImage32 on MouseUP i have:

You failed to account for default Windows behavior which is
that when the mouse is released, the click is only executed
if the mouse is still within the control. The reason being
is that this behavior provides the user a way to cancel the
click.
I have checking if mouse is withing control (onhittest), but thats only for

OnMouseClick, not for mousedown!!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics 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.