Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/141.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ MFC CEdit-绘制部分长度的背景_C++_Mfc_Cedit - Fatal编程技术网

C++ MFC CEdit-绘制部分长度的背景

C++ MFC CEdit-绘制部分长度的背景,c++,mfc,cedit,C++,Mfc,Cedit,我想有一个CEdit控件,背景画一半长度或在其长度的任何其他部分 我已经实现了以下代码 HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor); if (nCtlColor == CTLCOLOR_EDIT) {

我想有一个CEdit控件,背景画一半长度或在其长度的任何其他部分

我已经实现了以下代码

    HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
        HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
    
        if (nCtlColor == CTLCOLOR_EDIT)
        {
    
            if (pWnd->GetDlgCtrlID() == IDC_MY_NORMAL_PERCENT_BOX)
            {
                // Set the text color to red
                pDC->SetTextColor(RGB(255, 0, 0));
    
                CRect rc;
                // Get the client area of the edit control
                m_CTV_Normal_Percent_Box_Ctrl.GetClientRect(&rc);
                m_CTV_Normal_Percent_Box_Ctrl.ScreenToClient(&rc);
                // Apply the device context to the client area of the edit control
                pDC->Rectangle(0, 0, rc.Width()/2, rc.Height());
    
                // Set the background mode for text to transparent 
                // so background will show thru.
                pDC->SetBkMode(TRANSPARENT);
    
                // Return handle to our CBrush object
                hbr = m_brush;
    
            }
        }

        return hbr;
    }
但这是无法实现的。有人能帮忙吗

这就是我想要的

这就是我得到的


提前感谢。

“我失败了”不是一个问题陈述。我刚刚修改了问题和政治上不正确的陈述。IInspectable的投诉不是关于措辞,而是关于它没有告诉我们失败的原因。它会画画吗?它会崩溃吗?它是如何失败的?“这不可能实现”只告诉我们您的第一句话。它描绘了整个编辑控件,但不是它的一部分。我只想画画,即长度的60%,对应一些统计数据。也许。你调查过背景处理程序吗?它可能正在擦你画的东西?