Jump to content
  • Advertisement
Sign in to follow this  

Using windows types from a C++ class library

This topic is 3094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!