Recent

Author Topic: [solved - partial] Clipboard clear not working in app  (Read 9324 times)

AlistairG

  • Jr. Member
  • **
  • Posts: 70
[solved - partial] Clipboard clear not working in app
« on: March 10, 2011, 10:10:48 pm »
Hi if I have something in the clipboard prior to app instantiation, then its showmessage below:

procedure Tmainform.FormCreate(Sender: TObject);
begin
clipboard.Clear;
clipboard.astext:=''; //should not be necessary but still doesnt work.
showmessage(clipboard.AsText); //still shows previous content!

Anyone can suggest what I am doing wrong?
Tks vm.
« Last Edit: March 11, 2011, 01:09:33 am by Alistair George/Laz 2.4 »
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Clipboard clear not working in app
« Reply #1 on: March 10, 2011, 10:22:39 pm »
It works for me (only clipboard.astext:='').

Lazarus 0.9.29 r28656 FPC 2.5.1 i386-win32-win32/win64

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Clipboard clear not working in app
« Reply #2 on: March 10, 2011, 10:25:28 pm »
It works for me.
Yes I made up another wee test program and it seemed to work there OK, but I cant for the life of me see where the previous clipboard info is reinstated during formcreate eg the line following clipboard.clear surely it should be clear at that point.
I'll keep trying and advise.
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Clipboard clear not working in app
« Reply #3 on: March 10, 2011, 10:43:56 pm »
Im going to have to stop editing my files before posting. Here is the original which did not clear:
procedure Tmainform.FormCreate(Sender: TObject);
begin
TrayIcon1.Icon.Assign(Application.Icon);
TrayIcon1.Show;
Application.OnHint := @ShowHint;
ShowScrollBar(listbox1.Handle, SB_BOTH, false);
clipboard.Clear;
clipboard.astext:='';
Listbox1.clear

//here is what works note the new position of clipboard.clear
procedure Tmainform.FormCreate(Sender: TObject);
begin
clipboard.Clear;
clipboard.astext:=''; //this is still required
TrayIcon1.Icon.Assign(Application.Icon);
TrayIcon1.Show;
Application.OnHint := @ShowHint;
ShowScrollBar(listbox1.Handle, SB_BOTH, false);
listbox1.Clear;
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Clipboard clear not working in app
« Reply #4 on: March 11, 2011, 01:06:19 am »
Anyone having probs with clipboard keep an eye on this one.
Clipboard.clear does not do the job if there is text on the clipboard. If you assign '' as text it then seems to remove CF_TEXT from the clipboard.
Suggest create your clipboard in formcreate eg myclipboard.create, even though you have access to a default board named clipboard, seems creation of a new object makes it work better.
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: [solved - partial] Clipboard clear not working in app
« Reply #5 on: March 11, 2011, 01:21:01 am »
Opening the clipboard before clearing it seems to work for me.

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: [solved - partial] Clipboard clear not working in app
« Reply #6 on: March 11, 2011, 07:27:05 am »
Opening the clipboard before clearing it seems to work for me.
Cheers Typo. What I am finding is that if I clipboard.open;clipboard.clear;clipboard.close;
Then try to use the clipboard as normal it does not behave. EG if I copy some text afterwards, then myapp will not see the copied text.
I have been having a lot of trouble with the clipboard over the last 2 days, which I never had before in delphi. Its either:
1..me
2..difference between gtk2 and windows
3..clipboard has some underlying problems.

Cheers,
Alistair.
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

 

TinyPortal © 2005-2018