Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


SendMessage & delete crashes..

This topic is 5585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Not very good with the Windows API and I''ve probably done something really stoopid.. This is a snippet from my app.
char *line;
len = SendMessage(GetDlgItem(g_hWnd, IDC_TABLE), LB_GETTEXTLEN, (WPARAM)i, 0 );
line = new char[len];

SendMessage(GetDlgItem(g_hWnd, IDC_TABLE), LB_GETTEXT, (WPARAM)i, (LPARAM)line );
fprintf( outfile, "%s\n", line );

delete [] line;
And it crashes something horribly at the delete operator, what am I doing wrong? -Luctus
Statisticly seen, most things happens to other people. [Mail]

Share this post

Link to post
Share on other sites
Are you sure it is delete that is causing the error? The only thing I can think of is that the listbox index you are passing might not be valid and so LB_GETTEXTLEN is returning LB_ERR which you aren''t checking for. I don''t know what LB_ERR is defined as, but if it is negative and you are using it to allocate memory with, well, fun things can happen .

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
LB_GETTEXTLEN: "The return value is the length of the string, in TCHARs, *excluding the terminating null character*"

LB_GETTEXT: "The buffer must have sufficient space for the string *and a terminating null character*"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!