Win32: How to custom draw an Edit control?

后端 未结 5 1509
面向向阳花
面向向阳花 2020-12-11 02:41

i need to implement the functionality of EM_SETCUEBANNER, where a text hint appears inside an Edit control:

\"Ex

5条回答
  •  再見小時候
    2020-12-11 02:58

    Custom drawing an Edit control is essentially impossible. There are a few specialized cases were you are doing so little that can get away with it, but you risk breaking badly in the next revision of windows (or when someone runs your app on an older version, or via terminal services, etc).

    Just taking over WM_PAINT and WM_ERASEBKGROUND aren't good enough, because the control will sometimes paint on other messages as well.

    You are better off just writing your own edit control. I know that's a huge amount of work, but in the long run it will be less work than trying to hack your way into taking over all of the Edit controls' drawing code.

    I remember back in the good old days when everyone use to subclass the button control to add color and graphics, etc. The thing is, one day I sat down and just wrote my own button window class. and it was LESS CODE than what we had in our source tree to subclass and custom draw the Windows button.

提交回复
热议问题