Search code examples
visual-c++mfceditbox

How to create watermark in edit box in MFC VC++


I have created an Edit box accepting password but I need to display a watermark or whatever it calls displaying "password" as default just like when we enter our password in windows 8 startup.

thanks


Solution

  • This is very easy thing to do.
    Just take an edit control, right click edit control and click "Add Variable".
    Give variable name, say "m_myEdit".
    Now "OnInitDialog()" you need to write just one line.

    m_myEdit.SetCueBanner(_T("Password"),TRUE);
    

    This will work as you mentioned like windows 8 startup.