Solved

Copy, Paste and Select All

Posted on 2007-03-20
4
165 Views
Last Modified: 2010-04-05
Dear Experts,

I have a procedure that select all text of a canvas when
the user select menu-item Select All and a procedure when
the user select the text with the mouse (rubberband rectan-
gle). And a procedure to Copy the text to the clipboard and
a procedure to paste text from Clipboard into the canvas.

These procedures works all fine, but now I have to programm
the menu-items in the procedure Edit1Click. Can someone
help me?

It has to be something like this:

if SocOpen := false then       (there is no connection)
                 Copy1.Enabled := False;
                 Paste1.Enabled := False;
                 SelectAll1.Enable := False;

If SocOpen := true then      (there is a connection)
                 SelectAll1.Enable :- True;
   
 If there is text in clipboard
                   Paste1.Enabled := True;
 If there is no text in clipboard
                   Paste1.Enabled := False;

 I believe this the code for it:
    Paste1.Enabled := Clipboard.HasFormat(CF_TEXT);

If there is a selection made by choosing menu-item Select All
or with the mouse:
 
Copy1. Enabled := True

If the user choose Copy then
Paste1.Enabled := True;

Can someone help me?

procedure TForm1.Edit1Click(Sender: TObject);
begin
    //
end;
(*-----------------------------------------------------*)
procedure TForm1.Copy1Click(Sender: TObject);
var
  i, j: integer;
  s: string;
begin
  s := '';
  for i := 1 to SCRROWS do
  begin
    for j := 1 to SCRCOLS do
      if (ScrBuf[i, j].Hilite = Char(chReverse)) and
        (ScrBuf[i, j].Data in ['A'..'Z', 'a'..'z', '0'..'9', ' ',
        ',', '!', '@', '#', '$', '%', '^', '&', '*', '(', '[', ']', ')',
          '<', '>', ';', ':', '=', '-', '.', '/', '\', '+', '"', '|']) then
        s := s + ScrBuf[i, j].Data;
    if s <> '' then s := s + #13#10;
  end;
  with Clipboard do
  begin
    open;
    astext := s;
    close;
  end;
end;
(*-----------------------------------------------------*)
procedure TForm1.Paste1Click(Sender: TObject);
var
  i, j, k: integer;
  ch: char;
  s: string;
begin
  with Clipboard do
  begin
    open;
    s := astext;
    close;
  end;
  k := 1;
  for i := 1 to SCRROWS do
    for j := 1 to SCRCOLS do begin
      if ((j > CsrCol) and (i >= CsrRow)) or (i > CsrRow) then begin
        if Length(s) >= k then begin
          ch := s[k];
          ScrBuf[i, j].data := ch;
          k := k + 1;
        end;
      end;
    end;
  ShowBuf;
end;
(*-----------------------------------------------------*)
procedure TForm1.SelectAll1Click(Sender: TObject);
var
  i, j: integer;
begin
  for i := 1 to SCRROWS do
    for j := 1 to SCRCOLS do
    begin
      if ScrBuf[i, j].Data = '' then
        ScrBuf[i, j].Data := ' ';
      ScrBuf[i, j].Color := Char(ccWhite);
      ScrBuf[i, j].Hilite := Char(chReverse);
    end;
  showbuf;
end;
(*-----------------------------------------------------*)

Peter Kiers

0
Comment
Question by:peterkiers
  • 3
4 Comments
 
LVL 1

Author Comment

by:peterkiers
ID: 18759242
I don't get any further than this:

procedure TForm1.Edit1Click(Sender: TObject);
begin
  if SocOpen = false then
  begin
  Copy1.Enabled := False;
  Paste1.Enabled := False;
  SelectAll1.Enabled := False
  end
  else begin
    Copy1.Enabled := True;
  Paste1.Enabled := Clipboard.HasFormat(CF_TEXT);
  SelectAll1.Enabled := True;
  end;
end;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 18759287

procedure TForm1.Edit1Click(Sender: TObject);
var
  i,j : integer;
begin
  if SocOpen = false then
  begin
  Copy1.Enabled := False;
  Paste1.Enabled := False;
  SelectAll1.Enabled := False
  end
  else begin
   //here must be the line if the text is selected then...
    Copy1.Enabled := True
    else Copy1.Enabled := False;
  Paste1.Enabled := Clipboard.HasFormat(CF_TEXT);
  SelectAll1.Enabled := True;
  end;
end;
0
 
LVL 10

Accepted Solution

by:
dinilud earned 500 total points
ID: 18762248
procedure TForm1.Edit1Click(Sender: TObject);

 function IsTextSelected:Boolean ;
 var i,j:Integer;
 begin
   Result:=False;
   for i := 1 to SCRROWS do
   begin
      for j := 1 to SCRCOLS do
        if (ScrBuf[i, j].Hilite = Char(chReverse)) and
          (ScrBuf[i, j].Data in ['A'..'Z', 'a'..'z', '0'..'9', ' ',
           ',', '!', '@', '#', '$', '%', '^', '&', '*', '(', '[', ']', ')',
            '<', '>', ';', ':', '=', '-', '.', '/', '\', '+', '"', '|']) then
        begin
           Result:=True;
           Break;
        end;
      if Result then Break;
   end;
 end;

begin
  if SocOpen = false then
  begin
    Copy1.Enabled := False;
    Paste1.Enabled := False;
    SelectAll1.Enabled := False
  end
  else
  begin
    Copy1.Enabled := IsTextSelected;
    Paste1.Enabled := Clipboard.HasFormat(CF_TEXT);
    SelectAll1.Enabled := True;
  end;
end;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 18766426
Thank you for the help

Greetings,

Peter Kiers
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now