Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems with Window class

Posted on 2011-02-23
4
Medium Priority
?
631 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 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 35

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

730 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