The code creating modal dialog is missing. And apparently that code is what you're asking about. Anyway, if you code in C++ instead of C things would become much more clear and safe. Be aware that tWinMain monstrosity is neither standard C, nor standard C++, and that it serves no technical purpose. It is only Microsoft obfuscation, so, use a standard main. Also, it helps to not use global variables. And don't use C style casts, in general.
–
Cheers and hth. - AlfApr 23 '12 at 13:15