3

I am starting to learn about the Windows API. So I opened up Microsoft Visual C++ and created a new project. I chose Win32 project and it started up. I then clicked build and run before typing anything and I came up with this error:

error RC2104: undefined keyword or key name: DS_SETFONT....

The error told me it was in the windows resource file that I cannot edit. I looked on-line and I couldn't find anything on this topic.

How would I go about fixing this?

perror
  • 7,071
  • 16
  • 58
  • 85
Wp3Dev
  • 2,001
  • 7
  • 38
  • 54

2 Answers2

12

When the solution is generated, it removes #include <windows.h>.

Simply adding #include <windows.h> will fix it.

In my case, I added it in the *.rc file.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Wasim A.
  • 9,660
  • 22
  • 90
  • 120
  • 3
    It probably has something to do with your decision *not* to use precompiled headers. Normally, the RC file includes the pre-compiled header, named `stdafx.h` by default. That in turn includes ``. If you've disabled pre-compiled headers and deleted `stdafx.h`, then you're not including the Windows headers in your resource file. However, I would advise *against* editing the RC file by hand--it's regenerated on demand by the designer. – Cody Gray - on strike Jul 22 '13 at 06:40
0

For others encountering this problem: my issue seems to have originated in that I was working on an old project where the resource files were not generated in Visual Studio and the normal Wizard setups had not been completed.

I was attempting to add/change controls to the MYAPP.RC files defining the menu etc but was getting an error "RC2104 undefined keyword or keyname: DS_SETFONT." This is because the Symbol Directives needed the header # include "windows.h"

I figured this out and added # include "windows.h" to the resource.h file. Trouble is both the MYAPP.RC and resource.h files are auto generated and any manually inserted # include "windows.h" gets dumped each time.

This Microsoft Help page put me straight and I went to the Resource View -> Resource Includes -> Read-only symbol directives window and inserted: # include "windows.h"

Can now edit Resources no problem.

Paul_S
  • 1
  • 4