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

Re: Transparent edit control on aero glass

Expand Messages
  • He Shiming
    ... Hey, it looks like I ve nailed it. Take a look at AeroEdit.zip I uploaded. The method is quite simple. The first key is theme subclass, which is
    Message 1 of 11 , Feb 29, 2008
    • 0 Attachment
      --- In wtl@yahoogroups.com, Bjarke Viksøe <bjarke@...> wrote:
      >
      > Hi,
      >
      > I've been trying to recreate the search Edit myself, but hasn't been
      > able to nail it either. I think the theme subclasses are the key. If
      > you look at how the Explorer/Vista search-edit are usually composed,
      > then there is an container window, edit window and toolbar for the
      > dropdown button. I'd imagine that you'll need to set a theme on all of
      > these controls, which might explain the Edit and SearchBox subclasses
      > in the (appalling) documentation.
      >
      > bjarke
      >

      Hey, it looks like I've nailed it. Take a look at AeroEdit.zip I
      uploaded.

      The method is quite simple. The first key is theme subclass, which is
      accomplished using m_edit.SetWindowTheme(NULL,
      L"SearchBoxEditComposited::Edit"); . The second key is the
      WM_PRINTCLIENT message handling of the container window.

      From what I understand, the edit control do need a container window to
      handle background painting. I discovered that when the subclass theme
      is set for the edit control, it'll call DrawThemeParentBackground or
      sending WM_PRINTCLIENT to the parent window for background painting.
      The edit control itself doesn't appear to have touched the background.
      And therefore it made transparency simpler.

      I'm not sure how toolbars and comboboxes are implemented, but the same
      method might be useful. Windows Explorer's search box has a complex
      child window structure. From what I understand, such structure is used
      merely to simplify painting.

      Some notes about the sample code: I didn't provide any code to handle
      situations without aero glass. And it seemed impossible to set the
      background transparent when the keyboard focus is received.

      Cheers!
      He Shiming
    • Alain Rist
      Hi He Shiming, You may want to check this with my AeroDialog sample. Insert in MainDlg.h: // MainDlg.h : interface of the CMainDlg class //
      Message 2 of 11 , Mar 1, 2008
      • 0 Attachment
        Hi He Shiming,

        You may want to check this with my AeroDialog sample.

        Insert in MainDlg.h:

        // MainDlg.h : interface of the CMainDlg class
        //
        /////////////////////////////////////////////////////////////////////////////

        #pragma once

        // ------------- insert ---------
        void WTL::aero::CCtrl<WTL::CEdit>::CtrlPaint(HDC hdc, RECT& rCtrl, RECT&
        rPaint)
        {
        if (GetFocus() == m_hWnd)
        DefCtrlPaint(hdc, rPaint);
        else
        {
        int iLength = GetWindowTextLength();
        if (iLength > 0)
        {
        CTempBuffer<WCHAR> sText(++iLength);
        GetWindowText(sText, iLength);

        rCtrl.left += 3;
        rCtrl.top += 1;
        POINT pt = {rCtrl.left, rCtrl.top};
        int pos = CharFromPos(pt);

        CDCHandle dc(hdc);
        HFONT hf = dc.SelectFont(GetFont());
        HRESULT hr = DrawPartText(dc,
        EP_EDITTEXT,
        ETS_NORMAL,
        sText + pos,
        &rCtrl ,
        DT_VCENTER/*uFormat*/,
        DTT_COMPOSITED/*dwFlags*/,
        6/*iGlowSize*/
        );
        dc.SelectFont(hf);
        }
        }
        }
        // ----------- end insert ------------

        Note that it will give a transparent background to the combo edit as well.

        cheers,
        AR

        ----- Original Message -----
        From: He Shiming
        To: wtl@yahoogroups.com
        Sent: Friday, February 29, 2008 3:20 PM
        Subject: [wtl] Re: Transparent edit control on aero glass

        >Any more insights?
      • Bjarke Viksøe
        ... That s great, but I m talking about actually replicating the look n feel of the Explorer SearchBox (wordwheel) - including the frame and semi/whitish
        Message 3 of 11 , Mar 1, 2008
        • 0 Attachment
          --- In wtl@yahoogroups.com, "He Shiming" <heshiming@...> wrote:
          >
          > --- In wtl@yahoogroups.com, Bjarke Viksøe <bjarke@> wrote:
          > >
          > > Hi,
          > >
          > > I've been trying to recreate the search Edit myself...
          > > bjarke
          > >
          >
          > Hey, it looks like I've nailed it. Take a look at AeroEdit.zip I
          > uploaded.
          >

          That's great, but I'm talking about actually replicating the
          look'n'feel of the Explorer SearchBox (wordwheel) - including the
          frame and semi/whitish transparency. Well... I believe that it is
          possible to create a decent SearchBox, but it's specifically the
          Breadcrumbs control I want to write a sample for.

          I wonder why the documentation on MSDN is so crappy? When I look at
          any top 10 feature list of Vista, the new Search capability is always
          mentioned at the very top. You would think that Microsoft would want
          other applications to have a similar visual appearance if it's such a
          great feature. Obviously MS wants to be able to add the SearchBox to
          their own applications, so they have to document it (so says all the
          anti-trust lawsuits) but it appears to me that the MSDN page was
          specifically created to fend off laywers rather than to give actual
          programmer information.

          bjarke
        • He Shiming
          ... always ... a ... I see. But it s really not that difficult to implement the search box. Obviously Microsoft doesn t want to share the information with us.
          Message 4 of 11 , Mar 1, 2008
          • 0 Attachment
            --- In wtl@yahoogroups.com, Bjarke Viksøe <bjarke@...> wrote:
            >
            > That's great, but I'm talking about actually replicating the
            > look'n'feel of the Explorer SearchBox (wordwheel) - including the
            > frame and semi/whitish transparency. Well... I believe that it is
            > possible to create a decent SearchBox, but it's specifically the
            > Breadcrumbs control I want to write a sample for.
            >
            > I wonder why the documentation on MSDN is so crappy? When I look at
            > any top 10 feature list of Vista, the new Search capability is
            always
            > mentioned at the very top. You would think that Microsoft would want
            > other applications to have a similar visual appearance if it's such
            a
            > great feature. Obviously MS wants to be able to add the SearchBox to
            > their own applications, so they have to document it (so says all the
            > anti-trust lawsuits) but it appears to me that the MSDN page was
            > specifically created to fend off laywers rather than to give actual
            > programmer information.
            >
            > bjarke
            >

            I see. But it's really not that difficult to implement the search
            box. Obviously Microsoft doesn't want to share the information with
            us. So, in my opinion, instead of trying to figure out how to create
            an exact replica, we might just think of creating it the easiest way.

            For instance, vista explorer used a static control to display
            that "Search" cue banner text. But it's much easier to just paint
            this text in the container window. As far as the etched white
            background is concerned, I suppose they used theme subclasses to draw
            it. However, I'd rather paint it using a bitmap(which made it easier
            to port to win2k and xp).

            I guess the green/blue gradient background of the toolbar is also
            painted using a bitmap. I have no idea where this resource is located
            but I found this stuff in Windows Live Mail and Windows Live Photo
            Gallery. The toolbar image is stored as a PNG in the resource. The
            drawing routine took the edge pixels and draw it without scaling, and
            then the center pixels with scaling for a better output. The
            technique is explained here: http://www.codeproject.com/KB/GDI-
            plus/enhancedimageprj.aspx . The same technique can be used to draw
            the etched white background.

            The breadcrumb is just a toolbar. Microsoft didn't bother to create a
            new control. The "combobox dropdown button" is actually a toolbar
            button I guess. When clicked, the combobox is shown and the toolbar
            is hidden.

            In any case, there's still a lot to do. I'll post some samples if I'm
            successful in re-creating the whole aero navbar.

            Best regards,
            He Shiming
          Your message has been successfully submitted and would be delivered to recipients shortly.