高手啊高手!敢問在何方!在Delphi7中做組件捕捉鼠標消息時碰到了難題!請幫幫手! (50分)

  • 主题发起人 主题发起人 cailihui
  • 开始时间 开始时间
C

cailihui

Unregistered / Unconfirmed
GUEST, unregistred user!
在[red]Delphi7[/red]中,請注意是Delphi7,新建一組件,定義一過程鼠標進入消息,然后新建一項目,在設計時使用該組件,這時竟然也觸發了鼠標事件!同樣的代碼在Delphi6.0中是正常的!
unit prSpeedButton;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Buttons,Graphics,Dialogs;
type
TprSpeedButton = class(TSpeedButton)
private
{ Private declarations }
procedure MouseEnter(var msg : TMessage);message cm_mouseenter;
procedure MouseLeave(var msg : TMessage);message cm_mouseleave;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('PR Controls', [TprSpeedButton]);
end;
{ TprSpeedButton }
procedure TprSpeedButton.MouseEnter(var msg: TMessage);
begin
inherited;
Font.Color := clHotLight;
ShowMessage('Hello');
end;
procedure TprSpeedButton.MouseLeave(var msg: TMessage);
begin
inherited;
font.Color := clDefault;
end;
end.
 
procedure TprSpeedButton.MouseEnter(var msg: TMessage);
begin
inherited;
if not (csDesigning in ComponentState ) then
begin
Font.Color := clHotLight;
ShowMessage('Hello');
end;
end;
 
To:jssy
我明白你的做法!問題是:為什麼Delphi6不需要這樣。所以我想是不是有什麼開關!
 
Delphi6的发出这一消息的DoMouseIdle代码
function TApplication.DoMouseIdle: TControl;
var
CaptureControl: TControl;
P: TPoint;
begin
GetCursorPos(P);
Result := FindDragTarget(P, True);
if (Result <> nil) and (csDesigning in Result.ComponentState) then
Result := nil;
CaptureControl := GetCaptureControl;
if FMouseControl <> Result then
begin
if ((FMouseControl <> nil) and (CaptureControl = nil)) or
((CaptureControl <> nil) and (FMouseControl = CaptureControl)) then
FMouseControl.Perform(CM_MOUSELEAVE, 0, 0);
FMouseControl := Result;
if ((FMouseControl <> nil) and (CaptureControl = nil)) or
((CaptureControl <> nil) and (FMouseControl = CaptureControl)) then
FMouseControl.Perform(CM_MOUSEENTER, 0, 0);
end;
end;
不知道Delphi7的DoMouseIdle代码是什么
 

Similar threads

I
回复
0
查看
515
import
I
I
回复
0
查看
748
import
I
I
回复
0
查看
692
import
I
后退
顶部