Is there a way to add my own button inside the edi

2019-05-31 07:42发布

Say, if I have a default EDIT common control in my MFC-based dialog window:

enter image description here

I'm looking for a way to add a small "X" (or delete) button inside of it (here's my Photoshop rendering of what I need):

enter image description here

Is there a way to do it by modifying the default edit control?

2条回答
等我变得足够好
2楼-- · 2019-05-31 08:05

If I wanted more than one button, I would investigate alternatives:

  • See the CMFCEditBrowseCtrl class' code. Then decide if derive a class from it and extend; or else derive from CEdit, copy CMFCEditBrowseCtrl code and extend.

  • Case the edit is multi-line, I would investigate the methods CEdit::SetRect and CEdit::SetRectNP. Case it is single-line I would look to CEdit::SetMargins. Then implement normal buttons over the text area of the edit.

查看更多
叛逆
3楼-- · 2019-05-31 08:29

Please consider using new class CMFCEditBrowseCtrl. It does have method CMFCEditBrowseCtrl::EnableBrowseButton() to do exactly what you need.

查看更多
登录 后发表回答