M
mill666
Unregistered / Unconfirmed
GUEST, unregistred user!
我想开发个stringgrid的控件,在cell输入完数据后,能够对cell的内容进行有效性检测;如下:
这里为了把问题说得简单点,让有效性检测只执行showmessage('****');
结果运行的时候,每输入完一个cell后,用鼠标点击【注意是用鼠标点击】下一个cell的时候,确实执行了showmessage('****')了,可问题在于执行了两次showmessage('****')了,难道触发了两次 WM_KILLFORCUS了码??
郁闷啊.......怎么样才能让其只执行一次??
代码:
TMyInplaceEdit = class(TInplaceEdit)
private
FOnEditExit: TNotifyEvent;
procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS;
//procedure WMKillFocus(var Msg: TCMExit); message CM_EXIT;
protected
property OnEditExit: TNotifyEvent read FOnEditExit write FOnEditExit;
end;
T8583Grid=class(Tstringgrid)
private
FOnCellEditExit:TNotifyEvent;
procedure celleditexit(Sender: TObject);
protected
function CreateEditor: TInplaceEdit; override;
public
constructor Create(AOwner: TComponent); override;
end;
{ T8583Grid }
procedure T8583Grid.celleditexit(Sender: TObject);
begin
showmessage('****');
end;
constructor T8583Grid.Create(AOwner: TComponent);
begin
inherited;
FOnCellEditExit:=self.celleditexit;
self.Options:=self.Options+[goEditing];
end;
function T8583Grid.CreateEditor: TInplaceEdit;
begin
Result := TMyInplaceEdit.Create(Self);
TMyInplaceEdit(Result).OnEditExit := FOnCellEditExit;
end;
{ TMyInplaceEdit }
procedure TMyInplaceEdit.WMKillFocus(var Msg: TWMKillFocus);
begin
if Assigned(FOnEditExit) then
FOnEditExit(Self);
inherited;
end;
这里为了把问题说得简单点,让有效性检测只执行showmessage('****');
结果运行的时候,每输入完一个cell后,用鼠标点击【注意是用鼠标点击】下一个cell的时候,确实执行了showmessage('****')了,可问题在于执行了两次showmessage('****')了,难道触发了两次 WM_KILLFORCUS了码??
郁闷啊.......怎么样才能让其只执行一次??