Announcement

Collapse
No announcement yet.

Clipboard functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Semen Matusovski
    replied
    Lance --
    I imagine, what PB does, but I have no wish to use MASM.

    I posted a sample in "Source code forum".

    [This message has been edited by Semen Matusovski (edited May 03, 2000).]

    Leave a comment:


  • Lance Edmonds
    replied
    What do you imagine those COM objects and "IPicture" controls do internally?

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    I guess, that Windows system programs use IPicture enough intensive.
    I saw some samples for VB.
    In PB it's not very simple (COM is COM), but if to have a great wish ...



    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    > All that remains is to submit the final bitmap (...) across
    > to the clipboard, and provide any necessary bitmap headers
    > that may be necessary.

    Not to mention the fact that you must create a memory object that you can "give" to the clipboard, because the clipboard takes ownership of everything that is sent there, so you must not destroy it after you have sent it.

    And those bitmap headers will drive you crazy! The format will vary wildly, depending on the "color depth" of the screen, the video driver, the operating system (95/98 vs. NT/2000) and other things.

    I recently added clipboard functions to Graphics Tools (including support for saving/loading "areas") and I can tell you that it is not easy!

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Lance Edmonds
    replied
    keybd_event is not 100% guaranteed to be reliable in most situations where sending keystrokes to application windows, but you could get away with it in this case (assuming that the %VK_SNAPSHOT code still works even if the owning application loses focus before it fires). However, Anand wants to copy & paste only a section of the target window.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    It's very easy to copy whole screen to clipboard
    Code:
        keybd_event %VK_SNAPSHOT, MapVirtualKey(%VK_SNAPSHOT, 0), 0, 0: Sleep 0
         keybd_event %VK_SNAPSHOT, MapVirtualKey(%VK_SNAPSHOT, 0), %KEYEVENTF_KEYUP, 0: Sleep 0
    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    While your descriptions makes the job sound easy, the implementation is very complex. The following is one way (it may not be the best way, but it should work - there are shortcuts that you can take to accomplish the same task, but doing it the long way is a very useful learning exercise!).

    First, you need to be able to "draw" a dotted region on the target window. This involves detecting a mousedown event, and capturing the cursor. At the same time, you need to capture mousemove events and draw a region outline (so the use can see what is being selected), whilst removing the last drawn line each time the mouse position moves. This gives the visual effect of dragging a focus rectangle in the target window. Drawing the rectangle is usually done with DrawFocusRect() API.

    Next, when the mouseup event occurs, you need to release the mouse capture. You'll have to handle the case where the use presses the ESC key, or does a task-switch, etc.

    Then, you need to get the DC to the target window, create a hidden DC (using CreateCompatibleDC, etc) based on the target window's DC, and then create a bitmap of the desired size and select it into the hidden DC. This gets you a "blank" bitmap of the desired size, ready to receive the bitmap bits from the target window.

    Finally, you use BitBlt() to transfer the bitmap bits from the target window to the DC, using the rectangle that you marked out with the mouse.

    All that remains is to submit the final bitmap (now located in the hidden DC) across to the clipboard, and provide any necessary bitmap headers that may be necessary.

    Still interested in pursuing this project?

    Charles Petzold's "Programming Windows" contains all of the information you'll need to accomplish this task... it is certainly beyond the scope of this forum to go through the process at a deeper level, unless you can convince some the great GUI guru's here to write the code for you.

    Seriously, my advice is to get the book (or one of the others we recommend in the FAQ forum), and use this project as a learning experience... you'll be amazed at the level of understanding you'll gain by writing this application, and you'll gain expert skills in GUI programming!

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Anand Kumar
    started a topic Clipboard functions

    Clipboard functions

    Hello all,

    I am developing a CAD product much like autocad.
    I want to cut some area from my screen (the data format is local and is not the standard Bmp / Jpeg / Tiff file formats) and transfer the data to the clipboard. Now when I paste this data in Paint Brush or Word, I want my data to be displayed. How do I do it. I have been playing around with the Api but couldn't find it. Is there any way to do it.

    Bye

    -------------
    Anand Kumar
Working...
X