c++ - How to insert an edit box into CMFCPropertyGridCtrl for password usage? -
i want insert edit box cmfcpropertygridctrl inputting password. cmfcpropertygridproperty can create normal edit box. how can create new 1 password usage ?
derive new class cmfcpropertygridproperty
, override 2 functions: ondrawvalue()
, createinplaceedit()
.
the code prototype may this:
void cmygridproperty::ondrawvalue(cdc* pdc, crect rect) { // pre-processing // ... cstring strval = formatproperty(); if(!strval.isempty()) { strval = _t("******"); // note: replace plain text "******" } 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; }
Comments
Post a Comment