The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: simonst on March 11, 2009, 01:45:52 AM

Title: How can I copy a selected list item into the clipboard?
Post by: simonst on March 11, 2009, 01:45:52 AM
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
Title: Re: How can I copy a selected list item into the clipboard?
Post by: MichaelW on March 11, 2009, 05:06:51 AM
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

Title: Re: How can I copy a selected list item into the clipboard?
Post by: Bill Cravener on March 11, 2009, 09:24:32 AM
And another example here: http://www.masm32.com/board/index.php?topic=9583.0
Title: Re: How can I copy a selected list item into the clipboard?
Post by: PBrennick on March 11, 2009, 12:04:41 PM
simonst,

In the library included with GeneSys, there is:

GetClipboardTextA
GetClipboardTextW

SetClipboardTextA
SetClipboardTextW

hth,
Paul
Title: Re: How can I copy a selected list item into the clipboard?
Post by: simonst on March 11, 2009, 12:16:57 PM
WOW!!!! Thank You all, great examples! I have tried it out, it works fine!!!!!!
Best Regards,
Stefan :U