How to set EM_SETCUEBANNER in a Edit Control
-
Hi to all, I am unable to get the Cue Banner Text in the Edit control. Below is the code i had used.
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 0, (LPARAM)TEXT("Username"));
break;Is something extra is required to achieve the cue banner in edit control. :zzz:
Regards, Vishal
-
Hi to all, I am unable to get the Cue Banner Text in the Edit control. Below is the code i had used.
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 0, (LPARAM)TEXT("Username"));
break;Is something extra is required to achieve the cue banner in edit control. :zzz:
Regards, Vishal
The text for your "Username" must be wide character
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 0, (LPARAM)L"Username");
break;Other than that, it's supported on WinXP and later - and I believe you need to have WINVER set to 0501 or higher - at least you used to need that. If your project is Unicode, then the TEXT macro will do, but if it's not Unicode, you must use the L prefix to create a wide character string. Hope this helps
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
The text for your "Username" must be wide character
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 0, (LPARAM)L"Username");
break;Other than that, it's supported on WinXP and later - and I believe you need to have WINVER set to 0501 or higher - at least you used to need that. If your project is Unicode, then the TEXT macro will do, but if it's not Unicode, you must use the L prefix to create a wide character string. Hope this helps
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
-
Hi to all, I am unable to get the Cue Banner Text in the Edit control. Below is the code i had used.
case WM_INITDIALOG:
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 0, (LPARAM)TEXT("Username"));
break;Is something extra is required to achieve the cue banner in edit control. :zzz:
Regards, Vishal
What you've given is correct. You're probably not seeing the banner because the edit control has the focus. You can give the value of 1 for wParam to show the banner even if the control has focus.
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 1, (LPARAM)TEXT("Username"));
«_Superman_» _I love work. It gives me something to do between weekends.
-
What you've given is correct. You're probably not seeing the banner because the edit control has the focus. You can give the value of 1 for wParam to show the banner even if the control has focus.
SendMessage(GetDlgItem(hwnd,IDC_USER), EM_SETCUEBANNER, 1, (LPARAM)TEXT("Username"));
«_Superman_» _I love work. It gives me something to do between weekends.
You're probably right that the control has focus, thus preventing the cue banner from showing, however the OP must still insure that it's a Unicode build if TEXT is used. If the build is non-Unicode, the L prefix is required.
Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193