Jump to content
  • Advertisement
Sign in to follow this  
Tjaalie

mmm... i don't understand

This topic is 4836 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

Hello to all, Im making an editor for my 2d game engine. And when i use the below listen code it crashes before the second messagebox.
	//Vars
	char* TempString = NULL;
	
	//Something to do??
        MessageBox(NULL, "1", "", 0);
	if (ResourceList == NULL)
	{
		return;
	}
	
	//Loop trough the resources and add them if right type
        MessageBox(NULL, "2", "", 0);
	for (int i=0;i<NumResource;i++)
	{
		//Right type
		if (ResourceList.Type == type)
		{
			//Rip name
			TempString = new char[ResourceList.Length+1];
			memcpy(TempString, &Buffer[ResourceList.Offset], ResourceList.Length);
			TempString[ResourceList.Length+1] = 0;
			
			//Add him to the list box
			SendMessage(hwnd, LB_ADDSTRING, 0, (LPARAM)TempString);
		}
	}



Anyone got an idea why???

Share this post


Link to post
Share on other sites
Advertisement
Is ResourceList NULL? If not, then all I can think is that the this pointer is invalid.

Have you tried doing "Rebuild all", or a clean build?

Share this post


Link to post
Share on other sites
Quote:
Original post by Tjaalie
But i can't see the second messagebox at all so the
code crashes before.

You have to be really careful working with Win32 dialog functions (including MessageBox()), because they don't necessarily run when you think they will, display when you think they will, or close when you think they will. It appears you're using it to "debug" your program, but this is definitely not a good idea. I would suggest using a real debugger (you have one unless you're using gcc from the command line or vctoolkit2003 from the command line), which will show you exactly which line of code the problem is at.

Share this post


Link to post
Share on other sites
Yes, Code::Blocks has a built in debugger. To use it:
1. Under your Project Build Options, turn on Produce debugging symbols
2. Use the Debug command under the Debug menu to run your program in Debug mode
3. When it crashes, it'll take you straight to the line of code that caused it
4. If the code is in a library or somewhere else, you can open the backtrace window (Debug -> Debugging windows -> Backtrace) and see the functions that were called leading up to it

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!