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

📄 select.cpp

📁 《Visual C++ Bible》或者说是《Visual C++ 宝典》的对应的源码文件
💻 CPP
字号:
// select.cpp : Line selection helper functions
//

#include "stdafx.h"
#include "gettext.h"

#include "mainfrm.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

//-----------------------------------------------------------------------------
// [GETTEXT] Query rectangle around currently selected lines of text.
void DMainFrame::GetSelectedRect(CRect * prSelected)
{
    // If nothing selected, return an empty rectangle.
    if (d_nFocusMode != FOCUS_SELECT)
    {
        prSelected->SetRectEmpty();
        return;
    }

    // Order by min/max.
    int nMinSelect = min(d_nSelectFirst, d_nSelectLast);
    int nMaxSelect = max(d_nSelectFirst, d_nSelectLast);

    // Initialize left and right sides of selection rectangle.
    CRect rSelected;
    rSelected.left  = -32000;
    rSelected.right =  32000;

    // Set top line.
    rSelected.top    = (nMinSelect - d_iTopLine)     * d_cyLineHeight;
    rSelected.bottom = (nMaxSelect - d_iTopLine + 1) * d_cyLineHeight;

    // Query client area.
    CRect rClient;
    GetClientRect(&rClient);

    // Get intersection of client area with selected rectangle.
    prSelected->IntersectRect(&rSelected, &rClient);
}

//-----------------------------------------------------------------------------
// [GETTEXT] Invert set of lines using brute force CDC::InvertRect() function.
void DMainFrame::InvertLines(int nFirst, int nLast)
{
    // Get order straight.
    int nLow  = min (nFirst, nLast);
    int nHigh = max (nFirst, nLast);

    // Initialize first rectangle to invert.
    CRect rClient;
    GetClientRect(&rClient);
    rClient.top = (nLow - d_iTopLine) * d_cyLineHeight;
    rClient.bottom = rClient.top + d_cyLineHeight;

    // Fetch DC with client area clipping.
    CClientDC dc(this);

    // Loop from first to last, inverting as we go.
    while (nLow <= nHigh)
    {
        // Invert rectangle.
        dc.InvertRect(&rClient);

        // Update all relevant indexes and coordinates.
        nLow++;
        rClient.top    += d_cyLineHeight;
        rClient.bottom += d_cyLineHeight;
    }
}

⌨️ 快捷键说明

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