Go announce HINSTANCE and friends

Is there a way to forward-declare a type HINSTANCEfrom WinAPI without including the full (and large) header windows.h?

For example, if I have a class RenderWindowthat belongs to HINSTANCE mInstance, I must include windows.hin RenderWindow.h. So, everything you need should RenderWindowalso include windows.h.

I tried turning it on windef.h, but it seems that I need some things from windows.h. :-( If I can’t forward the ad, is there at least a portable way to use something like long mInstancein RenderWindowinstead HINSTANCE?

+5
source share
3 answers

HINSTANCE WinDef.h typedef HINSTANCE __ * HINSTANCE;

:

#ifndef _WINDEF_
class HINSTANCE__; // Forward or never
typedef HINSTANCE__* HINSTANCE;
#endif

, HINSTANCE, WinDef.h .

+4

void * . , . , windows.h

stdafx.h:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+3

, RenderWindow, HINSTANCE mInstance, windows.h RenderWindow.h. , , RenderWindow, windows.h.

Have you looked at the Pimpl idiom ? This allows you to hide private members. A side effect is that you do not need to include headings in the heading of your class.

+3
source

All Articles