How can I copy a selected list item into the clipboard?

Started by simonst, March 11, 2009, 01:45:52 AM

Previous topic - Next topic

simonst

Hello, in many examples for coding in masm32 I have found a detailled description how
to build a small application that contains a simple listbox. If the user (double)click
on a list item, it is presented in a Message Box.
My question is: how can I copy this selected item into the clipboard instead of presenting
it in a message box???

....example:

.....

.if uMsg == WM_CLOSE

     .elseif uMsg == WM_LBUTTONDBLCLK
        invoke SendMessage,hWin,LB_GETCURSEL,0,0
        mov IndexItem, eax
        invoke SendMessage,hWin,LB_GETTEXT,IndexItem,ADDR Buffer  ; item is now in Buffer

        [copy to clipboard, maybe useful for inserting it later into a texteditor or an input field]

.....

Thanks for any help, best regards
Stefan

MichaelW

Assuming that the item is text, there is a commented example here:

http://www.masm32.com/board/index.php?topic=3879.msg28908#msg28908

And for MASM32 v10 the MASM32 library includes procedures for getting and setting clipboard text, see \masm32\m32lib\getcbtxt.asm and \masm32\m32lib\setcbtxt.asm

eschew obfuscation

Bill Cravener

My MASM32 Examples.

"Prejudice does not arise from low intelligence it arises from conservative ideals to which people of low intelligence are drawn." ~ Isaidthat

PBrennick

simonst,

In the library included with GeneSys, there is:

GetClipboardTextA
GetClipboardTextW

SetClipboardTextA
SetClipboardTextW

hth,
Paul
The GeneSys Project is available from:
The Repository or My crappy website

simonst

WOW!!!! Thank You all, great examples! I have tried it out, it works fine!!!!!!
Best Regards,
Stefan :U