Re: [wtl] Re: How to get rid of CS_DBLCLKS for my custom Static control?
- Makes sense, though it's not apparent to me where ATL is calling RegisterClassEx and I'm too lazy at the moment to dig for it.
Anyway, if this control exists on a dialog resource that you own, could you create the window class yourself, register it, and then in the dialog editor use the Custom Control toolbox item (which I believe allows you to specify the custom window class)?
Other than that, I'd be interested to here what the answer is. Seems to me that if you don't own the creation of the control, either because you are truly sublcassing an already-existing control that was not created by you or because it was created via a dialog resource that you don't own, then you can't use a custom window class, other than by destroying the existing window and replacing it with a window of your own window class.
My impression is thus that if you own the dialog resource, the easiest thing to try is the Custom Control toolbox item, and if that fails manually create the control in your OnInitDialog instead of having it created by the dialog resource.
-------------- Original message --------------
From: "avewtl" <avewtl@...>
Thanks for the info.
If I'm not mistaken, the window class gets registered when Create()
The problem is, I never call Create() since SubclassWindow() is used
to associate existing static control with my class. So the
GetWndClassInfo() function should not have been called.
--- In email@example.com, "Michael Stephenson" <domehead100@...>
> I think you need to use DECLARE_WND_CLASS_EX instead of
> DECLARE_WND_SUPERCLASS if you want to specifiy window class
> DECLARE_WND_CLASS_EX, you supply a class name, a dwStyleparameter, and a
> background brush.adjusting the
> If you do this, you can probably take out your stuff about
> CS_DBLCLKS class style because you shouldn't have to do thatanymore.
> That way I understand it is that these DECLARE_WND... macros do is
> static method in your class called GetWndClassInfo that returns anWNDCLASSEX
> ATL::CWndClassInfo reference (this is mostly a wrapper around the
> structure). Then, when Create is called, it calls yourGetWndClassInfo
> function to get the window class parameters that it will use whencreating
> the window.actually gets
> One thing I'm not entirely clear on is how the window class
> registered. I suppose the ATL library does that automatically atsome
> point, but I'm not sure about where or when.From there
> You might find it interesting to put your cursor on one of the
> DELCARE_WND... macros and press F12 to go to it's definition.
> you can drill down further. This is a useful technique esp. withWTL where
> often there is no documentation. Since it's part of the ATLlibrary, there
> is some documentation in MSDN covering CWndClassInfo that youmight find
> helpful.Of avewtl
> Hope this helps.
> From: firstname.lastname@example.org [mailto:email@example.com] On Behalf
> Sent: Wednesday, July 18, 2007 1:47 PMcontrol?
> To: firstname.lastname@example.org
> Subject: [wtl] How to get rid of CS_DBLCLKS for my custom Static
> Hi all,
> I have a customized static control class:
> template<class T, class TBase = CStatic, class TWinTraits =
> class ATL_NO_VTABLE CCustomStaticCtrl : public CWindowImpl<T,
> DECLARE_WND_SUPERCLASS(_T("CustomStaticCtrl "),
> I use this class to subclass a static control in a dialog. Then I
> call the following to get rid of the CS_DBLCLKS style (which is
> unwanted for my custom control):
> LONG_PTR dwNewLong = (~CS_DBLCLKS) & (::GetClassLongPtr(pT-
> >m_hWnd, GCL_STYLE));
> ::SetClassLongPtr(pT->m_hWnd, GCL_STYLE, dwNewLong);
> However, all my static controls in the application lose their
> CS_DBLCLKS style (found in Spy++).
> What is the right way to get rid of CS_DBLCLKS for my custom
> control? Thanks.[Non-text portions of this message have been removed]
> [Non-text portions of this message have been removed]