Solved

Problems with Window class

Posted on 2011-02-23
4
611 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
ID: 34965824
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
ID: 34968843
Hi,

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

Ocrana
0
 
LVL 33

Expert Comment

by:sarabande
ID: 34969768
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
ID: 34971338
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

815 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

13 Experts available now in Live!

Get 1:1 Help Now