News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Clipboard handling.

Started by akalenuk, July 12, 2006, 02:53:52 PM

Previous topic - Next topic

akalenuk

How can i store a simple test string in the clipboard?

arafel

OpenClipboard, SetClipboardData

akalenuk

Quote from: arafel on July 12, 2006, 03:13:26 PM
OpenClipboard, SetClipboardData
Yes, but how can i get a handler of the string? SetClipboardData demands handler, yet i have only an address.

P1

Reading the API documentation will take you a long way in getting it done.
Once SetClipboardData is called, the system owns the object identified by the hData parameter. The application can read the data, but must not free the handle or leave it locked. If the hData parameter identifies a memory object, the object must have been allocated using the GlobalAlloc function with the GMEM_MOVEABLE and GMEM_DDESHARE flags.MSDN website is a great tool as well.

Regards,  P1  :8)

akalenuk

Quote from: P1 on July 12, 2006, 03:53:13 PM
Reading the API documentation will take you a long way in getting it done.

"RTFM" is much shorter you know  :wink

Quote from: P1 on July 12, 2006, 03:53:13 PM
Once SetClipboardData is called, the system owns the object identified by the hData parameter. The application can read the data, but must not free the handle or leave it locked. If the hData parameter identifies a memory object, the object must have been allocated using the GlobalAlloc function with the GMEM_MOVEABLE and GMEM_DDESHARE flags.MSDN website is a great tool as well.

So i should alocate some memory, copy data and pass the handlet to SetClipboardData? Ok, i'll give it a try. Thanks.

P1

Quote from: akalenuk on July 12, 2006, 04:03:28 PM"RTFM" is much shorter you know  :wink
Read The Fine Manual is a cliché. 

Just remember to have the right format of data in the target of the data handle.

Regards,  P1  :8)

Ehtyar

If it's an editbox, send it WM_COPY.

akalenuk

Quote from: Ehtyar on July 12, 2006, 09:52:43 PM
If it's an editbox, send it WM_COPY.

The thing is, i don't have a window at all. I even open clipboard with zero handler. But thanks anyway.


Ehtyar

Then as mentioned in previous posts, use OpenClipboard, and SetClipboardData. If you need some help with these, see Using the Clipboard on MSDN.

MichaelW

eschew obfuscation

akalenuk

Quote from: MichaelW on July 14, 2006, 12:38:08 AM
The example here stores a string in the clipboard:

http://www.masm32.com/board/index.php?topic=3879.msg28908#msg28908
Thanks. I've allready done the same thing, it's fine. Yet i skipped all the testing after SetClipboardData, OpenClipdoard and GlobalAlloc. Are they really necessery?