?
Solved

Help with copy and paste.

Posted on 2001-06-14
11
Medium Priority
?
190 Views
Last Modified: 2010-04-06
0
Comment
Question by:pucko
[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
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6190488
What do you want exactly???
0
 
LVL 3

Expert Comment

by:MarcG
ID: 6190493
What do you need ?  for copy press CTRL + C and for paste CTRL + V.
??????????
0
 
LVL 3

Expert Comment

by:MarcG
ID: 6190510
What do you need ?  for copy press CTRL + C and for paste CTRL + V.
??????????
0
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!

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6190512
See this article maybe it what u r looking for

TCLIPBOARD.CUT-COPY-PASTE
http://delphi.about.com/compute/delphi/library/weekly/aa092199.htm

also this
Listening to the Clipboard
http://delphi.about.com/compute/delphi/library/weekly/aa110700a.htm

Best regards
Mohammed Nasman
0
 
LVL 3

Expert Comment

by:alzv
ID: 6190513
If you want to copy and paste something from your code, look at Clipboard object...
0
 
LVL 3

Expert Comment

by:MarcG
ID: 6190514
sorry for sending twice
0
 
LVL 1

Author Comment

by:pucko
ID: 6190531
Wtf... something went wrong with my submittion.
I had a hudreds of lines here.


I have A window (Say q_window)that I can open several instances of.
In the Window I have a treeView looking like this:


mother-node--|
             |
             |BlocksNode
                       |
                       |
                       |Block1
                       |     |
                       |     |
                       |     |-BlockItem1
                       |     |-BlockItem2
                       |
                       |Block2
                             |
                             |-BlockItem1
                             |-BlockItem2

It can contains dynamicly number of blocks and each block can contain dynamic number of BlockItems.


So I want to copy a whole Block to another q_window under The Blocks Node.

Each Block Has A Block_no so I have to go through The Target TreeView to find out the highest block_no in that Tree and set the BlockNo to that number+1 when I paste it.
The same for each BlockItem. (the BlockItem.block_no refers to which block it is related to.


I tried this: (so you can se what I try to do):



procedure TQuoteForm.Copy1Click(Sender: TObject);
begin
  if T
  Clipboard.SetComponent(TreeView1);
  RegisterClasses([TTreeview]);
end;

procedure TQuoteForm.Paste2Click(Sender: TObject);
var
  ThisComponent : TComponent;
  ThisTreeView : TTreeView;
  TmpBlockNode : TTreeNode;
  BlocksNode : TTreeNode;
  TreeNode : TTreeNode;
  no, ix : integer;
  ThisBlock : TBlock;
  tmpNode : TTreeNode;
  ThisBlockItem : TBlockITem;
begin
  if Clipboard.HasFormat(CF_COMPONENT) then
  begin
    ThisComponent:= Clipboard.GetComponent(self, self);
    ThisTreeView:= TTreeView(ThisComponent);
    ThisTreeView.Visible:= False;
    TmpBlockNode := TTreeView(ThisComponent).Selected;
    BlocksNode:= FindNode(TreeView1.Items[0],'TBlocksNode');
    no:= 0 ;
    for ix:= 0 to BlocksNode.Count-1 do
    begin
      if no < TBlock(BlocksNode.Item[ix].Data).block_no then
        no:= TBlock(BlocksNode.Item[ix].Data).block_no
    end;
    Inc(no);
    TreeView1.Items.BeginUpdate;
    ThisBlock := TBlock(TmpBlockNode.Data);
    with ThisBlock do
    begin
      quote_no:= Current_quote.quote_no;
      version:= Current_quote.version;
      alternate:= Current_quote.alternate;
      block_no:= no;
    end;
    TreeNode:= TreeView1.Items.AddChild(BlocksNode, RemoveTAB(RemoveCRLF(ThisBlock.header)));
    TreeNode.Data:= ThisBlock;
    TreeNode.ImageIndex:= tiFolder;
    BlocksNode.Expand(False);
    for ix := 0 to TmpBlockNode.Count-1 do
    begin
      ThisBlockItem:=TBlockITem(TmpBLockNode[ix].Data);
      ThisBlockItem.quote_no:=Current_quote.quote_no;
      ThisBlockItem.version:=Current_quote.version;
      ThisBlockITem.alternate:=Current_quote.alternate;
      ThisBlockItem.block_no:=no;
      tmpNode:= TreeView1.Items.AddChild(TreeNode, FormatArtNo(ThisBlockItem.art_no));
      tmpNode.Data:= ThisBlockItem;
      tmpNode.ImageIndex:= GetTreeImageByClass(ThisBlockItem.class1);
    end;
    TreeView1.Items.EndUpdate;
    UpdateListView;
    CalcBlockItemArrange;
    QuoteModified(True);
    TTreeView(ThisComponent).Free;
  end;
end;


0
 
LVL 3

Accepted Solution

by:
MarcG earned 1200 total points
ID: 6192810
what's wrong with your code ? didn't try it ... but one question, why are you using clipboard for this ? here's how i would try it :
you have a main window, and in this main window you create the q_windows. so all q-wins can access the main windows... i would make a public variable (maybe record) that when copying a block gets the source window and the block nr to copy. when pasting a block to another q_win this win gets the info from the main window. then you check the numbers and create new nodes with the right numbers in the target treeview.  
only the block nr is written in the public record, for creating the new nodes the infos are read directly from the source treeview.
0
 
LVL 1

Author Comment

by:pucko
ID: 6194020
The problem with my code is that when I do the paste thing
it still tries to use the TreeView that I copied.

SO if I Have 3 Blocks in the one that I try to copy from and none in the one I try to paste it into,
 this code:

BlocksNode:= FindNode(TreeView1.Items[0],'TBlocksNode');
   no:= 0 ;
   for ix:= 0 to BlocksNode.Count-1 do
   begin
     if no < TBlock(BlocksNode.Item[ix].Data).block_no then
       no:= TBlock(BlocksNode.Item[ix].Data).block_no
   end;
   Inc(no);

Gives me 3 blocks.

So It still thinks that I'm working with the treeView that I copied and not the one in the new window.

The second problem is that:

TmpBlockNode := TTreeView(ThisComponent).Selected;

Always becomes the Mother Node and not the one that I selected when I did copy.

I prefere to use the Clipboard for this but I don't know how to do. There should be some way to do this I think.

If I use your Idea MarcG, I cant close the window I copied from before I have paste it into the other, Right?

0
 
LVL 3

Expert Comment

by:MarcG
ID: 6196658
yes, with that you are right ...or you have to copy the data needed in some temp variables then you can close the window and still copy the files.
make a record with the data needed for one node and then make a dynamic array of this record. when copying first put all the data there and when pasting read it from there.
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 9285972
pucko,
No comment has been added lately (811 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to MarcG http:#6196658

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

DragonSlayer
EE Cleanup Volunteer
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

801 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