Sign in to follow this  
DayOldPudding

Using windows types from a C++ class library

Recommended Posts

DayOldPudding    100
Hi, I'm trying to create a C++ Windows Forms Application in Visual Studio 2008 that will eventually become a level editor. My hope is to wrap up my game-code (which exists in a separate project) into a class library, and use that DLL in both the level editor, and the game executable itself. I've read that I can pass an HWND from a WinForm component to my class library, and use that as a DirectX drawing surface. Sounds great, however I can't seem to get the definition for HWND without introducing a river of compiler errors complaining about IServiceProvider being an ambiguous symbol... I'm #including <windows.h> from within the class library to get the HWND definition. Is that the wrong way to do this? I admit, I don't know enough about DLL development to be sure I'm asking the right questions. Any help would be appreciated!

Share this post


Link to post
Share on other sites
DayOldPudding    100
For instance, here's the only .h in the class library:


// DXClassLibrary.h
#pragma once

#include <windows.h>

using namespace System;

namespace DXClassLibrary {

public ref class Class1
{
HRESULT InitDevice( HWND hWnd );
};
}




This produces an error:
Error 1 error C2872: 'IServiceProvider' : ambiguous symbol C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\ocidl.h 6238

The "using namespace System;" was auto-generated by VS2008, and does seem to impact the situation. Moving it to before the #include results in 9 IServiceProvider errors instead of 1 when the code is left as stated above.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this