Search code examples
mfccedit

Handling dynamic text editing in an MFC CView


I have a class that implements OnDraw to draw text and images to a CView. At certain times (ie onClick) I would like this text to be editable in place. What would be the best way to implement this?

  • Have the class have a CEdit object that I hide and show and draw over the top of my text.
  • Handle key presses in the class and implement my own editing
  • Have something external to the class control whether to show the edit box or my class
  • Something else?

Solution

  • Go with your first idea, create a CEdit box when you need some text editing. If you look at how a ListCtrl handles rename functionality it does exactly that.