Re: CWindowImpl-derived classes in dialog boxes

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 04/09/04


Date: Fri, 9 Apr 2004 00:04:16 -0700

Now I remember what was the principle problem with ATL
for User Controls - its startup windowproc does not allocate
a class instance - it assumes it is created from an existing class
instance. I meant to write an extension that actually manages
its own lifetime so one can write User Controls, but never
got to that...

The solution lies in writing some code in WM_INITDIALOG.
What you do is you place static controls on your dialog, then
you either destroy them after you get their coordinates and
create your controls in their places, or you simply subclass them
using your real control classes and take over everything.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"ColdShine" <coldshine_NO_UNDERSCORES_@hotmail.com> wrote in message
news:c5344t$2o8ffm$1@ID-214373.news.uni-berlin.de...
> >> So, is there any safe way of creating ATL controls à-là plain SDK?
> >
> > Are you trying to host a full ATL control?
> >
> > If so, learn to love CAxWindow and its sibling CAxDialog. There is
> > lots of heavy lifting to do in this effort, and CAxWindow does a
> > fairly decent job. And if that is not enough, have a look at:
> >
> > http://www.microsoft.com/msj/1299/Containment/Containment.aspx
> >
> > I think when you study this, it is not for the faint of heart. And if
> > you want to do this without CAxWindow, then I wish you a good summer.
>
> Uhm, I think that would be shooting a butterfly with a cannon :P
> No ActiveX, I only meant a simple ATL control, that is:
>
> class CMyControl : public CWindowImpl<CMyControl>
> {
> public:
>     DECLARE_WND_CLASS(_T("MyControl class"))
>
>     BEGIN_MSG_MAP(CMyControl)
>         ...
>     END_MSG_MAP()
> };
>
> Once I declare such a window class, I'd like to draw a "MyControl class"
> control in the dialog designer, but where do I register the class? When?
> The Windows code to create a dialog from a resource template invokes
> ::CreateWindowEx(), thus _AtlWinModule.AddCreateWndData() is never called
> (and of course, the actual class instance is not even allocated); this
> surely leads to something bad.
>
> I wonder if there's any way of meeting the ease of design provided by
> resource editor with the ease of coding provided by ATL.
>
> --
> ColdShine
>
> "Experience is a hard teacher: she gives the test first, the lesson
> afterwards."
> - Vernon Sanders law
>
>


Relevant Pages

  • Re: What does an Active X control mean by Accelerator?
    ... titled something about extending ATL ... >> and after creating the control to subclass the child window using a ... > keys. ...
    (microsoft.public.win32.programmer.ole)
  • Re: Quest: Creating an ActiveX panel control...
    ... I think you need to start from the basics on creating ActiveX controls. ... always prefer using ATL rather than MFC, ...
    (microsoft.public.vc.mfc)
  • Re: ocx creation
    ... There are two options - ATL and MFC. ... framework and it offers extensive support for writing ActiveX ... Controls. ...
    (microsoft.public.win32.programmer.ole)
  • Re: Controls
    ... If you want to use MFC, why bother with ATL in the first place? ... for Windows and Common Controls. ... Microsoft MVP, MCSD ...
    (microsoft.public.vc.atl)
  • Re: About HWND of the dialog in the CDiloag based class
    ... > The second parameter is the ID of the button like ... looks a little bit like a cross between a WindowProc and a DialogProc. ... > is how to refer to the properties of the controls in it. ... Jeff Partch ...
    (microsoft.public.vc.mfc)