Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.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++ 如何将编辑框插入CMFCPropertyGridCtrl以使用密码?_C++_Mfc_Propertygrid - Fatal编程技术网

C++ 如何将编辑框插入CMFCPropertyGridCtrl以使用密码?

C++ 如何将编辑框插入CMFCPropertyGridCtrl以使用密码?,c++,mfc,propertygrid,C++,Mfc,Propertygrid,我想在CMFCPropertyGridCtrl中插入一个用于输入密码的编辑框。但是CMFCPropertyGridProperty只能创建普通编辑框。如何创建用于密码使用的新类?从CMFCPropertyGridProperty派生一个新类,并重写两个函数:OnDrawValue()和CreateInPlaceEdit() 代码原型可能如下所示: void CMyGridProperty::OnDrawValue(CDC* pDC, CRect rect) { // pre-proces

我想在CMFCPropertyGridCtrl中插入一个用于输入密码的编辑框。但是CMFCPropertyGridProperty只能创建普通编辑框。如何创建用于密码使用的新类?

CMFCPropertyGridProperty
派生一个新类,并重写两个函数:
OnDrawValue()
CreateInPlaceEdit()

代码原型可能如下所示:

void CMyGridProperty::OnDrawValue(CDC* pDC, CRect rect)
{
    // pre-processing
    // ...

    CString strVal = FormatProperty();
    if(!strVal.IsEmpty())
    {
        strVal = _T("******");  // NOTE: replace the plain text with "******"
    }
    rect.DeflateRect(AFX_TEXT_MARGIN, 0);
    pDC->DrawText(strVal, rect, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS);

    // post-processing
    // ...
}

CWnd* CMyGridProperty::CreateInPlaceEdit(CRect rectEdit, BOOL& bDefaultFormat)
{
    // pre-processing
    // ...

    CEdit* pWndEdit = new CEdit;
    DWORD dwStyle = WS_VISIBLE | WS_CHILD | ES_AUTOHSCROLL | ES_PASSWORD;   // NOTE: add 'ES_PASSWORD' style here
    pWndEdit->Create(dwStyle, rectEdit, m_pWndList, AFX_PROPLIST_ID_INPLACE);

    // post-processing
    // ...

    return pWndEdit;
}

查看ES_密码样式。我认为您可以使用正常的CEdit ctrl并修改其样式,使其成为密码框。