lcl: Enter edit state for LM_PASTE / Clear / Cut for TDBEdit in WndProc instead of each one separated

git-svn-id: trunk@32484 -
This commit is contained in:
blikblum 2011-09-24 01:33:18 +00:00
parent d73f175065
commit 2012691818
2 changed files with 21 additions and 25 deletions

View File

@ -202,8 +202,7 @@ Type
procedure WMSetFocus(var Message: TLMSetFocus); message LM_SETFOCUS;
procedure WMKillFocus(var Message: TLMKillFocus); message LM_KILLFOCUS;
procedure LMPasteFromClip(var Message: TLMessage); message LM_PASTE;
procedure LMCutToClip(var Message: TLMessage); message LM_CUT;
procedure WndProc(var Message: TLMessage); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

View File

@ -123,12 +123,6 @@ begin
end;
end;
function FieldCanAcceptKey(Field: TField; AKey: char): boolean;
begin
Result := (Field<>nil) and Field.IsValidChar(AKey) and
(Field.DataType<>ftAutoInc);
end;
procedure TDBEdit.KeyPress(var Key: char);
var
SavedKey: Char;
@ -233,27 +227,30 @@ begin
FDatalink.Reset;
end;
procedure TDBEdit.LMPasteFromClip(var Message: TLMessage);
procedure TDBEdit.WndProc(var Message: TLMessage);
begin
if FDataLink.CanModify then
begin
//LCL changes the Text before LM_PASTE is called and not after like Delphi. Issue 20330
//When Edit is called the Text property is reset to the previous value
//Add a workaround while bug is not fixed
FDataLink.OnDataChange := nil;
FDatalink.Edit;
FDataLink.Modified;
FDataLink.OnDataChange := @DataChange;
inherited LMPasteFromClip(Message);
case Message.Msg of
LM_CLEAR,
LM_CUT,
LM_PASTE:
begin
if FDataLink.CanModify then
begin
//LCL changes the Text before LM_PASTE is called and not after like Delphi. Issue 20330
//When Edit is called the Text property is reset to the previous value
//Add a workaround while bug is not fixed
FDataLink.OnDataChange := nil;
FDatalink.Edit;
FDataLink.Modified;
FDataLink.OnDataChange := @DataChange;
inherited WndProc(Message);
end;
end;
else
inherited WndProc(Message);
end;
end;
procedure TDBEdit.LMCutToClip(var Message: TLMessage);
begin
FDatalink.Edit;
inherited LMCutToClip(Message);
end;
{ Public Methods }
constructor TDBEdit.Create(AOwner: TComponent);
begin