Recent

Author Topic: Clipboard actions to multiple controls and types : How?  (Read 272 times)

zxandris

  • Full Member
  • ***
  • Posts: 154
Clipboard actions to multiple controls and types : How?
« on: April 26, 2025, 04:16:53 am »
Okay, here's my issue.  I've set up an action hooked to CTRL+V, for instance, for paste, which will now only paste into a memo.  But there are multiple controls on that form that I would like to paste with the shortcut key.  Now, outside of using ActiveControl and checking every name, is there a way I can paste to any viable control that is focused?

This is something I would love to be able to do with any of the clipboard actions, and potentially others, too.  Is there a nice way of doing this? Can I, cast to a class that won't crash for any TEdit, TMemo, TSynEdit, and File edit controls and trigger its built-in action.  This is one for the knowledgeable here, I think.

Thanks in advance,

CJ

jamie

  • Hero Member
  • *****
  • Posts: 6888
Re: Clipboard actions to multiple controls and types : How?
« Reply #1 on: April 26, 2025, 11:29:28 am »
Lookup WM_PASTE mrssage and related
The only true wisdom is knowing you know nothing

cdbc

  • Hero Member
  • *****
  • Posts: 2124
    • http://www.cdbc.dk
Re: Clipboard actions to multiple controls and types : How?
« Reply #2 on: April 26, 2025, 12:13:09 pm »
Hi
Remove your 'Ctrl+V'-action and let the controls handle it themselves...?!?
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

zxandris

  • Full Member
  • ***
  • Posts: 154
Re: Clipboard actions to multiple controls and types : How?
« Reply #3 on: April 26, 2025, 02:48:28 pm »
Okay thanks people for replying.

Thanks "jamie" I went searching on WM_Paste and it provided the solutions to my woes or rather https://dsiders.gitlab.io/lazdocsnext/lcl/lclintf/sendmessage.html did.

I couldn't just let the controls handle themselves for that action or rather remove my shortkey because I have special handling so what I did in the end was check ActiveControls name field for my three specials, or rather it wasn't then and instead I :-

Code: Pascal  [Select][+][-]
  1.      if ActiveControl<>nil then
  2.      begin
  3.           try
  4.              if (ActiveControl.Name<>'memEdit') and (ActiveControl.Name<>'synEdit') and (ActiveControl.Name<>'lvList') then
  5.              begin
  6.                   SendMessage(ActiveControl.Handle, WM_Paste, 0, 0)
  7.              end else
  8.              begin
  9.                  // Special
  10.              end;
  11.          except
  12.             // Error Handling
  13.          end;
  14. end;
  15.  

Basically rather cut down that's what I did.  Feels oddly clunky but it does work.  For anyone that is in a similar situation that was the solution thanks to those above this message.

Thank you!

CJ

 

TinyPortal © 2005-2018