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

📄 drawbackground.cpp

📁 一个WinCE6。0下的IP phone的源代码
💻 CPP
字号:
//
// 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 <windows.h>
#include "Common.hpp"
#include "PaintHelper.hpp"
#include "Debug.hpp"
#include "Layout.hpp"
#include "Resource.h"


EXTERN_C
BOOL
WINAPI
PHDrawBackground(
    HDC hdc,
    RECT* pDrawRectangle
    )
{
    BOOL Success = FALSE;
    PaintHelper_t paint;
    bool UseBitmap = false;

    if (!pDrawRectangle || FAILED(paint.Attach(hdc)))
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        goto error;
    }

    if (UseBitmap)
    {
        Bitmap_t BackgroundBitmap;

        BackgroundBitmap.LoadBitmap(
            GlobalData_t::s_ModuleInstance,
            IDB_BACKGROUND
            );
        if (!BackgroundBitmap)
        {
            goto draw_simple_background;
        }

        PaintHelper_t paintSource;
        ce::auto_hdc hdcSource = CreateCompatibleDC(paint);
        if (FAILED(paintSource.Attach(hdcSource)))
        {
            goto draw_simple_background;
        }

        paintSource.SetBitmap(BackgroundBitmap);

        Success = StretchBlt(
            paint,
            pDrawRectangle->left,
            pDrawRectangle->top,
            RECTWIDTH(*pDrawRectangle),
            RECTHEIGHT(*pDrawRectangle),
            paintSource,
            0,
            0,
            BackgroundBitmap.Width(),
            BackgroundBitmap.Height(),
            SRCCOPY
            );
    }
    else
    {
        //GradientFill
        TRIVERTEX Vertex[2];
        GRADIENT_RECT Mesh;

        Vertex[0].x = pDrawRectangle->left;
        Vertex[0].y = pDrawRectangle->top;
        Vertex[0].Red = GetRValue(Colors_t::GradientTopBackgroundColor()) << 8;
        Vertex[0].Green = GetGValue(Colors_t::GradientTopBackgroundColor()) << 8;
        Vertex[0].Blue = GetBValue(Colors_t::GradientTopBackgroundColor()) << 8;
        Vertex[0].Alpha = 0x0000;

        Vertex[1].x = pDrawRectangle->right;
        Vertex[1].y = pDrawRectangle->bottom;
        Vertex[1].Red = GetRValue(Colors_t::GradientBottomBackgroundColor()) << 8;
        Vertex[1].Green = GetGValue(Colors_t::GradientBottomBackgroundColor()) << 8;
        Vertex[1].Blue = GetBValue(Colors_t::GradientBottomBackgroundColor()) << 8;
        Vertex[1].Alpha = 0x0000;

        Mesh.UpperLeft = 0;
        Mesh.LowerRight = 1;

        Success = GradientFill(
            paint,
            Vertex,
            _countof(Vertex),
            &Mesh,
            1,
            GRADIENT_FILL_RECT_V
            );
    }

    if (!Success)
    {
    draw_simple_background:
        paint.SetBkColor(Colors_t::DefaultBackgroundColor());
        Success = ExtTextOutW(paint, 0, 0, ETO_OPAQUE, pDrawRectangle, NULL, 0, NULL);
    }

error:
    return Success;
}

⌨️ 快捷键说明

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