Why are windows.h definitions not found or being set

First I'm very new to C++ and am going through a tutorial about windows programming.

The problem (well not really a problem as I've got around it) is in regards to some definitions not appearing to exist. I'm using Codeblocks 8:02 (which may make a difference)

The first problem I had was with IDC_STATIC, it turned out that this wasn't being defined, even though I found it in windows.h
I've progressed but have the same issue with IDC_PRESS and IDC_OTHER, other than that a search for these (in all includes), finds nothing.

My get-around is to add the following code, in my resource.rc file:-

1
2
3
4
5
6
7
8
9
#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#ifndef IDC_PRESS
#define IDC_PRESS (9005)
#endif
#ifndef IDC_OTHER
#define IDC_OTHER (9006)
#endif 


My primary question is, am I going about this in the right way? A secondary question I suppose is perhaps that I've got a cut-down version of windows.h and should I be looking for a fuller version?

I'm getting the values by searching via google, but I have visions of this ending up being a momentous task which I would guess that others may have encountered.

I have included windows.h, in case this is asked. I have included it twice in main.cpp and in resource.rc, I wouldn't have thought that this would be an issue though, but am I wrong to think this way?
Last edited on
I can't speak to IDC_PRESS or IDC_OTHER because I don't recall ever using those, but I've always encountered the problem you decribe in terms of IDC_STATIC, and I've always solved it the same way you did. However, I usually define it in my header files that I then include with Windows.h in the *.rc file. This isn't unique to CodeBlocks, but will be encountered in every C++ development environment as far as I know.
Last edited on
freddie1 thanks for that, needless to say I've got way past this. Sorry for not replying sooner.
Adding the following, before including windows.h appears to circumvent the issue.

#define _WIN32_IE (0x0500)

So it looks as though some definitions are dependant upon the version of windows that you want to compile for.
If you're using a resource file then whatever you used to generate it should have given you a custom header file (i.e. resources.h); include it in your .rc file & main.c/cpp.
Uhhm, I manually created the resource files based upon a tutorial. I gave up on looking for a resource editor/generator as it was very apparent that for my project, which requires dynamic creation/removal of controls, that I had to find another way of creating what I need. So the deficiency appears to lie with myself and perhaps that I'm trying to run before I can walk.

However I'm getting there and perhaps learning in a way that seems to suit me. :)

Thanks for the reply Kiana, it all goes in and sets the old grey matter to work.
Topic archived. No new replies allowed.