My program keeps crashing when not in debugging mode. So now i'm debugging manually, or well, log everything to find where it is crashing

Oldproc = (PROC)SetWindowLong(Childs[1], GWL_WNDPROC, (DWORD)EditProc);
	cout << "Oldproc\n";
	SetFocus(MainWnd);

	cout << "SetFocus() Done\n";

	cout << "DIRECTX:\n";
	DirectX		= new DIRECTX(); // Creating DirectX
	cout << "DirectX = new DIRECTX(MainWnd);\n";
	Background	= new CHARACTER("Background"); // Creating background
	cout << "background\n";
	Player1		= new CHARACTER("Player"); // Creating Player
	cout << "player1\n";
	Notices		= new CHARACTER("Notice");
	cout << "notice\n";

Due to that, I know that the error is somewhere in the DirectX Class.
But the strange thing is, the last message I get is

DIRECTX:

And no more. I should get some more because it is not possible that the function begins and immidiatly crashes without doing anything:

DIRECTX::DIRECTX(HWND Window) {      
	cout << "DIRECTX::DIRECTX\n";
	this->counter		= 0;
	cout << "DIRECTX::counter\n";
	this->DXWindow		= Window;
	cout << "DIRECTX::DXWindow\n";
	this->Interface		= 0;
	cout << "DIRECTX::Interace\n";
	this->Device		= 0;
	this->Sprite		= 0;

	InitInterface();
	cout << "DIRECTX::InitInterface();\n";
	InitDevice();
	cout << "DIRECTX::InitDevice();\n";
	InitSprite();
	cout << "DIRECTX::InitSprite();\n";

}

Someone got an idea on what is happening? T_T. I'm almost killing myself, but I really want to finish the game before that XD!

Recommended Answers

All 6 Replies

My program keeps crashing when not in debugging mode. So now i'm debugging manually, or well, log everything to find where it is crashing

DirectX		= new DIRECTX(); // Creating DirectX

is not calling :

DIRECTX::DIRECTX(HWND Window)

but

DIRECTX::DIRECTX()

so we can't see where the problem is.
There may also be issues in calling your variable & class directX, etc

is not calling :


but

DIRECTX::DIRECTX()

so we can't see where the problem is.
There may also be issues in calling your variable & class directX, etc

Woops that is an error. I changed it to test if it maybe calls the DIRECTX::DIRECT() instead of DIRECTX::DIRECTX(HWND Window) =P. -edits-


edit: Damn can't edit the post anymore >_>.
Anyway it has to be

DirectX = new DIRECTX(MainWnd);

I know absolutely nothing about win32API and DirectX but...

The keyword "new" generates a pointer to the specified class. How is the variable DirectX defined? Is it some sort of pointer, and if so, is it the correct type of pointer?

Oldproc = (PROC)SetWindowLong(Childs[1], GWL_WNDPROC, (DWORD)EditProc);

You might want to check that SetWindowLong() actually succeeds. And while you are at it, you might switch to SetWindowLongPtr() altogether (it supersedes the former).

I know absolutely nothing about win32API and DirectX but...

The keyword "new" generates a pointer to the specified class. How is the variable DirectX defined? Is it some sort of pointer, and if so, is it the correct type of pointer?

DIRECTX* DirectX = 0;

Its defined like that.

You might want to check that SetWindowLong() actually succeeds. And while you are at it, you might switch to SetWindowLongPtr() altogether (it supersedes the former).

Its succeeds.

But I know where the error is, I just don't know WHY it is there. I mean,

DirectX = new DIRECTX(MainWnd);

Should call the constructor. But the constructor is not doing anything yet and it already crashes.

without seeing your exact code there is some guess work involved.

If you put your call to new int a try catch block you might get a clearer answer as to where the error is coming.

DirectX is already a class that is known somewhere to visual studio and although I think you probably don't have a conflict it is possible that you are not using the class that you have defined.

Is there a reason why you have your own class called DIRECTX ?

If not try renaming it and the variable DirectX . I am not familiar enough with microsoft directX to know if you have a potential naming conflict but it is something to consider. This is something to be careful of with all your variable names.

Your DIRECTX constructor uses a this pointer, which could cause confusion, why not just have

counter = 0;

etc.

The other things that could be happening.

- cout - may not be writing from the call to DirectX
- Does your directX inherit - if so it is calling the base constructor and this might require that your window is valid.

If you try commenting out everything other than the first cout what happens?

DIRECTX* DirectX = 0;

Its defined like that.


Its succeeds.

But I know where the error is, I just don't know WHY it is there. I mean,

DirectX = new DIRECTX(MainWnd);

Should call the constructor. But the constructor is not doing anything yet and it already crashes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.