⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 displayitem.hpp

📁 一个WinCE6。0下的IP phone的源代码
💻 HPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#pragma once

#ifndef __DISPLAYITEM_HPP__
#define __DISPLAYITEM_HPP__

#include <windows.h>


//EXTERN_C const IID IID_IVoIPDisplayItem;
// {C4A8921C-ED7C-4f30-8495-E55CB851AE18}
DEFINE_GUID(IID_IVoIPDisplayItem, 0xc4a8921c, 0xed7c, 0x4f30, 0x84, 0x95, 0xe5, 0x5c, 0xb8, 0x51, 0xae, 0x18);

//EXTERN_C const IID IID_IVoIPDisplayControl;
// {722C3636-3598-4538-B569-73D65F35FD8D}
DEFINE_GUID(IID_IVoIPDisplayControl, 0x722c3636, 0x3598, 0x4538, 0xb5, 0x69, 0x73, 0xd6, 0x5f, 0x35, 0xfd, 0x8d);

//EXTERN_C const IID IID_IVoIPLabeledEditDisplayItem;
// {9D78EF29-F7A5-485f-9906-6ACA27E11F05}
DEFINE_GUID(IID_IVoIPLabeledEditDisplayItem, 0x9d78ef29, 0xf7a5, 0x485f, 0x99, 0x6, 0x6a, 0xca, 0x27, 0xe1, 0x1f, 0x5);

//EXTERN_C const IID IID_IVoIPTextDisplayItem;
// {474E4015-2D0B-4326-8693-BC8999539FCC}
DEFINE_GUID(IID_IVoIPTextDisplayItem, 0x474E4015, 0x2d0b, 0x4326, 0x86, 0x93, 0xbc, 0x89, 0x99, 0x53, 0x9f, 0xcc);

interface DECLSPEC_UUID("C4A8921C-ED7C-4f30-8495-E55CB851AE18") IVoIPDisplayItem
{
public:
    virtual ~IVoIPDisplayItem() {};

    //Queries interface
    virtual
    HRESULT
    QueryInterface(
        REFIID riid,
        __deref_out void** ppvObject
        ) = 0;

    //Draws the item into the specified rectangle with the specified hdc
    virtual
    HRESULT
    Draw(
        HDC hdc,                        //Device context to draw into
        __in const RECT* pRectangle,    //rectangle to draw into (there is no client rect associated with the item)
        BOOL IsSelected,                //flag indicating whether this item is selected
        BOOL IsTopItem = FALSE          //flag indicating whether this item is top item
        ) = 0;

    //Sets the main text of the item
    virtual
    HRESULT
    SetText(
        __in const WCHAR* pText
        ) = 0;

    //Gets the main text from the item
    virtual
    HRESULT
    GetText(
        __out_ecount(cchBuffer) WCHAR* pBuffer, //buffer to hold the text
        int cchBuffer                   //character count of the buffer
        ) = 0;

    //Gets the text of a specified subitem in the control
    virtual
    HRESULT
    GetSubItemText(
        int Index,                      //subitem text to get
        __out_ecount(cchBuffer) WCHAR* pBuffer, //buffer to hold the text
        UINT cchBuffer                  //character count of the buffer
        ) = 0;

    //In the case these are cased in a ownerdraw, variable height listbox,
    //the item must size itself
    virtual
    BOOL
    GetHeight(
        __out UINT* pHeight
        ) = 0;

    //check to see if this displayitem needs a tool tip
    //An item needs a tooltip if it is a singleline item that cannot fit on a single line
    virtual
    BOOL
    NeedsToolTip(
        __in RECT* pRectangle
        ) = 0;

    //check to see if this displayitem is selectalbe
    //a valid scenario for this is if there is sub popup menu inside a popup menu
    //then the collection label item will be un-selectable
    virtual
    BOOL
    IsSelectable(
        void
        ) = 0;
};

/*------------------------------------------------------------------------------
    CVoIPDisplayItem

    Base class that implements all the methods of IVoIPDisplayItem -
    but as non-impl's (return S_FALSE)
------------------------------------------------------------------------------*/
class CVoIPDisplayItem :
    public IVoIPDisplayItem
{
public:
    virtual ~CVoIPDisplayItem() { }

    // Draws a band for the display item
    HRESULT
    DrawBand(
        HDC hdc,                        //Device context to draw into
        __in const RECT* pRectangle,    //rectangle to draw into
        BOOL IsSelected,                //flag indicating whether this item is selected
        BOOL IsTopItem = FALSE          //flag indicating whether this item is top item
        );

    // IVoIPDisplayItem interface methods
    __override
    HRESULT
    QueryInterface(
        REFIID riid,
        __deref_out void** ppvObject
        )
    {
        if (ppvObject)
        {
            *ppvObject = NULL;
        }
        return E_NOTIMPL;
    }

    //Draws the item into the specified rectangle with the specified hdc
    __override
    HRESULT
    Draw(
        HDC hdc,                        //Device context to draw into
        __in const RECT* pRectangle,    //rectangle to draw into (there is no client rect associated with the item)
        BOOL IsSelected,                //flag indicating whether this item is selected
        BOOL IsTopItem = FALSE          //flag indicating whether this item is top item
        )
    {
        ASSERT(FALSE);
        return S_FALSE;
    }

    //Sets the main text of the item
    __override
    HRESULT
    SetText(
        __in const WCHAR* pText
        )
    {
        return S_FALSE;
    }

    //Gets the main text from the item
    __override
    HRESULT
    GetText(
        __out_ecount(cchBuffer) WCHAR* pBuffer, //buffer to hold the text
        int cchBuffer                   //character count of the buffer
        )
    {
        return S_FALSE;
    }

    //Gets the text of a specified subitem in the control
    __override
    HRESULT
    GetSubItemText(
        int Index,                      //subitem text to get
        __out_ecount(cchBuffer) WCHAR* pBuffer, //buffer to hold the text
        UINT cchBuffer                  //character count of the buffer
        )
    {
        return S_FALSE;
    }

    __override
    BOOL
    GetHeight(
        __out UINT* pHeight
        )
    {
        return FALSE;
    }

    __override
    BOOL
    NeedsToolTip(
        __in RECT* pRectangle
        )
    {
        return FALSE;
    }

    __override
    BOOL
    IsSelectable(
        void
        )
    {
        return TRUE;
    }
};


interface DECLSPEC_UUID("722C3636-3598-4538-B569-73D65F35FD8D") IVoIPDisplayControl
{
public:
    //Informs the item to show/hide its subcontrols
    virtual
    HRESULT
    ShowControls(
        BOOL fVisible
        ) = 0;

    //Informs the item its position onscreen so it can position its subcontrols
    virtual
    HRESULT
    PositionControls(
        HWND VirtualListBox,    //HWND of the ListView calling this function
        __in RECT* pRectangle   //Rectangle in which the item will be drawn
        ) = 0;

    //if this item has controls overlayed on it - this call is sent before
    //deleteing the item so the item can destroy its controls properly.
    virtual
    HRESULT
    RemoveControls(
        void
        ) = 0;

    //informs the display item to set focus to it's child control
    //(if any)
    virtual
    BOOL
    SetFocus(
        void
        ) = 0;
};


interface DECLSPEC_UUID("9D78EF29-F7A5-485f-9906-6ACA27E11F05") IVoIPLabeledEditDisplayItem
{
public:
    virtual
    HRESULT
    SetLabelText(
        __in const WCHAR* pBuffer
        ) = 0;

    virtual
    HRESULT
    SetNumbersOnly(
        BOOL NumbersOnly
        ) = 0;

    virtual
    HRESULT
    SetReadOnly(
        BOOL ReadOnly
        ) = 0;
};

interface DECLSPEC_UUID("474E4015-2D0B-4326-8693-BC8999539FCC") IVoIPTextDisplayItem
{
public:
    virtual
    HRESULT
    SetHighlightIndices(
        int Begin,
        int End
        ) = 0;

    virtual
    HRESULT 
    SetCookie(
        UINT Cookie
        ) = 0;

    virtual
    UINT
    GetCookie(
        void
        ) = 0;    
    
    virtual
    HRESULT 
    SetComPtr(
        __in_opt IUnknown* pUnk
        ) = 0;

    virtual
    HRESULT
    GetComPtr(
        __deref_out_opt IUnknown** ppUnk
        ) = 0;    
};

#endif //!defined __DISPLAYITEM_HPP__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -