Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Misc > Re: WndProc
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 16 Topic 5998 of 6155
Post > Topic >>

Re: WndProc

by Jamie <jamie_ka1lpa_not_valid_after_ka1lpa_@[EMAIL PROTECTED] > Feb 27, 2008 at 07:14 PM

Fons wrote:
> 
>>> This works fine:
>>>
>>> procedure TFormTest.WndProc(var Message: TMessage);
>>> begin
>>>    inherited;
>>>
>>>    if Message.LParam = longint(Label1) then begin
>>>      case Message.Msg of
>>>        CM_MOUSELEAVE : Label2.Caption := 'CM_MOUSELEAVE';
>>>        CM_MOUSEENTER : Label2.Caption := 'CM_MOUSEENTER';
>>>      end;
>>>    end;
>>> end;
>>>
>>> Until I put Label1 in a TPanel. If I catch WndProc of Label1, instead
>>> of the Form, I can make it work but there must be a better solution.
>>>
>>> I tried Internet but couldn't find a solution (WndProc and controls in
>>> TPanels).
>>
>>
>> You seem to imply there is some sort of problem. But you don't say what
>> it is.
>>
>> Application.OnMessage?
> 
> 
> The problem is that both "Label2.Caption := ..." are called when Label1 
> is directly in the form. But when I move Label1 into a TPanel (that is 
> directly in the form), so: a label on top of a panel that is on top of a

> form; then "Label2.Caption := ..." is not called. I made some object 
> that makes it work:
> 
> THandleMessage = procedure (Sender : TObject; Message : TMessage)
>                  of object;
> 
> constructor TCatchWndMethod.Create(aWinControl: TWinControl; 
> aHandleMessage : THandleMessage);
> begin
>   WinControl := aWinControl;
>   OldWindowProc := WinControl.WindowProc;
>   WinControl.WindowProc := WindowProc;
>   HandleMessage := aHandleMessage;
> end;
> 
> procedure TCatchWndMethod.WindowProc(var Message: TMessage);
> begin
>   if Assigned(OldWindowProc) then
>     OldWindowProc(Message);
>   HandleMessage(WinControl, Message);
> end;
> 
> Called with:
> 
> TCatchWndMethod.Create(TWinControl(Label1), HandleMessage);
> 
> In HandleMessage:
> 
> procedure TFormTest.HandleMessage(Sender: TObject; Message: TMessage);
> begin
>   if Sender = Label1 then begin
>     case Message.Msg of
>       CM_MOUSELEAVE : Label2.Caption := 'CM_MOUSELEAVE';
>       CM_MOUSEENTER : Label2.Caption := 'CM_MOUSEENTER';
>     end;
>   end;
> end;
> 
> you have to call:
> 
>   if Sender = Label1 then
> 
> instead of:
> 
>   if Message.LParam = longint(Label1) then
> 
> because the latter doesn't work.
> 
> In this construction "Label2.Caption := ..." is called when Label1 is 
> placed in a TPanel.
> 
>> Groetjes,
>> Maarten Wiltink
> 
> 
> Thanks,
> Fons.
> 
A Tlabel is a managed control with in the VCL and has no window of it's 
own.
   A Tpanel how ever is a windows control and has it's own window so that
means all Tlabel type controls (TGraphic) become a child of that panel.
  Tgraphic controls do not receive messaegs from the OS message pump 
instead, the parent of the control will send on messages needed to 
manage the control..
   This type of control can not receive input focus etc.
A TFORM and TPANEL both contain a real windows handle to message
messages from the OS etc..

etc..
  That was put in layman's terms ..



-- 
http://webpages.charter.net/jamie_5"
 




 16 Posts in Topic:
WndProc
Fons <fonzzzNO@[EMAIL   2008-02-27 21:11:20 
Re: WndProc
"Maarten Wiltink&quo  2008-02-27 22:32:19 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-27 23:15:55 
Re: WndProc
Jamie <jamie_ka1lpa_no  2008-02-27 19:14:16 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-28 17:45:24 
Re: WndProc
Jamie <jamie_ka1lpa_no  2008-02-28 19:40:31 
Re: WndProc
Rob Kennedy <me3@[EMAI  2008-02-27 19:56:07 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-28 17:46:53 
Re: WndProc
Brad Blanchard <nadie1  2008-02-28 19:12:28 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-28 19:34:26 
Re: WndProc
"Chris.Cheney"   2008-02-28 18:58:15 
Re: WndProc
"Maarten Wiltink&quo  2008-02-28 20:09:08 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-28 20:21:29 
Re: WndProc
"Maarten Wiltink&quo  2008-02-28 20:29:11 
Re: WndProc
Fons <fonzzzNO@[EMAIL   2008-02-28 20:48:18 
Re: WndProc
"Maarten Wiltink&quo  2008-02-29 09:31:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 10:30:41 CDT 2008.