为什么给text赋值,会产生一个Key=37的按键消息?(15分)

  • 主题发起人 主题发起人 hjp0214
  • 开始时间 开始时间
H

hjp0214

Unregistered / Unconfirmed
GUEST, unregistred user!
继承是TCustomMaskedit
新控件在CMEnter消息时,也会产生Key=37的按键,
检查代码,没有发现哪里产生什么key=37的keydown消息啊

分数有点低,希望大家帮忙解决
 
procedure TCustomMaskEdit.SetCursor(Pos: Integer);
const
ArrowKey: array[Boolean] of Word = (VK_LEFT, VK_RIGHT);
var
SelStart, SelStop: Integer;
KeyState: TKeyboardState;
NewKeyState: TKeyboardState;
I: Integer;
begin
if (Pos >= 1) and (ByteType(EditText, Pos) = mbLeadByte) then Dec(Pos);
SelStart := Pos;
if (IsMasked) then
begin
if SelStart < 0 then
SelStart := 0;
SelStop := SelStart + 1;
if (Length(EditText) > SelStop) and (EditText[SelStop] in LeadBytes) then
Inc(SelStop);
if SelStart >= FMaxChars then
begin
SelStart := FMaxChars;
SelStop := SelStart;
end;

SetSel(SelStop, SelStop);

if SelStart <> SelStop then
begin
GetKeyboardState(KeyState);
for I := Low(NewKeyState) to High(NewKeyState) do
NewKeyState := 0;
NewKeyState [VK_SHIFT] := $81;
NewKeyState [ArrowKey[UseRightToLeftAlignment]] := $81;
SetKeyboardState(NewKeyState);
FSettingCursor := True;
try
SendMessage(Handle, WM_KEYDOWN, ArrowKey[UseRightToLeftAlignment], 1);//这里发出的消息
SendMessage(Handle, WM_KEYUP, ArrowKey[UseRightToLeftAlignment], 1);
finally
FSettingCursor := False;
end;
SetKeyboardState(KeyState);
end;
FCaretPos := SelStart;
end
else
begin
if SelStart < 0 then
SelStart := 0;
if SelStart >= Length(EditText) then
SelStart := Length(EditText);
SetSel(SelStart, SelStart);
end;
end;
怎么样屏蔽呢
 
子类中对SetCursor方法reintroduce不久得了??
这样,你爱怎么屏蔽就怎么屏蔽!!
 
即使屏蔽了,但又有新问题了,就是如果设置了editmask属性了话,就输入不了了。
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
623
import
I
I
回复
0
查看
571
import
I
后退
顶部