You really need to be more careful with your casting. First of all, if you're using C++ then you'll want to ditch the C-style cast. C++ has
casting operators that can prevent mistakes and make your code easier to understand.
Having said that,
don't cast function pointers unless you're 1000% sure you know what you're doing. Casting a function pointer has the possibilty to cause some insanely bizarre errors if you do it wrong. In your case you should have no reason to do it: the signature of your Window_Procedure function should match that of WNDPROC and you should have no problem assigning it to your WNDCLASSEX struct. If you take away the cast and it doesn't compile, then you screwed up the function signature and you should figure out what you did wrong.
The reason your MessageBox for displaying the error code isn't working is again because of casting.
GetLastError returns a
DWORD, which is a typedef of an unsigned long. In other words, it returns an unsigned 32-bit integer. MessageBox (or actually,
MessageBoxW) on the other hand takes an
LPCWSTR, which is a typedef for "constant wchar_t*"...in other words a C-string. As you surely know, an unsigned integer is not a string. I'm sure the compiler told you this when you wrote that code, however sticking that cast in there is the equivalent of saying "shut up compiler, I know what I'm doing!".
As the documentation for GetLastError indicates, if you want a string representation of your error code you should use the
FormatMessage function. An easier alternative would be to set a breakpoint in the debugger, store the value of GetLastError in a variable, look a the value of the variable, and then look up the error code
here.