Notifications
Clear all
[Closed] How to setup LB_GETTEXT??
Page 2 / 2
Prev
Mar 07, 2011 1:06 pm
I’ve double-checked what returns with LB_GETTEXT message. It’s c-style string (chars + null terminator) . So we have to allocate one char more memory then length of the listbox item text.
finally:
fn getListBoxText hWnd i =
(
LB_GETTEXT = 0x189
LB_GETTEXTLEN = 0x18A
marshal = dotnetclass "System.Runtime.InteropServices.Marshal"
len = windows.sendmessage hWnd LB_GETTEXTLEN i 0
lParam = marshal.AllocHGlobal (marshal.SystemDefaultCharSize*(len+1))
windows.sendmessage hWnd LB_GETTEXT i lParam
ptr = dotnetobject "System.IntPtr" lParam
str = marshal.PtrToStringAnsi ptr
marshal.FreeHGlobal ptr
str
)
Page 2 / 2
Prev