A: It just doesn't want to happen in the OnKeyDown event of the memo field. You have to go to the application level for this one.
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;
procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
if (Msg.hwnd = Memo1.Handle) and
(Msg.Message = WM_KEYDOWN) and
(Msg.wParam = VK_RETURN) then { user pressed
return key }
begin
if GetKeyState(VK_CONTROL) < 0 then { control
key is down }
caption := 'Cool stuff, dude!';
Handled := True;
end;
end;
Note: If you use GetKeyState(vk_Return) you must check for a value
greater than zero.