In function
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
I get hwnd , then I have to pass it to many other functions through parameters, and this clutters up the code. Maybe make a global variable Hwnd , let other functions use it? Otherwise, I read the theory that global variables are dangerous, but in this case, perhaps this is justified?

  • 7
    They are dangerous only because you can forget somewhere that it is global and can be changed by chance. So call it so that you know for sure that it is global and that it doesn’t intersect with anything else (and with large letters). It just seems too simple to me Hwnd , it is easy to confuse with dozens of other hwnd small letters. It is better to give a more speaking name, which will reflect which window hwnd. And if it is installed in CALLBACK, be careful not to start using it before the callback occurred. - Mike

0