VC++ 2010 crashes on ShowWindow(..)

Started by
19 comments, last by wintertime 11 years, 1 month ago
While I do not know the default value for nCmdShow try displaying your window using SW_SHOW (Also seen here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx).

If nCmdShow is uninitialized, which it could or could not be honestly I have never checked, you would get an error with your program. If that doesn't help - sorry :P
Advertisement

According to MS, that parameter should be taken from WinMain parameter. I tried it anyway. Same issue.

Post your WndProc.

Actually make a new project and paste your code there and then post the entire code if it still crashes, don't include stuff that isn't used. Perhaps you use something from WndProc that isn't created yet. Try putting ShowWindow right before the main-loop after D3D is set up etc.

That's what I did. Just finished cleaning it up so it would work. It runs but that doesn't explain what caused the issue in the first place.....

Just guessing unless you post the whole code in its entirety, but when you call ShowWindow it will call your WindowProc with a couple of messages, and perhaps the D3D device was used there, before it was initialized, or similar.

I don't have the code that isn't working. I moved all my files into another project and I got it to work. That's actually funny: the "solution" was the "problem"....biggrin.png


Access violation reading location 0x00000000

You've a NULL pointer somewhere that you're trying to use. Again, this is something that your debugger will tell you. At this stage you're getting into fairly basic stuff and essentially asking us to debug your code for you. I don't mean to be rude here, but you're really not showing many signs of trying very hard - or at all - yourself. If you had run this in your debugger it would have halted execution at the offending line, enabling you to determine exactly what has happened. If you had been using your debugger you would have stepped through line-by-line and found what you were doing wrong. Which leads me to suspect that you haven't.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I did run the debugger. The "offending line" had something to do with the exit of the program. That didn't tell me anything. The problem was some kind of corruption in my VC++ solution file. When I started over with a new solution, the problem went away. Debug will only show me the answer if the problem is in my program. This went beyond that, so to say I wasn't trying is a bit insulting.

A general advice from my experience as a programmer: every time I think the compiler/the framework is wrong, it always turns out *I* did something wrong.

In C++ Win32/COM programming, you have to understand the error model, which is quite different from the easy-peasy world of .NET/Java. As others said before, CreateWindow/CreateWindowEx can fail for many reasons - most probably because of incorrect arguments or WinProc. In the first case, GetLastError() and Google would help you, and in the case of WinProc - a few well-placed breakpoints at key messages would pin-point the problem. You should also absolutely always check return codes... this isn't Java/.NET where something crashes with a nice exception - return codes and/or GetLastError() are the way.

I get your point. The thing is, I took my original code files and put them into a new project and it worked fine. The problem started when I transferred my project from one computer to another, something happened..... Maybe there was something wrong with the project/solution or I had some update issues with the new computer/compiler that caused it. So ultimately this problem WAS something other than my program.

This topic is closed to new replies.

Advertisement