The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: akalenuk on July 12, 2006, 02:53:52 PM

Title: Clipboard handling.
Post by: akalenuk on July 12, 2006, 02:53:52 PM
How can i store a simple test string in the clipboard?
Title: Re: Clipboard handling.
Post by: arafel on July 12, 2006, 03:13:26 PM
OpenClipboard, SetClipboardData
Title: Re: Clipboard handling.
Post by: akalenuk on July 12, 2006, 03:43:46 PM
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.
Title: Re: Clipboard handling.
Post by: P1 on July 12, 2006, 03:53:13 PM
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)
Title: Re: Clipboard handling.
Post by: akalenuk on July 12, 2006, 04:03:28 PM
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.
Title: Re: Clipboard handling.
Post by: P1 on July 12, 2006, 04:59:16 PM
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)
Title: Re: Clipboard handling.
Post by: Ehtyar on July 12, 2006, 09:52:43 PM
If it's an editbox, send it WM_COPY.
Title: Re: Clipboard handling.
Post by: akalenuk on July 13, 2006, 02:07:55 PM
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.

Title: Re: Clipboard handling.
Post by: Ehtyar on July 13, 2006, 11:18:37 PM
Then as mentioned in previous posts, use OpenClipboard, and SetClipboardData. If you need some help with these, see Using the Clipboard (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard/usingtheclipboard.asp) on MSDN.
Title: Re: Clipboard handling.
Post by: 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

Title: Re: Clipboard handling.
Post by: akalenuk on July 14, 2006, 12:59:48 PM
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?