-
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.
-
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];
}