Delphi 7에서 TEdit 마우스 진입 종료 이벤트 처리
28425 단어 Delphi
1
unit
MyEdit;
2
3
interface
4
5
uses
6
SysUtils, Classes, Controls, StdCtrls,Messages,Dialogs,Forms,Windows;
7
8
type
9
TMsgDlgMode
=
(Yes_No,YES_NO_CANCEL,OK,OK_CANCEL,RETRY_CANCEL,ABORT_RETRY_IGNORE);
10
TShowDialogEvent
=
procedure
(Sender: TObject;Result:integer)
of
object
;
11
12
TMyEdit
=
class
(TEdit)
13
private
14
{
Private declarations
}
15
FAutoShowMsgOnMouseEnter:Boolean ;
16
FAutoShowMsgOnMouseLeave:Boolean ;
17
FMsgMsEnter:String;
18
FMsgMsLeave:String;
19
FMsgDlgModeEnter:TMsgDlgMode;
20
FMsgDlgModeLeave:TMsgDlgMode;
21
FMsgResultEnter:Integer;
22
FMsgResultLeave:Integer;
23
FOnMouseEnter: TNotifyEvent;
24
FOnMouseLeave: TNotifyEvent;
25
FAfterMsgDlgEnter:TShowDialogEvent;
26
FAfterMsgDlgLeave:TShowDialogEvent;
27
procedure
CMMouseEnter(
var
Message: TMessage);
message
CM_MOUSEENTER;
28
procedure
CMMouseLeave(
var
Message: TMessage);
message
CM_MOUSELEAVE;
29
protected
30
{
Protected declarations
}
31
public
32
{
Public declarations
}
33
property
MsgResultEnter:Integer
read
FMsgResultEnter
write
FMsgResultEnter;
34
property
MsgResultLeave:Integer
read
FMsgResultLeave
write
FMsgResultLeave;
35
published
36
{
Published declarations
}
37
property
AutoShowMsgOnMouseEnter:Boolean
read
FAutoShowMsgOnMouseEnter
write
FAutoShowMsgOnMouseEnter;
38
property
AutoShowMsgOnMouseLeave:Boolean
read
FAutoShowMsgOnMouseLeave
write
FAutoShowMsgOnMouseLeave;
39
property
MsgMsEnter:String
read
FMsgMsEnter
write
FMsgMsEnter;
40
property
MsgMsLeave:String
read
FMsgMsLeave
write
FMsgMsLeave;
41
property
MsgDlgModeEnter:TMsgDlgMode
read
FMsgDlgModeEnter
write
FMsgDlgModeEnter;
42
property
MsgDlgModeLeave:TMsgDlgMode
read
FMsgDlgModeLeave
write
FMsgDlgModeLeave;
43
property
OnMouseEnter:TNotifyEvent
read
FOnMouseEnter
write
FOnMouseEnter;
44
property
OnMouseLeave:TNotifyEvent
read
FOnMouseLeave
write
FOnMouseLeave;
45
property
AfterMsgDlgEnter:TShowDialogEvent
read
FAfterMsgDlgEnter
write
FAfterMsgDlgEnter;
46
property
AfterMsgDlgLeave:TShowDialogEvent
read
FAfterMsgDlgLeave
write
FAfterMsgDlgLeave;
47
end
;
48
49
procedure
Register;
50
51
implementation
52
53
procedure
Register;
54
begin
55
RegisterComponents(
'
Samples
'
, [TMyEdit]);
56
end
;
57
58
procedure
TMyEdit.CMMouseEnter(
var
Message: TMessage);
59
var
60
DlgMode:Integer ;
61
begin
62
if
csDesigning
in
ComponentState
then
Exit;
63
if
Assigned(FOnMouseEnter)
then
64
FOnMouseEnter(Self);
65
if
FAutoShowMsgOnMouseEnter
then
66
begin
67
case
FMsgDlgModeEnter
of
68
Yes_No:DlgMode:
=
MB_YESNO;
69
YES_NO_CANCEL:DlgMode:
=
MB_YESNOCANCEL;
70
OK:DlgMode:
=
MB_OK;
71
OK_CANCEL:DlgMode:
=
MB_OKCANCEL;
72
RETRY_CANCEL:DlgMode:
=
MB_RETRYCANCEL;
73
ABORT_RETRY_IGNORE:DlgMode:
=
MB_ABORTRETRYIGNORE;
74
end
;
75
if
FMsgMsEnter
=
''
then
76
FMsgMsEnter:
=
'
Mouse Enter
'
;
77
FMsgResultEnter:
=
Application.MessageBox(PChar(FMsgMsEnter),
78
PChar(Application.Title),
79
DlgMode);
80
if
Assigned(FAfterMsgDlgEnter)
then
81
FAfterMsgDlgEnter(Self,FMsgResultEnter);
82
end
;
83
end
;
84
85
procedure
TMyEdit.CMMouseLeave(
var
Message: TMessage);
86
var
87
DlgMode:Integer ;
88
begin
89
if
csDesigning
in
ComponentState
then
Exit;
90
if
Assigned(FOnMouseLeave)
then
91
FOnMouseLeave(Self);
92
if
FAutoShowMsgOnMouseLeave
then
93
begin
94
case
FMsgDlgModeLeave
of
95
Yes_No:DlgMode:
=
MB_YESNO;
96
YES_NO_CANCEL:DlgMode:
=
MB_YESNOCANCEL;
97
OK:DlgMode:
=
MB_OK;
98
OK_CANCEL:DlgMode:
=
MB_OKCANCEL;
99
RETRY_CANCEL:DlgMode:
=
MB_RETRYCANCEL;
100
ABORT_RETRY_IGNORE:DlgMode:
=
MB_ABORTRETRYIGNORE;
101
end
;
102
if
FMsgMsLeave
=
''
then
103
FMsgMsLeave:
=
'
Mouse Leave
'
;
104
FMsgResultLeave:
=
Application.MessageBox(PChar(FMsgMsLeave),
105
PChar(Application.Title),
106
DlgMode);
107
if
Assigned(FAfterMsgDlgLeave)
then
108
FAfterMsgDlgLeave(Self,FMsgResultLeave);
109
end
;
110
end
;
111
112
end
.
113
구성 요소 다운로드:http://files.cnblogs.com/uws2056/TMyEdit.rar
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[Delphi] TStringBuilder그리고 꼭 사용해야만 할까? 그림처럼 Heap 영역에 "Hello" 공간을 생성하고 포인팅을 한다. "Hello World" 공간을 새로 생성한 후 포인팅을 하게 된다. 결국 "Hello" 라는 String 객체가 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.