Solved

Copy, Paste and Select All

Posted on 2007-03-20
4
176 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

Technology Partners: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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