In this specific case, it means one of two things. Either you are trying to write a Win32 GUI application (or non-console application) and accidently compiled it as a Console application... or you really are trying to compile a console application and didn't write or properly compile in a main() function.
Generally the first is the most common, if you specify Win32 Console as the project type in VC++ when you create your project you will get this error. You will also likely get it if you try to compile from the command line using BC++ but you neglect to specify the correct parameters to tell it to make a Win32 GUI application instead of a console app which is the default.
If you're using BC++ command line compiler, use -tW to specify a windows application.
If you're compiling code not from this tutorial, I can't guarantee that it's correct and therefor it may actually be an error that needs resolving. You'll have to use your own judgement to determine if it's safe to cast the value and remove the error, or if you are actually trying to make a variable be something it's not.
For example, in C this will work:
HBITMAP hbmOldBuffer = SelectObject(hdcBuffer, hbmBuffer);
But in C++ requires a cast:
HBITMAP hbmOldBuffer = (HBITMAP)SelectObject(hdcBuffer, hbmBuffer);
afxres.h
to resource files even when you aren't using an MFC project, and yet
the file may only be installed if you install MFC. This perticular file isn't actually required, so to fix the error
you can edit the .rc file in notepad and replace both occurances of "afxres.h"
with "winres.h"
(note that there should be two of them, and you need to change both).
If you add a Common Control to a dialog and it fails to display, you most likely failed to call InitCommonControls()
before running your dialog, or perhaps at all. The best place to call it is first thing in WinMain()
. Calling
it in WM_INITDIALOG
is too late, since the dialog will fail before it reaches this point and it will never
get called.
Some people and documentation may tell you that InitCommonControls()
is deprecated and you should use InitCommonControlsEx()
.
Feel free to do this if you want, InitCommonControls()
is just simpler and there's nothing wrong with using it.