Unusual behavior...for me.
Posted: July 24th, 2019, 1:51 am
I decided to take a break from game-centric programming and try my hand at some Win32 stuffs. I've messed around before with some success and have never run into an issue quite like what I'm currently experiencing.
In WinMain I'm trying to create a window. I have my WNDCLASSEX structure filled out and registered with RegisterClassEx and I get the ATOM that the function returns just fine. I go to call CreateWindowEx() using the same constexpr const char* string for lpszclassname that I used for the WNDCLASSEX structure that I registered and I get error number 1407 "Cannot find window class".
I do a search and this seems to happen if the string is a temporary, but I've never had issues with this before. I thought string literals were stored in the program's data section same as global static variables. After commenting some things out and thinking the issue was invalid arguments or an incorrect HINSTANCE, I tried just using the string literal directly and this worked. Not sure what the difference is. If the string is still around then what should it matter what the address is?
Ok, figured it out. The string you use in the WNDCLASSEX struct must have same address as the one you use for the CreateWindowEx() call. So, it's not the string that matters, but the same address. Dang, all these years and not running into that issue by luck. Damn that was frustrating.
In WinMain I'm trying to create a window. I have my WNDCLASSEX structure filled out and registered with RegisterClassEx and I get the ATOM that the function returns just fine. I go to call CreateWindowEx() using the same constexpr const char* string for lpszclassname that I used for the WNDCLASSEX structure that I registered and I get error number 1407 "Cannot find window class".
I do a search and this seems to happen if the string is a temporary, but I've never had issues with this before. I thought string literals were stored in the program's data section same as global static variables. After commenting some things out and thinking the issue was invalid arguments or an incorrect HINSTANCE, I tried just using the string literal directly and this worked. Not sure what the difference is. If the string is still around then what should it matter what the address is?
Ok, figured it out. The string you use in the WNDCLASSEX struct must have same address as the one you use for the CreateWindowEx() call. So, it's not the string that matters, but the same address. Dang, all these years and not running into that issue by luck. Damn that was frustrating.