Solved

Problems with Window class

Posted on 2011-02-23
4
607 Views
Last Modified: 2012-05-11
Hello,

I have a problem with a CWindow class I use in a DLL. I load the class from the DLL.
The compile throws a message, and I am sure this is a problem of some crashes, too.
So anybody can give me a hint what is wrong here?

Ocrana

Compileroutput:
1>c:\projects\dvdranger2\trunk\dvdconvdll\mediawnd.h(120) : warning C4275: non dll-interface class 'ATL::CWindow' used as base for dll-interface class 'ATL::CWindowImplRoot<TBase>'
1>        with
1>        [
1>            TBase=ATL::CWindow
1>        ]
1>        c:\program files (x86)\microsoft visual studio 9.0\vc\atlmfc\include\atlwin.h(686) : see declaration of 'ATL::CWindow'
1>c:\projects\dvdranger2\trunk\dvdconvdll\mediawnd.h(289) : warning C4251: 'MediaWnd::frameBuffers' : class 'std::list<_Ty>' needs to have dll-interface to be used by clients of class 'MediaWnd'
1>        with
1>        [
1>            _Ty=BYTE *
1>        ]
#pragma once
#ifdef MOBILE_CONV_DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif

#include <atlbase.h>
#include <atlctl.h>
#include <list>

class DLLEXPORT MediaWnd : public CWindowImpl<MediaWnd, CWindow>
{
	BEGIN_MSG_MAP(MediaWnd)
		DEFAULT_REFLECTION_HANDLER()
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		....
	END_MSG_MAP()

public:
	MediaWnd();
	virtual ~MediaWnd();

	virtual void CreateWnd(HWND hWnd);
	....
	std::list<BYTE *> frameBuffers;
	....
	
}

Open in new window

0
Comment
Question by:Ocrana
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
Comment Utility
You are hitting a mine field here - see http://support.microsoft.com/kb/168958 ("How to export an instantiation of a Standard Template Library (STL) class and a class that contains a data member that is an STL object"). In short: Don't make an STL object publicly accessible in a DLL, always use accessors that conceal the object, e.g.
#pragma once
#ifdef MOBILE_CONV_DLL
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif

#include <atlbase.h>
#include <atlctl.h>
#include <list>

class DLLEXPORT MediaWnd : public CWindowImpl<MediaWnd, CWindow>
{
	BEGIN_MSG_MAP(MediaWnd)
		DEFAULT_REFLECTION_HANDLER()
		MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
		....
	END_MSG_MAP()

public:
	MediaWnd();
	virtual ~MediaWnd();

	virtual void CreateWnd(HWND hWnd);
	....

        BYTE* GetNextFrame() { */ ... */ }

protected:
	std::list<BYTE *> frameBuffers;
	....
	
}

Open in new window

0
 

Author Comment

by:Ocrana
Comment Utility
Hi,

I have set it to protected but the compiler is still naging with the same issue. So no change there.

Ocrana
0
 
LVL 32

Expert Comment

by:sarabande
Comment Utility
the std::list<BYTE*> cannot exported/imported between dll boundaries (at least not without efforts).

so you may think of using array of BYTE* instead.

Sara
0
 

Author Comment

by:Ocrana
Comment Utility
I use the std:list<BYTE*> for internal use.It is portected now. It contains the rendering buffer for the MEdiaWnd (a set of images). A "simple" Byte Arry is the worst solution.But why the compile see a protected member as a export one? It is not public, so not available to the export.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now