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 

Transferring mouse messages & coordinates between controls w

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





PostPosted: Tue Aug 22, 2006 4:52 pm    Post subject: Transferring mouse messages & coordinates between controls w Reply with quote



Dear All,

I have a custom control, let's call it "MyNewControl" that is a
TCustomControl descendant. I have a Custom Label on it (created in
MyNewControl.Create and freed in MyNewControl.Detstroy), let's call it
"MyLabel", which is a TCustomLabel descendant. I set MyLabel.Parent =
AOwner, which is MyNewControl, in MyLabel.Create (code: self.Parent :=
AOwner as TWinControl).

My point is that I want this MyLabel to ignore all mouse messages and
transfer them to MyNewControl.

For this, I've overridden the WndProc in MyLabel, which looks like
this:

Procedure TMyLabel.WndProc(var Message: TMessage);
var
myMousePoint: TPoint;
begin
if (
(Message.Msg=WM_MOUSEMOVE) or
(Message.Msg=WM_LBUTTONDOWN) or
(Message.Msg=WM_LBUTTONUP) or
(Message.Msg=WM_LBUTTONDBLCLK) or
(Message.Msg=WM_RBUTTONDOWN) or
(Message.Msg=WM_RBUTTONUP) or
(Message.Msg=WM_RBUTTONDBLCLK) or
(Message.Msg=WM_MBUTTONDOWN) or
(Message.Msg=WM_MBUTTONUP) or
(Message.Msg=WM_MBUTTONDBLCLK) or
(Message.Msg=WM_MOUSEWHEEL) or
(Message.Msg=WM_NCMOUSEMOVE) ) then
begin
//the next line WORKS, but provides wrong coordinates to the parent
(different coordinate systems)
//self.Parent.Perform(Message.Msg, Message.WParam, Message.LParam)

//for testing, the next 2 lines WORK, but exactly same problem as
above, provides wrong coordinates to MyNewComponent
//myMousePoint := Point(LOWORD(Message.LParam), Word(Message.LParam
shr 16));
//self.Parent.Perform(Message.Msg, Message.WParam, myMousePoint.X
or (myMousePoint.Y shl 16));

//based on the previous lines, the next 2 lines should convert
MyLabel's coordinates to MyNewControl's coordinates, but Delphi quits,
or shows a "Stack overflow" error message
myMousePoint :=
self.Parent.ScreenToClient(self.ClientToScreen(Point(LOWORD(Message.LParam),
Word(Message.LParam shr 16))));
self.Parent.Perform(Message.Msg, Message.WParam, myMousePoint.X or
(myMousePoint.Y shl 16));
end
else
inherited WndProc(Message);
end;

Please see the commented lines. I tried to convert MyLabel's
coordinates to MyNewControl's coordinates, but this generates a very
nasty "stack overflow" error in the Delphi IDE, if I move the mouse
pointer over MyLabel. If I run the test app, it hangs, with processor
on 100%.

What is happening? It seems that ScreenToClient and ClientToScreen does
something extra I don't know about.

Thank you for your time and ideas in advance!
Keke
Back to top
Riki Wiki
Guest





PostPosted: Sat Aug 26, 2006 11:32 am    Post subject: Re: Transferring mouse messages & coordinates between contro Reply with quote



Hoi Keke

You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question. Further, this news
group do not officially exist, the group to use is
b.p.d.vcl.components.writing.win32.

How to post to Delphi newsgroups:
<http://delphi.wikia.com/wiki/Delphi_Newsgroups>
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.