thanks for that.
The problem seems to be that when the ctrl is held down, it doesnt fire the
keypress or keyup events.

Strange.

Jeremy Coulter

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Andrew Little
Sent: Thursday, 6 September 2001 16:44
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Trapping ctrl+v


Hi,

This is a bit clugie, but it seems to work :) There is probably an API
hidden away some where.


FCtrl: Boolean;
FVKey: Boolean;

...

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  FCtrl := ssCtrl in Shift;
end;

procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
var
  pt: TPoint;
  s: string;
begin
  FV := Key = #22;
  if FV and FCtrl then
  begin
     pt := (Sender as TMemo).CaretPos;
     s := (Sender as TMemo).Lines[pt.y];
     Insert('// this is a comment' + #$D#$A, s, pt.x);
     (Sender as TMemo).Lines[pt.y] := s;
  end;
end;


Hope this helps?
Andrew.


----- Original Message -----
From: "vss" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, September 06, 2001 3:52 PM
Subject: [DUG]: Trapping ctrl+v


> HI All.
>
> I have a need to trap when someone does a paste into a control, so I can
> add some comments above the newly pasted text.
>
> What I am currently doing is if the press ctrl+v I get the line pos where
> the text is about to pasted to, then insert some text at that pos-1
>
> This does not quite work. I WOULD like to trap the event and do  what I
> need to.
>
> Can anyone give me some ideas ?
>
> Thanks, Jeremy Coulter
>
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
> Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/
>
>
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to