Win32: How to custom draw an Edit control?

后端 未结 5 1505
面向向阳花
面向向阳花 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:42

    Create a window class of your own that looks like and empty edit control, that draws the cue text and shows a caret and has focus. Create the edit control also, but position it behind your window. (or leave it hidden)

    Then when you get the first WM_CHAR message (or WM_KEYDOWN?). You put your window behind the edit conrol, give focus to the edit, and pass the WM_CHAR message on. From then on the edit control will take over.

    You can listen to EN_CHANGE notifications from the edit control if you need to go back to showing your cue text when the edit gets empty. But I'd think that it would be fine to go back to the cue text only when the edit looses focus AND is empty.

提交回复
热议问题