Re: PostMessage from a DLL
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 15 Dec 2005 11:51:20 -0500
One way around this that I've used is to subclass within the DLL. For example,
class CMyPublicInterface : public CSomeWndClass {
public:
static CMyPublicInterface * Create(...);
void DoThis();
void DoThat();
...
protected:
CMyPublicInterface();
public:
virtual ~CMyPublicInterface();
};
and in the DLL I do
class CMyPrivateInterface : public CMyPublicInterface {
protected:
int thing;
int object;
CWhatever stuff;
};
Because I have a protected constructor, the user cannot create an instance of the object
outside the DLL. The virtual destructor (always a good practice) means that the correct
object will be destroyed.
/* static */ CMyPublicInterface * CMyPubicInterface::Create(...)
{
return (CMyPublicInterface *)new CMyPrivateInterface(...);
//...or
return static_cast<CMyPublicInterface *>new CMyPrivateInterface(...);
}
void CMyPublicInterface::DoThis()
{
ASSERT_KINDOF(this, CMyPrivateInterface);
CMyPrivateInterface * p = (CMyPrivateInterface *)this;
// ... or
CMyPrivateInterface * p = dynamic_cast<CMyPrivateInterface *>(this);
p->DoThis();
}
A bit hokey, but it let me protect all the interface information so I could change the
implementation but not the public interface.
joe
On 14 Dec 2005 08:30:37 -0800, "Ajay Kalra" <ajaykalra@xxxxxxxxx> wrote:
>One way you can do it to use forward declaration:
>
>class CAnotherClass;
>
>class AFX_EXT_CLASS CComunication
>{
>public:
> SomeMethods
> SomeAttributes
>private:
> CAnotherClass* m_pManager;
>
>}
>
>Now you are not including the header file.
>
>----------
>Ajay Kalra
>ajaykalra@xxxxxxxxx
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- PostMessage from a DLL
- From: Stefano
- Re: PostMessage from a DLL
- From: Ajay Kalra
- Re: PostMessage from a DLL
- From: Stefano
- Re: PostMessage from a DLL
- From: Ajay Kalra
- Re: PostMessage from a DLL
- From: Stefan0
- Re: PostMessage from a DLL
- From: Ajay Kalra
- Re: PostMessage from a DLL
- From: Stefano
- Re: PostMessage from a DLL
- From: Ajay Kalra
- PostMessage from a DLL
- Prev by Date: MDI app view problem
- Next by Date: Re: Events from GROUPBOX
- Previous by thread: Re: PostMessage from a DLL
- Next by thread: Re: PostMessage from a DLL
- Index(es):
Relevant Pages
|