IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

[Update: de-encrypted attachment, please try again! Sorry...]
Someone asked in the Notes 6/7 Forum about a way to take screenshots off the clipboard and turn them into file attachments. I responded with a rough outline of a solution, but this is the sort of interesting problem that bugs me until I have working code. So, rather than leave it at that, I paid little attention to M. Hercule Poirot on TV as I slapped together some bits I already had, with a little new glue, and voila! Snap a screenshot, click this toolbar icon from any rich text field, and you get a file attachment in the rich text. The image files, of course, are not left behind to clutter up your disk.

The zipped attachment contains one NSF file. Put it in your local Notes data directory, and open it once. It will record its location in an INI variable so that the toolbar button can find it later. The About document contains the formula for the toolbar button (the Text Properties toolbar might be a good place for it).

Just to make it clearer what this does for you: I use a screenshot tool to capture a rectangle from my screen:

sampleScreenshot.gif

I put the cursor in a rich text field, and click the handy little toolbar icon:

toolbarImageClip.gif

I am prompted for a filename for the attachment:

promptForImageFilename.gif

A file attachment magically appears at the cursor location.

voilaAttachment.gif

And if I use the View function I can see the original screenshot.

Here's the zipped database: ImagePasteAttach.zip

I designed this so that you could add it to an application fairly easily, in case you have a database that has a lot of pasted graphics and you want to have this feature in it. The application uses three forms, including one that's opened in a dialog, one that launches the dialog, and one that cleans up the temporary files afterward. I had to do this to make the "use from anywhere" part work, but if it's part of your application, you only need one form; you can open the dialog with an agent instead of composing a "launcher" document, and run another agent for cleanup after you create the attachment(s).

Incidentally, if you already have a screenshot that was pasted into a document and you want to convert it to an attachment, this will also work for that -- just copy it from the Notes rich text and click the toolbar. You can do several images at a time this way if you don't mind them having the same filenames with consecutive numbers added.

Andre Guirard | 13 February 2008 03:15:00 AM ET | Home, Plymouth, MN, USA | Comments (11)

Search this blog 

Disclaimer 

    About IBM Privacy Contact