views:

276

answers:

5

I want to implement copy, cut and paste in my drawing program (copy part of an image that is selected)

I don't know how to start

Any Ideas?

A: 

to copy: take the selected rectangle, create a new image of that size, take a copy of the current image and place it on the new rectangle, offset by the topleft of the selected rectangle

Luke Schafer
A: 

in short there are two ways exists

1) your own clipboard 2) system-wide clipboard

in second case use must use standard format for storing your data. read MSDN for more information about windows clipboard

or you can maintain two clipboards - own and system. then in your clipboard you can store specific information for your application and in system cliboard just image

Trickster
A: 

Here are some global points that will drasticly speed up your issues that you'll be facing.

Try to search for reversible line / rubberband. to make selections in the picture. Try to search for LockBits in VB .NET , to create a fast way of reading and writing pixels. Try to learn background thread , and report progress. For per pixel operations that take a long time. Try to make a MDI. With enough status bars to report the status. Try to serialize to xml/binary when saving a project-file to disk (like a psd for example). This could also be handy , for creating a undo function.

A: 

see this one...

http://www.wallpaperama.com/forums/javascript-copy-selected-text-box-select-all-highlight-text-form-copy-paste-t706.html

but for firefox its not working. am also searching for similar one. will post if i get more.

Say
A: 
  1. Use the system-wide clipboard, just in case the user copy in one instance on your app and paste in another, or if the user close the window and re-open it, he can paste back the data.
  2. Inherit all the shapes of the program from a base class that implements the copy & paste.
  3. For copy (or cut), serialize the object and place it in the system clipboard.
  4. For paste, read the system clipboard and try to de-serialize back to a shape object (if the cast fails, the clipboard content was not an object of your app)
  5. Move the position of the pasted shape slightly to the left and bottom (to let the user know that there is a new shape in the drawing)
Eduardo Molteni