Loading ...
Sorry, an error occurred while loading the content.

Re: [wtl] Re: How to get rid of CS_DBLCLKS for my custom Static control?

Expand Messages
  • domehead100@comcast.net
    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
    Message 1 of 4 , Jul 18, 2007
    • 0 Attachment
      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()
      is called.

      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 wtl@yahoogroups.com, "Michael Stephenson" <domehead100@...>
      wrote:
      >
      > I think you need to use DECLARE_WND_CLASS_EX instead of
      > DECLARE_WND_SUPERCLASS if you want to specifiy window class
      styles. In
      > DECLARE_WND_CLASS_EX, you supply a class name, a dwStyle
      parameter, and a
      > background brush.
      >
      > If you do this, you can probably take out your stuff about
      adjusting the
      > CS_DBLCLKS class style because you shouldn't have to do that
      anymore.
      >
      > That way I understand it is that these DECLARE_WND... macros do is
      create a
      > static method in your class called GetWndClassInfo that returns an
      > ATL::CWndClassInfo reference (this is mostly a wrapper around the
      WNDCLASSEX
      > structure). Then, when Create is called, it calls your
      GetWndClassInfo
      > function to get the window class parameters that it will use when
      creating
      > the window.
      >
      > One thing I'm not entirely clear on is how the window class
      actually gets
      > registered. I suppose the ATL library does that automatically at
      some
      > point, but I'm not sure about where or when.
      >
      > 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.
      From there
      > you can drill down further. This is a useful technique esp. with
      WTL where
      > often there is no documentation. Since it's part of the ATL
      library, there
      > is some documentation in MSDN covering CWndClassInfo that you
      might find
      > helpful.
      >
      > Hope this helps.
      >
      > ~Mike
      >
      >
      > _____
      >
      > From: wtl@yahoogroups.com [mailto:wtl@yahoogroups.com] On Behalf
      Of avewtl
      > Sent: Wednesday, July 18, 2007 1:47 PM
      > To: wtl@yahoogroups.com
      > Subject: [wtl] How to get rid of CS_DBLCLKS for my custom Static
      control?
      >
      >
      >
      > Hi all,
      >
      > I have a customized static control class:
      >
      > template<class T, class TBase = CStatic, class TWinTraits =
      > CControlWinTraits>
      > class ATL_NO_VTABLE CCustomStaticCtrl : public CWindowImpl<T,
      TBase,
      > TWinTraits>
      > {
      > public:
      >
      > DECLARE_WND_SUPERCLASS(_T("CustomStaticCtrl "),
      > TBase::GetWndClassName())
      >
      > .....
      >
      > };
      >
      > 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
      Static
      > control? Thanks.
      >
      >
      >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >




      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.