|
-
Nov 2nd, 2002, 04:24 PM
#1
Thread Starter
Frenzied Member
How do i Buffer? (LB_GETTEXT)
I have no clue how to STRING BUFFER for lets say a LB_GETTEXT, SendMessage API Read Below:
Can someone tell me whats wrong with this:
Code:
case ID_GETLIST:
{
char *ListSel;
PSTR ListStr;
int x;
x = SendMessage(list,LB_GETTEXTLEN,0,0);
ListStr = (PSTR) VirtualAlloc((LPVOID) NULL,
(DWORD) (x + 1), MEM_COMMIT,
PAGE_READWRITE);
SendMessage(list,LB_GETTEXT,0,ListStr);
//GetWindowText(edit, ListStr,x + 1);
ListSel = ListStr;
SetWindowText(edit,ListSel);
}
i get this error but im not sure how to use a nuffer i hjust Copyed it and Pasted it
and then edited it. Is it correct?
Error
Code:
--------------------Configuration: Win32Controls - Win32 Debug--------------------
Compiling resources...
Compiling...
WinMain.cpp
E:\Files\w32sk\WinMain.cpp(159) : error C2664: 'SendMessageA' : cannot convert parameter 4 from 'char *' to 'long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
Win32Controls.exe - 1 error(s), 0 warning(s)
- JayWare
Live to love. Not to Hate
Im to busy to have a site. But I got one and still working on it.
http://dre3k.net/
-
Nov 2nd, 2002, 06:15 PM
#2
As far as I can tell there is nothing wrong with this code. You need to use a cast:
Code:
SendMessage(list,LB_GETTEXT,0,(LPARAM)ListStr);
Also, don't forget to free the memory you allocated for the string. Use VirtualFree (since you used VirtualAlloc to allocate it)
-
Nov 4th, 2002, 12:44 PM
#3
Use HeapAlloc or new for such small amounts of memory, VirtualAlloc is meant for 16k and up.
I'm saying it again, you'd be better off with console.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|