Hey, was wondering if anyone could help me accomplish getting a selection from a list box to copy to the clipboard.

I've tried

invoke OpenClipboard,hWin
invoke EmptyClipboard

and then a bunch of stuff with SetClipboardData and some other stuff (figured id try to get it to work before asking questions)

so yeah if anyone could help that would be great.
Posted on 2004-08-07 03:37:29 by cre
Have you ever tried LVM_GETNEXTITEM with LVNI_SELECTED flag?


Ignore! I was thinking of listview! Sorry!

/siddhartha
Posted on 2004-08-07 10:13:07 by siddhartha
Hi,

First you need to get the text from the listbox then copy it to the clipbard:

; Find the length of the string

invoke SendMessage, [hListbox], LB_GETTEXTLEN, [nItem], 0
inc eax
mov [nLen], eax
invoke OpenClipboard, [hWin]
or eax,eax
jz >>.DONE
invoke EmptyClipboard
invoke GlobalAlloc,GMEM_MOVEABLE + GMEM_ZEROINIT, [nLen]
mov [hClipData],eax
invoke GlobalLock,[hClipData]
invoke SendMessage, [hListbox], LB_GETTEXT, [nItem], eax
invoke GlobalUnlock,[hClipData]
invoke SetClipboardData, CF_TEXT, [hClipData]
invoke CloseClipboard
.DONE
Posted on 2004-08-07 11:02:27 by donkey
Oh, and before the inevitable next question, "how do I get the text from the clipboard ?", here's the answer:

invoke IsClipboardFormatAvailable, CF_TEXT

or eax,eax
jz >P2
invoke OpenClipboard, [hWin]
or eax,eax
jz >P2
invoke GetClipboardData, CF_TEXT
or eax,eax
jz >P1
push eax
invoke GlobalLock,eax
; ############
; EAX points to the text buffer, do what you want with it here
; ############
pop eax
invoke GlobalUnlock,eax
P1:
invoke CloseClipboard
P2:
Posted on 2004-08-07 11:22:05 by donkey
alright man thanks, I'll inform you how it went when I get back on my own computer
Posted on 2004-08-07 14:34:38 by cre