// This is a part of the Active Template Library. // Copyright (C) Microsoft Corporation // All rights reserved. // // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. // See these sources for detailed information regarding the // Active Template Library product. #pragma once #include #if !defined(_ATL_USE_WINAPI_FAMILY_DESKTOP_APP) #error This file is not compatible with the current WINAPI_FAMILY #endif #include #include #pragma once #ifndef __cplusplus #error ATL requires C++ compilation (use a .cpp suffix) #endif #include <__atlmfc_core.h> #pragma warning(push) #pragma warning(disable : _ATLMFC_DISABLED_WARNINGS) #pragma pack(push,_ATL_PACKING) namespace ATL { /// /// This class is an ATL implementation of a window that is placed on a host window provided by the Shell /// for Rich Preview. class CAtlPreviewCtrlImpl : public CWindowImpl, public IPreviewCtrl { public: BEGIN_MSG_MAP(CAtlPreviewCtrlImpl) MESSAGE_HANDLER(WM_PAINT, OnPaint) END_MSG_MAP() /// /// Constructs a preview control object. CAtlPreviewCtrlImpl(void) : m_clrText(0), m_clrBack(RGB(255, 255, 255)), m_plf(NULL) { } /// /// Destructs a preview control object. virtual ~CAtlPreviewCtrlImpl(void) { } /// Handles WM_PAINT message. /// Set to WM_PAINT. /// This parameter is not used. /// This parameter is not used. /// When this function returns it contains TRUE. /// Always returns 0. LRESULT OnPaint( _In_ UINT nMsg, _In_ WPARAM wParam, _In_ LPARAM lParam, _Out_ BOOL& bHandled) { UNREFERENCED_PARAMETER(nMsg); UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam); PAINTSTRUCT ps; this->CWindowImpl::BeginPaint(&ps); DoPaint(ps.hdc); this->CWindowImpl::EndPaint(&ps); bHandled = TRUE; return 0; } /// /// Called by a Rich Preview handler to create the Windows window. /// A handle to the host window supplied by the Shell for Rich Preview. /// Specifies initial size and position of the window. /// TRUE if creation succeeded; otherwise FALSE. virtual BOOL Create( _In_ HWND hWndParent, _In_ const RECT* prc) { _U_RECT rect((LPRECT)prc); this->CWindowImpl::Create(hWndParent, rect); return TRUE; } /// /// Called by a Rich Preview handler when it needs to destroy this control. virtual void Destroy() { this->CWindowImpl::DestroyWindow(); } /// /// Sets a new parent for this control. /// A handle to the new parent window. virtual void SetHost(_In_ HWND hWndParent) { this->CWindowImpl::SetParent(hWndParent); } /// /// Sets input focus to this control. virtual void Focus() { this->CWindowImpl::SetFocus(); } /// /// Tells this control to redraw. virtual void Redraw() { this->CWindowImpl::RedrawWindow(); } /// /// Sets a new bounding rectangle for this control. /// Usually new bounding rectangle is set when the host control is resized. /// Specifies the new size and position of preview control. /// Specifies whether the control should be redrawn. virtual void SetRect( _In_ const RECT* prc, _In_ BOOL bRedraw) { DWORD dwFlags = SWP_NOZORDER; if (!bRedraw) { dwFlags |= SWP_NOREDRAW; } this->CWindowImpl::SetWindowPos(NULL, prc, dwFlags); } /// /// Called by a Rich Preview handler when it needs to set visuals of rich preview content. /// Background color of preview window. /// Text color of preview window. /// Font used to display texts in preview window. virtual void SetPreviewVisuals( _In_ COLORREF clrBack, _In_ COLORREF clrText, _In_ const LOGFONTW *plf) { m_clrText = clrText; m_clrBack = clrBack; m_plf = plf; } protected: /// Called by the framework to render the preview. /// A handle to a device context for painting. Text color of preview window. COLORREF m_clrText; /// Background color of preview window. COLORREF m_clrBack; /// Font used to display texts in preview window. const LOGFONTW* m_plf; }; } //namespace ATL #pragma pack(pop) // _ATLMFC_DISABLED_WARNINGS #pragma warning(pop)