I’m making a simple GUI library, and I’ve gotten to the first test. The weird thing is, none of the windows macros seem to be defined. I’m getting errors like “‘NULL’ was not declared in scope” and “‘HANDLE’ was not declared in scope.” I’m thinking it might be the way I organized the code because the stuff in the entry file easywin.hpp isn’t defined either, but it SEEMS like it should work. Here’s (most) of easywin.hpp:
#ifndef EASYWIN_BASE_HPP
#define EASYWIN_BASE_HPP
#include <string>
#include <map>
//Strings are used everywhere, so might as well use them globally
using std::string;
/**
* A namespace to encapsulate WinAPI and prevent name clashing.
**/
namespace WinAPI{
#include <windows.h>
#include <commctrl.h>
}
//header includes (ordered according to inheritance)
#include "Application.hpp"
#include "Object.hpp"
#include "Widget.hpp"
#include "Container.hpp"
#include "Window.hpp"
#include "Dialog.hpp"
//not implemented yet, so don't include
//#include "Light.hpp"
#include "Heavy.hpp"
// there are more container types
#include "Control.hpp"
#include "Textbox.hpp"
#include "Tooltip.hpp"
//source includes
//needed to simplify class dependencies
#include "Application.cpp"
#include "Object.cpp"
#include "Widget.cpp"
#include "Container.cpp"
#include "Window.cpp"
#include "Dialog.cpp"
//not implemented yet, so don't include
//#include "Light.cpp"
#include "Heavy.cpp"
// there are more container types
#include "Control.cpp"
#include "Textbox.cpp"
#include "Tooltip.cpp"
#endif
I just don’t get it. If I’m including everything in this file, those files SHOULD get what’s defined in this file. What did I do wrong?
EDIT: To encourage better answers, I’ll post the git repository:
This should be a comment on IronMensan’s answer because it’s entirely correct but I can’t fit in there…
The windows’s API has functions that take parameters of type “HANDLE” in the global namespace, in other words “::HANDLE”. The windows libraries are already compiled to do this and the compiled code exists in such libraries as user32.lib/dll.
The purpose of windows.h is to define the types and functions that already exist in the library so you can call them. What you have done is define some unrelated types for example WinAPI::HANDLE which is fine, but in no way alters the fact that library contains functions which need a ::HANDLE as a parameter.
I understand what you are trying to do, and it’s a good aim. However there is no way that it can possibly work.