Is there a way to add my own button inside a normal edit control?

Let's say if I have a standard EDIT generic control in my MFC based dialog:

enter image description here

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

enter image description here

Is there a way to do this by changing the default control?

+1


source to share


2 answers


Please use the new class CMFCEditBrowseCtrl

. It has a method CMFCEditBrowseCtrl::EnableBrowseButton()

to accomplish exactly what you need.



+2


source


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



  • See the code CMFCEditBrowseCtrl

    class. Then decide if you are extracting a class from it and extending; or output from CEdit, copy the code CMFCEditBrowseCtrl

    and expand.

  • The fact is that editing is multi-line, I would investigate the CEdit :: SetRect and CEdit :: SetRectNP methods . This is a one-liner case, I would look at CEdit :: SetMargins . Then implement regular buttons above the text edit area.

0


source







All Articles