logoscreen.cpp

来自「一个WinCE6。0下的IP phone的源代码」· C++ 代码 · 共 108 行

CPP
108
字号
//
// 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.
//

#include "LogoScreen.hpp"
#include "Common.hpp"

LRESULT
LogoScreen_t::OnEraseBackground(
    HWND    hwnd,
    UINT    LogoResourceId,
    HDC     hdc, 
    LPARAM  lParam
    )
{
    HRESULT hr;
    PaintHelper_t paint;

    hr = paint.Attach(hdc);
    ASSERT(SUCCEEDED(hr));

    RECT ClientRect;
    GetClientRect(hwnd, &ClientRect);

    if ((HDC)m_BackBuffer == NULL)
    {
        hr = m_BackBuffer.CreateCanvas(
            hwnd,
            ClientRect.right,
            ClientRect.bottom
            );
        ASSERT(SUCCEEDED(hr));
    }

    //use lParam as a workaround to request immediate paint
    PaintHelper_t& paintToUse = (lParam || ((HDC)m_BackBuffer == NULL)) ? paint : m_BackBuffer;

    //first draw the background
    PHDrawBackground(paintToUse, &ClientRect);

    //Draw the logo
    Bitmap_t Logo;

    hr = Logo.Attach(
        GlobalData_t::s_GDICacheObject.LoadCachedBitmap(
            LogoResourceId
            )
        );
    if (FAILED(hr))
    {
        ASSERT(FALSE);
        return 1;
    }

    RECT LogoRect = ClientRect;
    LogoRect.left = ClientRect.right - Logo.Width();
    LogoRect.bottom = LogoRect.top + Logo.Height();

    TransparentImage(
        paintToUse,
        LogoRect.left,
        LogoRect.top,
        Logo.Width(),
        Logo.Height(),
        Logo,
        0,
        0,
        Logo.Width(),
        Logo.Height(),
        PHGetColor(phcDefaultTransparentColor)
        );

    return 1;
}

LRESULT
LogoScreen_t::OnPaint(
    HWND hwnd
    )
{
    HRESULT hr = S_OK;
    PaintHelper_t paint;

    hr= paint.Begin(hwnd);
    if (FAILED(hr))
    {
        return 0;
    }

    if ((HDC)m_BackBuffer != NULL)
    {
        paint = m_BackBuffer;
    }

    paint.End();
    return 1;
}

⌨️ 快捷键说明

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