Click here to Skip to main content
15,891,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a ComboBox on my application which displays a watermark 'Search...'

The watermark is added using CB_SETCUEBANNER:

'Private Const EM_SETCUEBANNER As Integer = &H1501 (TextBox)
Private Const CB_SETCUEBANNER As Integer = &H1703 '(ComboBox)

<DllImport("user32.dll", EntryPoint:="SendMessageW")> _
       Private Shared Function SendMessageW(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As UInteger, <MarshalAs(UnmanagedType.LPTStr)> ByVal lParam As String) As Integer
       End Function

SendMessageW(CBSearch.Handle, CB_SETCUEBANNER, 0, "Search...")


I want the SETCUEBANNER text 'Search...' to be italic. Is there a way to pass an additional parameter to SETCUEBANNER?


Many thanks for your help.

What I have tried:

I tried passing an additional parameter through on the SendMessageW:
<DllImport("user32.dll", EntryPoint:="SendMessageW")> _
    Private Shared Function SendMessageW(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As UInteger, ByVal styleItalic As FontStyle, <MarshalAs(UnmanagedType.LPTStr)> ByVal lParam As String) As Integer
    End Function

    SendMessageW(CBSearch.Handle, CB_SETCUEBANNER, 0, FontStyle.Italic, "Search...")
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900