[DUG] Component creation
Gary T. Benner
gary at 123.co.nz
Tue Sep 5 11:37:21 NZST 2006
[Reply]
HI Rob et all,
Here's a mod to the previous code that makes the change when you click on the form.
Note that when you click off the component on to a non-focusable object, the original component still has focus, so you can trap the mousedown event and go from there.
If you click on a focusable component then focus leaves and you can trap the onexit event.
HTH
cheers
Gary
unit Edit1;
interface
uses
Messages,SysUtils, Classes, Controls, StdCtrls, Graphics;
type
TEdit1 = class(TEdit)
private
{ Private declarations }
procedure MyExit(var Message: TCMExit); message CM_EXIT;
procedure MyEnter(var Message: TCMEnter); message CM_ENTER;
procedure MyMousedown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('GCS', [TEdit1]);
end;
{ TEdit1 }
procedure TEdit1.MyEnter(var Message: TCMEnter);
begin
color:=clYellow;
end;
procedure TEdit1.MyExit(var Message: TCMExit);
begin
//
color:=clWindow;
end;
procedure TEdit1.MyMousedown(var Message: TWMLButtonDown);
begin
color:=clWindow;
inherited;
end;
end.
At 10:55 on 5/09/2006 you wrote
>To : delphi at ns3.123.co.nz
>CC : >From: Robert martin, rob at wildsoft.co.nz
>Content Type: text/plain
>Attached: >
>Thought I had tried it but my implementation mat have been wrong, will >have another crack :)
>
>Rob Martin
>Software Engineer
>
>phone +64 03 377 0495
>fax +64 03 377 0496
>web www.chreos.com
>
>Wild Software Ltd
>
>
>
>James Sugrue wrote:
>> WM_KILLFOCUS?
>>
>> Never used it, but apparently it can be a bit dodgy.
>>
>> -----Original Message-----
>> From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
>> Behalf Of Robert martin
>> Sent: Tuesday, September 05, 2006 10:11 AM
>> To: NZ Borland Developers Group - Delphi List
>> Subject: [DUG] Component creation
>>
>> Hi
>>
>> I have a custom component that expands to show data. When focus changes >> it reverts back to its shrunken state. However I also want it to revert >> to small if the user clicks the mouse anywhere outside of the component >> (the way that TComboBox does if it is dropped down).
>>
>> I assume I need to trap a windows message to handle this but I just cant >> see which.
>>
>> Any suggestions ?
>>
>> >_______________________________________________
>Delphi mailing list
>Delphi at ns3.123.co.nz
>http://ns3.123.co.nz/mailman/listinfo/delphi
>
Ref#: 41006
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ns3.123.co.nz/pipermail/delphi/attachments/20060905/936e52df/attachment.html
More information about the Delphi
mailing list