Solved

Copy, Paste and Select All

Posted on 2007-03-20
4
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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