Just a heads up to anyone who has an error with window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). In the properties of the project, go to general > advanced > character set > "Use Multi-Byte Character Set". This is how I fixed this error on Visual Studio 2019.
DOWNLOAD the GAME and the SOURCE CODE: danzaidan.itch.io/pong-learn-programming It's also on GITHUB: github.com/DanZaidan/pong_learn_programming Let me know what you think about the way I'm doing these tutorials! :)
If you are having trouble creating the window in 2022, the LPCTSTR type for lpszClassName and for lpWindowName now need to be written as L"Game window Class" and L"My First Game!" with the L before the " "
I'm pretty familiar with C++, and I'm going through this series just to brush up on engine development a bit. But I want to say, that locker analogy you gave for pointers is the single best one I've EVER heard, and I can't believe I haven't heard it elsewhere. Props!
So I followed along... and I got frustrated because a lot of the stuff was not working like it did for you. This was the second time watching the video, so I am glad I came back. I did make sure the windows.h library was on my computer this time, a simple google search for this helped out! I had issues with the lpszClassName giving errors. So I google searched that and came up with that I had to put TEXT in front of Game Window Class, so it looked like window_class.lpszClassname = TEXT("Game Window Class"). It may be because I have VS 2022, it could be a lot of things. But I hope that might help someone else down the road. Do not get frustrated with the code guys. If it doesn't work the first time, google is your friend. You can find just about anything out there when it comes to the error codes you get with the compilers. I hope this helps!
Your reply saved me from a half hour headache. I'm a beginner, this is my first lesson, and even googling didn't get me far as I understood nothing of the answers. You legend!
This is SO exciting. Even though I knew bits of this a refresher is nice, I like knowing all the nitty gritty details instead of - let's say - Unreal/Unity holding my hand.
Recently decided to try making my own little games from scratch and found your series. I don't understand half of what's happening in this video, but I am so excited to learn! In only a half hour, I've already made my own window pop up, something I didn't think i'd be able to do until after college! Just graduated high school a little less than a year ago and have been dealing with doubts about my own coding abilities. But seeing what I can do here in such little time gives me hope, so thank you for that! Your videos are inspiring and you have created something good into the world, feel proud!
Thanks a million dude, C++ is my arch nemesis, it pounds me into a confusion pulp, but with your tutorial I finally created a freaking window! Also, seems you can't define a string variable with quotes anymore, you have to use: string_variable = L"test" I don't know why, but you have to put that L in front of your quotes to not get an error xd
LPCWSTR expects a multi-byte char and a string variable is just a normal single-byte char, appending just an L (I too have no idea why the heck they made it like that) converts normal string variable to multi-byte char...alternatively you could set character set to "Use Multi-Byte Character Set" in Config Properties of the main project -> that saves a lot of manual conversion effort actually :)
Great video, two issues i had was, i need to put L in front of strings so L"my first game" and i didnt have a close button top right of window so i had to put in WS_SYSMENU on the create window line for window style "WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU"
wow, your pointers explanation would've been really helpful last semester when i was struggling through learning C lol; yours is definitely the best explanation i've found so far, thanks!
Oh, that's great, I did it with you. Last time I did it on my own I failed and almost gave up and then got this. Great way of approaching the problem. Thanks dude!!! I could create that silly blank window to hype my confidence up again :)
If anyone is having issues with this line ~ window_class.lpszClassName = "Game Window Class"; ~ add L before the string like this ~ window_class.lpszClassName = L"Game Window Class"; ~. I also noticed that you have to do that at least for the createWindow section as well like ~ L"My First Game!" ~.
I couldn't close the window so I changed the case inside the switch(uMsg) to the following: case WM_CLOSE | WM_DESTROY: { running = false; }break; and it it now works as intended! I'm using MSVS 2022.
Hey Dan! I followed your tutorial step by step but no window appears when I run the program like you did @ 8:54. Task Manager shows a process for the window but the window doesn't show up (not even on the taskbar). Also, when defining window_class.lpszClassName it's giving me an error saying "a value of type const char* cannot be assigned to an entity of type LPCWSTR". Could you help me?
Apparently, your compiler is expecting a Unicode string (LPCWSTR). You can define one by putting an L before the string like: windows_class.lpszClassName = L"My Class Name"; Alternatively, you can make the Window Class be of type WNDCLASSA to make use it will use Ansi (the default) strings. Like this: WNDCLASSA window_class = {0}; window_class.style = CS_HREDRAW|CS_VREDRAW; window_class.lpfnWndProc = win32_window_callback; window_class.lpszClassName = "Window Class"; Let me know if it helps you! :)
@@DanZaidan Hi Dan. I have a problem when I used WNDCLASSA window_class = {}; RegisterClass change to RegisterClassA. The result coming out the title no same like my settings and looks like don't have UTF-8 words
@@daattavyaaggarwal7768 Yes, I found it. You just use the same with video WNDCLASS window_class and RegisterClass. In lpszClassName just added "L" in your game title windows_class.lpszClassName = L"My Class Name";
I hope you are doing well sir as you have not posted anything on the channel for 3 years i feel bad as i was not able watch this legacy in its prime . I will absorb every bit of information for game development and make something. Thank you from the bottom of my heart as game development is my dream and i hope you read my comment if you are out there🤗👍
I wrote the same code as you did with L before "Game Window Class" and "My First Game". And there's still something wrong with CreateWindow. How to solve that?
This is a great series. I love C++, even if I normally use JS or Python for uni projects. Your tutorial are super fast and condensed but we can take our time to study each single concept even in more detail. Am I screwed? Programming has become my new hobby.
Thanks, but no need to try to speed run the tutorial, take your time man, lots of people like to 'code along' to tutorials, when you're going so fast, it's hard to follow and code at the same time, it also doesn't leave much time to think about what you're saying, and understand it. It's easy for you because you've done it a million times, but for a beginner, it takes time to understand what the names even mean. I had to keep switching back to this video and pausing it every 5 seconds.
Thanks for the tutorial! I did the code as in the video but i have a problem: when i execute the file, it also opens the console. i´m doing this in vscode. What can i do to solve this? (Sorry if my english is bad, it´s not my firss language.)
This is the best tutorial for creating Windows in C++ I have ever seen. Thank you for putting in the effort to explain things so well. You explained enough that I can fill in any of the other information by doing my own research. Other tutorials are so vague that I don't even have enough information to efficiently and effectively do my own research to fill in all of the holes. Once again, thank you.
I'm getting "LPCSTR kind entity cannot assignt to "const wchar_t*" no value assignment of type" and " Unable to convert ''=' const wchar_t - LPCSTR" errors in this line //Create a window class WNDCLASS window_class = {}; window_class.style = CS_HREDRAW | CS_VREDRAW; window_class.lpszClassName = "Wnd"; //This is line with the problem window_class.lpfnWndProc = window_callback; Please help
in the line where i wrote "window_class.lpszClassName = "Game Window Class" I got the error "a value type of 'const char*' cannot be assigned to an entity of type 'LPCWSTR'" and the error "'=': cannot convert from 'const char[18]' to 'LPCWSTR'. Does anybody know what to do with this or how to fix it? Thanks.
5:45 if your class name doesn't work: add L as a prefix window_class.lpszClassName = L"Game_Window_Class"; 9:42 again CreateWindow(window_class.lpszClassName, L"My First Game",......
if you get issue around 4 min ``` std::string word = "Game Window Class"; LPCTSTR lp = (LPCTSTR) word.c_str(); window_class.lpszClassName = lp; ``` will work instead
@@ovdiaries it got rid of the error, but the compiler still complained, @niek's answer worked best :) If you want to put it all in one line the you can do `(LPCTSTR)std::string("Game Window Class").c_str()`, remember to `#include ` :)
hey so i got to the point where the blank window should pop up, however it reads that an access violation was thrown. the code is 0xC000041D. do you know how to fix this?
Hey! Thanks for the guide. Quick question: at 4:51 we can see that when you hover over lpfnWndProc you are getting a little tooltip that links to some documentation. How are you getting that? Hovering or selecting that text just shows me a tag.
I'm glad you are liking it! Actually I have CS_VREDRAW under the cursor at this point (lpfnWndProc is only selected via Shift+Arrow Keys), so it shows the tooltip for the macro (pink text). If you don't see, I'm not really sure, I have installed VS2019 specifically for this series. You can watch me installing it on episode #0 (with the Windows SDK, so maybe it has something to do with it?) and I haven't added anything to it. :P Visual Studio is kind of a mystery... hahaha Sorry I couldn't be more useful.
@@DanZaidan So it turns out that the version of visual studios that comes with unity3d is 2017 and the features that were lacking from my intellisense quickinfo panel were added in 2019. -_- Well, I guess I just spent a couple hours learning all about intellisense. Visual studio is not longer a mystery to me. :p
Its impossible to follow the video in real time and having to pause for every action because you move on and use shortcuts way too quickly for any beginner to follow along with is a bit frustrating but the video is packed with info which is good. Including the links to the resources would also be very helpful in saving people time.
Hi, I have a few problems with my game. So first of all the 1Param wouldn't go grey, then when I got to the CreateWindow part the "CreateWindow" error wouldn't go away. And then I couldn't debug because of the errors and when I went to debug> Windows There was no watch window there. I'm using Visual studio 2022. Please help me
Why at 3:59 there is a video edit that doesn't allow the viewer to see how you got to that documentation page, I downloaded the whole pdf and searched for WINDCLASS, and it doesn't show up. This is always a kill joy on these tutorials when the person giving instructions just randomly jumps to another page without showing how they got there.
I realize this video was made 3 years ago so a heads up to anyone just barely jumping in like me, there is no WNDCLASS information, you can pull up WNDCLASSA, documentation under winsuer.h, I found the latest information is from 2022 so be aware you might need to dig like I did to follow along with this video. Hope this helps.
Also, like user @andrewcampbell4960 pointed out do the following to clear the error with the .lpszClassName "In properties of the project, go to advanced > character set > "Use Multi-Byte Character Set". and that will fix your problem.
Hey, I'm really enjoying the tutorial, but I've encountered an issue. See, I'm using blocks instead of visual studio and somehow can't compile the code. When I click the "build" button nothing happens, but when I click the "run" button, the window about the code not being built appears. This would be normal but the window keeps reappearing whenever I click the "yes" option and the code still isn't compiled. Is it a compiler issue, or something else? Also, I don't know how to change the x64 bit os into x32 bit os. It's much clearer in visual studio but not in codeblocks.
Hi Marcel. This seems to be an IDE issue. Unfortunately, I don't know CodeBlocks so I can't help you specifically. However, I would suggest trying to create a simple "Hello World" program before tacking the game to make sure everything is working properly. :)
at 05:45 mine doesn't compile... the error list flags line 11 with a value of the type ""const char*"" can't be assigned to an entity of the type ""LPCWSTR"" and "=": "const char [18]" can't be converted into "LPCWSTR" My code is exactly like yours, please help
this is OOP which is a couple of lessons into c++. if i were to relate this to college classes this would be like a midterm project in the second c++ class
For my code I had to type an L just before every mention of "Game Window Class" to avoid getting the following build error: Severity Code Description Project File Line Suppression State Error (active) E0513 a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR" My_First_Cpp_Game Any idea why?
One guy commented with a solution to an error: window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). One can solve it by imply writing it with "L" before the string like: window_class.lpszClassName = L"Game Window Class". Im not sure of it but L there works as an literal defined by msc, and what it does is basically make your single char take twice as much space (or sth like that) as it is in LPCWSTR
I'm stuck at 9:35, to me it doesn't appear you change anything so I'm not sure what's causing it to work, because mine isn't. Any help would be appreciated.
At this point, the window should be created and destroyed very quickly (just flash on the screen). I used the debugger to set through each line of code (by pressing F10) to see the window before the program exists (and the window closes). A little bit layer in this video I add the input loop so that the window stays open. Try to plow forward a bit, and if the problem persists, paste some code and I'll try to help you further. ;)
@@DanZaidan Ok thanks I was able to get the window to stay up but now I'm unable to move it, close, or full screen it and I can't minimize it I just click on another tab to move it to the background.
Great tutorial man, just a question , There is no minimize, maximize and close buttons in my output window?? EDIT: Also no black screen on the next tutorial??
Thanks! Make sure you are passing both flags to the CreateWindow function. @8:16 WS_OVERLAPPEDWINDOW | WS_VISIBLE I'm not sure what you mean by no black screen :P
@@ahmedthegreat3973 Hi! This means that "CreateWindow" is expecting "wide characters" for the window name (characters that support the whole Unicode format). You can easily fix this by calling CreateWindowA instead (also make sure that RegisterClass has the A sufix). Alternatively, you could pass "wide characters" instead of normal strings to it, by prefixing the string with L, like so: CreateWindow(L"Window Title", ...); Let me know if it helps. :)
I get the error below at '=' in the line window_class.lpszClassName = "Game Window Class"; a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR"C/C++(513) I also get another error shown below in the line CreateWindowA(window_class.lpszClassName, "My First Game!", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0); argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR"C/C++(167) I followed along exactly and should get the blank window but for some reason the types don't agree and I am not sure why and don't know enough to fix it. I have tried several things like using a wide string by putting 'L' in front of "Game Window Class", but that doesn't fix the other error. I've tried CreateWindow without the 'A' and tried other versions of CreateWindow but always end up with errors.
i have two build erros link2019 and link1120 1 .how to resolve the issue and i just dont know where was the problem it says unable to run the porgram at specified direction
it says that it cant find windows.h. also all this line of code: (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) it wont work and i want to do this.
This probably mean you don't have the Windows SDK installed. It is installed automatically when you install Visual Studio. Maybe the best thing for you to do would be to reinstall it and make sure you select the "C++ Development" option. :)
i just started this and it says theres something wrong with " window_class.lpszClassName = "Game Window Class"; " and i dont know what to do because this is also exaclty what u have in the video
Damn....You have drawn a blank window and I'm already lost....guess I'm off to watch another 30 to 40 more "Hello World" tutorials....Great video tho, not your fault.
in my CreateWindow(); it's giving me error because it's saying:argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR". PLEAAAAAAAAAAAAAAAAAAAAAAAAAAAASSSSSSSSSSEEE Someone help!!!!!! 🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺
First off, thanks for the video :) Everything works fine, until 12:00 in the video, towards the end. "warning: no return statement in function returning non-void [-Wreturn-type]" The problem for me started when you changed... return DefWindowProc(hwnd, uMsg, wParam, lParam); to... return result; Here's my code: LRESULT CALLBACK window_callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ LRESULT result = 0;
switch(uMsg){ case WM_CLOSE: case WM_DESTROY: { running = false; } break;
default: { result = DefWindowProc(hwnd, uMsg, wParam, lParam); } } return result; } I got it working by putting "return 0" within the WinMain{} block, as the last statement, figuring that if an error occurs, then the return value will not be 0. I'm using Mingw64, with Notepad++ Maybe it's a compiler issue that won't allow me to run the program while WinMain expects a return value, even though the "return" value has already been provided within the LRESULT CALLBACK window_callback() function. Perhaps?
Is this C++ a diefferent program? Because I downloaded a C++ program but it doesnt have that Infinity logo. I'm just a freshmen in computer engineering and I dont know where to get this C++. I only downloaded the DEV C++ is that different?
*MAKE SURE TO COPY IT EXACTLY!!!* I had the same problem and it was because I only had one "CW_USEDEFAULT" when there should be two. Here's what you should copy: CreateWindow(window_class.lpszClassName, "Your name", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0);
somethings my professor though me is writing the code out on paper and finding out what each piece of code does aka taking notes on the code. you'll also need to be able to recognize classes and pointers to understand the parts in this video. you can also use an AI to break down pieces of the code. some of the stuff such as the windows you dont "really" need to know how it works just that it's windows class for windows development. but microsoft does have a documentation you can read through on what each part does.
Just a heads up to anyone who has an error with window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). In the properties of the project, go to general > advanced > character set > "Use Multi-Byte Character Set".
This is how I fixed this error on Visual Studio 2019.
Thanks for this 👍
Thank you😁
Thank you so much!
I'm not religious but you are an angel. Thank you
Thank you
It was hard, but I got through. I've never been so happy to see a blank window before
That's awesome!!
Blank windows do have their charm... :)
just finished it also such a satisfying feeling
I am with you, Michael. A blank window never looked so good ; 0
can u pls help me out i found difficulties in debug process
real
DOWNLOAD the GAME and the SOURCE CODE: danzaidan.itch.io/pong-learn-programming
It's also on GITHUB: github.com/DanZaidan/pong_learn_programming
Let me know what you think about the way I'm doing these tutorials! :)
If you are having trouble creating the window in 2022, the LPCTSTR type for lpszClassName and for lpWindowName now need to be written as L"Game window Class" and L"My First Game!" with the L before the " "
Thanks for this.
tysm
Thanks a lot, I was trying to figure out why I was getting this kind of error message after typing exactly what he had there.
thanks
Thank you
You saved me from the PAIN that is going through this without a proper guide. This is amazing, thank you from the bottom of my kidney.
I have been searching for this tutorial for a whole day and now I have finally found one that works
I hope you love it! :)
I'm pretty familiar with C++, and I'm going through this series just to brush up on engine development a bit. But I want to say, that locker analogy you gave for pointers is the single best one I've EVER heard, and I can't believe I haven't heard it elsewhere. Props!
So I followed along... and I got frustrated because a lot of the stuff was not working like it did for you. This was the second time watching the video, so I am glad I came back. I did make sure the windows.h library was on my computer this time, a simple google search for this helped out! I had issues with the lpszClassName giving errors. So I google searched that and came up with that I had to put TEXT in front of Game Window Class, so it looked like window_class.lpszClassname = TEXT("Game Window Class"). It may be because I have VS 2022, it could be a lot of things. But I hope that might help someone else down the road. Do not get frustrated with the code guys. If it doesn't work the first time, google is your friend. You can find just about anything out there when it comes to the error codes you get with the compilers. I hope this helps!
Your reply saved me from a half hour headache. I'm a beginner, this is my first lesson, and even googling didn't get me far as I understood nothing of the answers. You legend!
Thank you i was so confused by the error and this comment helped me out a lot!
How cool is this? The last time I looked at windows coding, it was like staring into the abyss. This is excellent. Thx so much.
This is SO exciting. Even though I knew bits of this a refresher is nice, I like knowing all the nitty gritty details instead of - let's say - Unreal/Unity holding my hand.
following this in 2024, will keep you updated
Just finished this video didn't understand a lot but felt good after seeing the box. Learned a lot
Recently decided to try making my own little games from scratch and found your series. I don't understand half of what's happening in this video, but I am so excited to learn! In only a half hour, I've already made my own window pop up, something I didn't think i'd be able to do until after college! Just graduated high school a little less than a year ago and have been dealing with doubts about my own coding abilities. But seeing what I can do here in such little time gives me hope, so thank you for that! Your videos are inspiring and you have created something good into the world, feel proud!
Exactly what I needed, thank you!
Thanks a million dude, C++ is my arch nemesis, it pounds me into a confusion pulp, but with your tutorial I finally created a freaking window! Also, seems you can't define a string variable with quotes anymore, you have to use: string_variable = L"test"
I don't know why, but you have to put that L in front of your quotes to not get an error xd
LPCWSTR expects a multi-byte char and a string variable is just a normal single-byte char, appending just an L (I too have no idea why the heck they made it like that) converts normal string variable to multi-byte char...alternatively you could set character set to "Use Multi-Byte Character Set" in Config Properties of the main project -> that saves a lot of manual conversion effort actually :)
Great video, two issues i had was, i need to put L in front of strings so L"my first game"
and
i didnt have a close button top right of window so i had to put in WS_SYSMENU on the create window line for window style
"WS_OVERLAPPED | WS_VISIBLE | WS_SYSMENU"
Thx, that L tip just save me (I'm not sure why i had to do this, but I gonna search about it later to understand)
@@denilopereira234 I know this comment was helpful right?
Thanks for this comment. I was trying to figure out how to generate an exit button on the window. This helped!
wow, your pointers explanation would've been really helpful last semester when i was struggling through learning C lol; yours is definitely the best explanation i've found so far, thanks!
Oh, that's great, I did it with you. Last time I did it on my own I failed and almost gave up and then got this. Great way of approaching the problem. Thanks dude!!! I could create that silly blank window to hype my confidence up again :)
Who had to watch it in x0.75 because his typing is too fast
Me bro 😂😂
I dont see any problem with that. We are supposed to UNDERSTAND the code, not just rewriting/copypasting everything that he wrote .
If anyone is having issues with this line ~ window_class.lpszClassName = "Game Window Class"; ~ add L before the string like this ~ window_class.lpszClassName = L"Game Window Class"; ~. I also noticed that you have to do that at least for the createWindow section as well like ~ L"My First Game!" ~.
hi this worked for me but why do we have to put an L in, like what does it do in there?
@@anforawelch marks the literal as a wide literal
@@DH-cg6qx thank you😁
this is underrated
I couldn't close the window so I changed the case inside the switch(uMsg) to the following:
case WM_CLOSE | WM_DESTROY: {
running = false;
}break;
and it it now works as intended! I'm using MSVS 2022.
it was a little fast, but definitely was waaaay more informative than every other tutorial i could find
Hey Dan! I followed your tutorial step by step but no window appears when I run the program like you did @ 8:54. Task Manager shows a process for the window but the window doesn't show up (not even on the taskbar). Also, when defining window_class.lpszClassName it's giving me an error saying "a value of type const char* cannot be assigned to an entity of type LPCWSTR". Could you help me?
Apparently, your compiler is expecting a Unicode string (LPCWSTR). You can define one by putting an L before the string like:
windows_class.lpszClassName = L"My Class Name";
Alternatively, you can make the Window Class be of type WNDCLASSA to make use it will use Ansi (the default) strings. Like this:
WNDCLASSA window_class = {0};
window_class.style = CS_HREDRAW|CS_VREDRAW;
window_class.lpfnWndProc = win32_window_callback;
window_class.lpszClassName = "Window Class";
Let me know if it helps you! :)
@@DanZaidan Hi Dan. I have a problem when I used WNDCLASSA window_class = {};
RegisterClass change to RegisterClassA. The result coming out the title no same like my settings and looks like don't have UTF-8 words
@@DanZaidan Hello Dan! Sorry for the late response! Thank you for your helo! I'll let you know if it worked!
@@TeaDessert Did you find a solution? I have the exact same problem.
@@daattavyaaggarwal7768 Yes, I found it. You just use the same with video WNDCLASS window_class and RegisterClass.
In lpszClassName just added "L" in your game title
windows_class.lpszClassName = L"My Class Name";
what a satisfying view that white window was...after struggling all those build errors!!
I hope you are doing well sir as you have not posted anything on the channel for 3 years i feel bad as i was not able watch this legacy in its prime . I will absorb every bit of information for game development and make something. Thank you from the bottom of my heart as game development is my dream and i hope you read my comment if you are out there🤗👍
Congratulations! This is how tutorials should be done!
Awesome!
I'm glad you liked it. :)
bro that was the most hardcore 12 minutes of my life
I wrote the same code as you did with L before "Game Window Class" and "My First Game". And there's still something wrong with CreateWindow. How to solve that?
I also have this issue, someone pls help
Thank you so much! You will probably be the guy that teaches me coding
That would be awesome! :D
This is a great series. I love C++, even if I normally use JS or Python for uni projects. Your tutorial are super fast and condensed but we can take our time to study each single concept even in more detail.
Am I screwed? Programming has become my new hobby.
yes probably
I have no clue what I just did... but I did it...
Thank you for sharing your talent, please continue. Excellent video.
Thanks, but no need to try to speed run the tutorial, take your time man, lots of people like to 'code along' to tutorials, when you're going so fast, it's hard to follow and code at the same time, it also doesn't leave much time to think about what you're saying, and understand it. It's easy for you because you've done it a million times, but for a beginner, it takes time to understand what the names even mean. I had to keep switching back to this video and pausing it every 5 seconds.
yes, yes & yes! still, great tutorial. but yes, tranquilo, just a bit
Though surely this is the best. I appreciate your work! The best tutorial out there.
Lmao. Just spent an hr trying to figure out what was wrong before thinking to check comments
Thanks for the tutorial!
I did the code as in the video but i have a problem: when i execute the file, it also opens the console.
i´m doing this in vscode. What can i do to solve this?
(Sorry if my english is bad, it´s not my firss language.)
This is the best tutorial for creating Windows in C++ I have ever seen. Thank you for putting in the effort to explain things so well. You explained enough that I can fill in any of the other information by doing my own research. Other tutorials are so vague that I don't even have enough information to efficiently and effectively do my own research to fill in all of the holes. Once again, thank you.
I'm getting "LPCSTR kind entity cannot assignt to "const wchar_t*" no value assignment of type" and " Unable to convert ''=' const wchar_t - LPCSTR" errors in this line
//Create a window class
WNDCLASS window_class = {};
window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.lpszClassName = "Wnd"; //This is line with the problem
window_class.lpfnWndProc = window_callback;
Please help
in the line where i wrote "window_class.lpszClassName = "Game Window Class" I got the error "a value type of 'const char*' cannot be assigned to an entity of type 'LPCWSTR'" and the error "'=': cannot convert from 'const char[18]' to 'LPCWSTR'. Does anybody know what to do with this or how to fix it? Thanks.
window_class.lpszClassName = L"Game Window Class"; use this bro
2 minutes of video and my brain already fried ill come back tomorrow
5:45 if your class name doesn't work:
add L as a prefix
window_class.lpszClassName = L"Game_Window_Class";
9:42 again
CreateWindow(window_class.lpszClassName, L"My First Game",......
thank you!
sir my diagnostic tool part showing No data has been collected yet.....and debug>window>then there is no watch option
You will get the watch option when you are in line by line mode ( press F10)
thank you for the series, im learning a lot
if you get issue around 4 min
```
std::string word = "Game Window Class";
LPCTSTR lp = (LPCTSTR) word.c_str();
window_class.lpszClassName = lp;
```
will work instead
L"name" xd works just fine
@@ovdiaries it got rid of the error, but the compiler still complained, @niek's answer worked best :) If you want to put it all in one line the you can do `(LPCTSTR)std::string("Game Window Class").c_str()`, remember to `#include ` :)
@@julianavar3836 THANKS
keep doing great things like that bro!
i get this error message identifier "window" is undefined
my mans keyboard is on fire
I watch this in 2023 and the code have this new line "[in] WNDPROC lpPrevWndFunc", is it necessary to include this line?
pointer explaination on point i must say
hey so i got to the point where the blank window should pop up, however it reads that an access violation was thrown. the code is 0xC000041D. do you know how to fix this?
Hey! Thanks for the guide. Quick question: at 4:51 we can see that when you hover over lpfnWndProc you are getting a little tooltip that links to some documentation. How are you getting that? Hovering or selecting that text just shows me a tag.
I'm glad you are liking it!
Actually I have CS_VREDRAW under the cursor at this point (lpfnWndProc is only selected via Shift+Arrow Keys), so it shows the tooltip for the macro (pink text).
If you don't see, I'm not really sure, I have installed VS2019 specifically for this series. You can watch me installing it on episode #0 (with the Windows SDK, so maybe it has something to do with it?) and I haven't added anything to it. :P
Visual Studio is kind of a mystery... hahaha
Sorry I couldn't be more useful.
@@DanZaidan So it turns out that the version of visual studios that comes with unity3d is 2017 and the features that were lacking from my intellisense quickinfo panel were added in 2019. -_- Well, I guess I just spent a couple hours learning all about intellisense. Visual studio is not longer a mystery to me. :p
mainly learned about platform development in this did not know how to do that before thx.
Hey man.
Love your video
Waiting for new tutorial
Thanks so much for your comment! :D
Its impossible to follow the video in real time and having to pause for every action because you move on and use shortcuts way too quickly for any beginner to follow along with is a bit frustrating but the video is packed with info which is good. Including the links to the resources would also be very helpful in saving people time.
Hi, I have a few problems with my game. So first of all the 1Param wouldn't go grey, then when I got to the CreateWindow part the "CreateWindow" error wouldn't go away. And then I couldn't debug because of the errors and when I went to debug> Windows There was no watch window there. I'm using Visual studio 2022. Please help me
it's "lParam" not "1Param" his font made the lowercase L look like a 1 for some reason, as for a window just put a L before the title in quotes
Why at 3:59 there is a video edit that doesn't allow the viewer to see how you got to that documentation page, I downloaded the whole pdf and searched for WINDCLASS, and it doesn't show up. This is always a kill joy on these tutorials when the person giving instructions just randomly jumps to another page without showing how they got there.
I realize this video was made 3 years ago so a heads up to anyone just barely jumping in like me, there is no WNDCLASS information, you can pull up WNDCLASSA, documentation under winsuer.h, I found the latest information is from 2022 so be aware you might need to dig like I did to follow along with this video. Hope this helps.
Also, like user @andrewcampbell4960 pointed out do the following to clear the error with the .lpszClassName "In properties of the project, go to advanced > character set > "Use Multi-Byte Character Set". and that will fix your problem.
Hey, I'm really enjoying the tutorial, but I've encountered an issue. See, I'm using blocks instead of visual studio and somehow can't compile the code. When I click the "build" button nothing happens, but when I click the "run" button, the window about the code not being built appears. This would be normal but the window keeps reappearing whenever I click the "yes" option and the code still isn't compiled. Is it a compiler issue, or something else? Also, I don't know how to change the x64 bit os into x32 bit os. It's much clearer in visual studio but not in codeblocks.
Hi Marcel.
This seems to be an IDE issue.
Unfortunately, I don't know CodeBlocks so I can't help you specifically.
However, I would suggest trying to create a simple "Hello World" program before tacking the game to make sure everything is working properly. :)
at 05:45 mine doesn't compile... the error list flags line 11 with
a value of the type ""const char*"" can't be assigned to an entity of the type ""LPCWSTR""
and
"=": "const char [18]" can't be converted into "LPCWSTR"
My code is exactly like yours, please help
I have the same problem.
Found a comment that said to just put an L in front of it.
window_class.lpszClassName = L"Game Window Class"
dunno why tho...
@@akabami2161 doesnt work anymore with the 2019 version
Making games on raw C++ seems so hard bro
this is definitely not for beginners 🤯
in fact it scared me away from programming. very overwhelming
this is OOP which is a couple of lessons into c++. if i were to relate this to college classes this would be like a midterm project in the second c++ class
Tutorials really cool!!! Thanks for work😉
if anyone's having any syntax errors for seemingly no reason, make sure all your brackets {} are in the correct places!
At 9:35what did you with the keyboard??
Did you find out?
I also didn't understand it
can someone help me?
it errors C4716 'winMain': must return a value
if I return 0 or 1 it says cant find main();
For my code I had to type an L just before every mention of "Game Window Class"
to avoid getting the following build error:
Severity Code Description Project File Line Suppression State
Error (active) E0513 a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR" My_First_Cpp_Game
Any idea why?
I'm having the same issue if you figure it out please explain
@@MrFoxUltima Will do. It doesn't seem to be a hinderance though. Just a nuisance
Thanks my code took the L now it works
Typing L changes it to wide character type, no idea why that fixes it though.
One guy commented with a solution to an error: window_class.lpszClassName = "Game Window Class" throwing an error (error C2440: '=': cannot convert from 'const char [18]' to 'LPCWSTR'). One can solve it by imply writing it with "L" before the string like: window_class.lpszClassName = L"Game Window Class". Im not sure of it but L there works as an literal defined by msc, and what it does is basically make your single char take twice as much space (or sth like that) as it is in LPCWSTR
are you boy or girl
@@EgeÇınar-m7f male, why
This is amazing! Thank you for sharing this man :]
I'm stuck at 9:35, to me it doesn't appear you change anything so I'm not sure what's causing it to work, because mine isn't. Any help would be appreciated.
At this point, the window should be created and destroyed very quickly (just flash on the screen).
I used the debugger to set through each line of code (by pressing F10) to see the window before the program exists (and the window closes).
A little bit layer in this video I add the input loop so that the window stays open. Try to plow forward a bit, and if the problem persists, paste some code and I'll try to help you further. ;)
@@DanZaidan Ok thanks I was able to get the window to stay up but now I'm unable to move it, close, or full screen it and I can't minimize it I just click on another tab to move it to the background.
Great tutorial man, just a question , There is no minimize, maximize and close buttons in my output window??
EDIT: Also no black screen on the next tutorial??
Thanks! Make sure you are passing both flags to the CreateWindow function.
@8:16 WS_OVERLAPPEDWINDOW | WS_VISIBLE
I'm not sure what you mean by no black screen :P
im stuck at the create window part it just keeps saying theres an error when i followed everything from the video right
I’m haveing troubles with the LPSTR part of the int winmain code it’s saying cannot concert const char to [18] to LPCWSTR could I get some help?
Have you found a fix Mine is also not working
@@ahmedthegreat3973 Hi!
This means that "CreateWindow" is expecting "wide characters" for the window name (characters that support the whole Unicode format).
You can easily fix this by calling CreateWindowA instead (also make sure that RegisterClass has the A sufix).
Alternatively, you could pass "wide characters" instead of normal strings to it, by prefixing the string with L, like so:
CreateWindow(L"Window Title", ...);
Let me know if it helps. :)
whew! made it! you are amazing, but, wow
I get the error below at '=' in the line window_class.lpszClassName = "Game Window Class";
a value of type "const char *" cannot be assigned to an entity of type "LPCWSTR"C/C++(513)
I also get another error shown below in the line CreateWindowA(window_class.lpszClassName, "My First Game!", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0);
argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR"C/C++(167)
I followed along exactly and should get the blank window but for some reason the types don't agree and I am not sure why and don't know enough to fix it. I have tried several things like using a wide string by putting 'L' in front of "Game Window Class", but that doesn't fix the other error. I've tried CreateWindow without the 'A' and tried other versions of CreateWindow but always end up with errors.
for the first problem i guess u can go to properties in the project > advanced > character set > "Use Multi-Byte Character Set". it's fixed my error
i have two build erros link2019 and link1120 1 .how to resolve the issue and i just dont know where was the problem it says unable to run the porgram at specified direction
sorry but i did not watch the first video you mentioned, could you link it?
very good channel, thanks for your time bro subscribed!
Thank YOU! :D
it says that it cant find windows.h. also all this line of code: (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
it wont work and i want to do this.
This probably mean you don't have the Windows SDK installed.
It is installed automatically when you install Visual Studio.
Maybe the best thing for you to do would be to reinstall it and make sure you select the "C++ Development" option. :)
@@DanZaidan thanks! i will try it.
at 4:00 I can only see wndclassA structure on the msdn?
How can I fix the CreateWindow error? When I type it, it's wrong spelling and my only option is to take it out. So can you fix it for me please?
i just started this and it says theres something wrong with " window_class.lpszClassName = "Game Window Class"; " and i dont know what to do because this is also exaclty what u have in the video
Damn....You have drawn a blank window and I'm already lost....guess I'm off to watch another 30 to 40 more "Hello World" tutorials....Great video tho, not your fault.
I need a tutorial to do this on my phone while my laptop is in the shop
in my CreateWindow(); it's giving me error because it's saying:argument of type "LPCWSTR" is incompatible with parameter of type "LPCSTR".
PLEAAAAAAAAAAAAAAAAAAAAAAAAAAAASSSSSSSSSSEEE Someone help!!!!!!
🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺🥺
CreateWindow(
win_class.lpszClassName,
L"Test Game!",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
1280,
720,
0,
0,
hInstance,
0
);
how did you test the Project??
First off, thanks for the video :) Everything works fine, until 12:00 in the video, towards the end.
"warning: no return statement in function returning non-void [-Wreturn-type]"
The problem for me started when you changed...
return DefWindowProc(hwnd, uMsg, wParam, lParam);
to...
return result;
Here's my code:
LRESULT CALLBACK window_callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){
LRESULT result = 0;
switch(uMsg){
case WM_CLOSE:
case WM_DESTROY: {
running = false;
} break;
default: {
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
return result;
}
I got it working by putting "return 0" within the WinMain{} block, as the last statement, figuring that if an error occurs, then the return value will not be 0.
I'm using Mingw64, with Notepad++
Maybe it's a compiler issue that won't allow me to run the program while WinMain expects a return value, even though the "return" value has already been provided within the LRESULT CALLBACK window_callback() function. Perhaps?
thanks for this tutorial brother, great stuff
I'm glad you liked it, Frank! :)
what version on visuel studio do I download (community, professional, enterprise )
The community edition is perfect for individuals! (And it's free! :D )
Its a wonderful tutorial! Great man, continue with that, please!
Is this C++ a diefferent program? Because I downloaded a C++ program but it doesnt have that Infinity logo. I'm just a freshmen in computer engineering and I dont know where to get this C++. I only downloaded the DEV C++ is that different?
Bruh! You're talking about IDE. This is a different one yay. As it had been 2 years I think you know it now!
@@hadiaabq7981 hahaha true I didnt know what I was talking about then
It Saya hwnd and the other stuff in the callback function thing are unidentified, how to fix
on create window it is underlined in red and i cant get rid of it... How do i do that?
Try posting your code here and I'll try to help out. :)
*MAKE SURE TO COPY IT EXACTLY!!!*
I had the same problem and it was because I only had one "CW_USEDEFAULT" when there should be two.
Here's what you should copy:
CreateWindow(window_class.lpszClassName, "Your name", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 1280, 720, 0, 0, hInstance, 0);
I got error in creatwindowW
Tell me how to solve this error
Coming here from C#, which I came to after doing this via python.
This is soooo much harder..
If I were to put pointers on the scale 1 to 10. How important are they?
What is name of app?
the buttons for making it full screen does not appear
How do i make the window stop?? I struggled but succeeded to find the watch option now what did you press i don't get it?
Solved
I just feel like even if i do this and get it working I still won't know what I did or why it works. Will this help me learn/teach me something?
somethings my professor though me is writing the code out on paper and finding out what each piece of code does aka taking notes on the code. you'll also need to be able to recognize classes and pointers to understand the parts in this video. you can also use an AI to break down pieces of the code.
some of the stuff such as the windows you dont "really" need to know how it works just that it's windows class for windows development. but microsoft does have a documentation you can read through on what each part does.
I really want to do this tutorial, but my Visual Studio seems to be different than yours, I don´t have the Properties option, for example
my window isnt responding
C++ is so much memorization as compared to c#.... you can’t type window size and expect a similar variable to show up