|
-
Apr 10th, 2001, 06:27 PM
#1
Thread Starter
Hyperactive Member
THe result of this is nothing
Im not good at handling strings in array's but from the reference i've looked at this should work. I suspect the problem is in the last parameter of sendmessage, but have tried many combination and nothings worked!!
Code:
num = SendMessage(hwndlist, LB_GETCOUNT, 0, 0);
char buffer[num];
for(i=0;i<num; i++){
SendMessage(hwndlist,LB_GETTEXT, i,(LPARAM)buffer[i]);
MessageBox (NULL, buffer , "message", 0);
fputs(buffer, fp);
fprintf(fp, "\n");
}
Thanks for your help.
Matt 
-
Apr 10th, 2001, 07:07 PM
#2
Monday Morning Lunatic
char only holds a single character, not a string. You'd need something similar to:
Code:
num = SendMessage(hwndlist, LB_GETCOUNT, 0, 0);
char *buffer[num];
for(i = 0; i < num; i++) {
long lLen = SendMessage(hwndlist, LB_GETTEXTLEN, i, 0);
buffer[i] = new char[lLen+1]; // Include space for terminator
SendMessage(hwndlist, LB_GETTEXT, i, (LPARAM)buffer[i]);
MessageBox (NULL, buffer[i], "message", 0);
fprintf(fp, "%s\n", buffer[i]);
}
for(i = 0; i < num; i++) {
delete[] buffer[i];
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|