Yes, this is not a bad base implementation:
procedure TCustomEdit.CNCommand(var Message: TWMCommand); begin if (Message.NotifyCode = EN_CHANGE) and not FCreating then Change; end;
This message does not take into account that “A,” which is the button that launches EN_CHANGE, currently comes with ctrl pressed.
What you can do is check if the Ctrl key is pressed or not:
procedure TForm44.edt1Change(Sender: TObject); function IsCtrlPressed: Boolean; var State: TKeyboardState; begin GetKeyboardState(State); Result := ((State[VK_CONTROL] and 128) <> 0); end; begin if IsCtrlPresed then Exit; Caption := 'Ctrl is not pressed'; end;
In order not to read the state of the entire keyboard, you can do what was suggested by David Heffernan:
procedure TForm44.edt1Change(Sender: TObject); function IsCtrlPresed: Boolean; begin Result := GetKeyState(VK_CONTROL) < 0; end; begin if IsCtrlPresed then Exit; Caption := 'Ctrl is not pressed'; end;
source share