Click here to Skip to main content
Click here to Skip to main content

CueProvider

By , 24 Jul 2008
 

Introduction

CueProvider is a tiny class that lets you set a cue banner (the grey prompt text that automatically disappears when you begin to type) in a TextBox control.

CueProvider demo

How to use CueProvider

CueProvider is easy to use, and has just two methods - one to set a TextBox's cue text, the other to clear it. To set the cue text, call SetCue(); to clear it, call ClearCue(). These calls are best placed in your form's OnLoad handler.

  // Set cue text
  CueProvider.SetCue (theTextBox, theCueText);

  // Clear cue text
  CueProvider.ClearCue (theTextBox);

How it works

CueProvider works by sending the TextBox the EM_SETCUEBANNER message. The message is sent using the SendMessage() Win32 API. More information on the EM_SETCUEBANNER message can be found on this MSDN page.

Conclusion

As you can see, there's nothing overly complicated in this class. I put CueBanner together in a few minutes, and wanted to share it with the CodeProject community in the hope it could help give our desktop apps a bit of UI "polish".

Revision history

  • 24 Jul 2008
  • Updated the "How to use" section.

  • 17 Jul 2008
  • Initial version.

License

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

About the Author

Ravi Bhavnani
Technical Lead
Canada Canada
Member
Ravi Bhavnani is an ardent fan of Microsoft technologies who loves building Windows apps, especially PIMs, system utilities, and things that go bump on the Internet. During his career, Ravi has developed expert systems, desktop imaging apps, marketing automation software, EDA tools, a platform to help people find, analyze and understand information, trading software for institutional investors and advanced data visualization solutions. He currently works for a company that provides enterprise workforce management solutions to large clients.
 
His interests include the .NET framework, reasoning systems, financial analysis and algorithmic trading, NLP, CHI and UI design. Ravi holds a BS in Physics and Math and an MS in Computer Science and was a Microsoft MVP (C++ and C# in 2006 and 2007). He is also the co-inventor of 2 patents on software security and generating data visualization dashboards. His claim to fame is that he crafted CodeProject's "joke" forum post icon.
 
Ravi's biggest fear is that one day he might actually get a life, although the chances of that happening seem extremely remote.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questioncoolmemberlhcxx15 Mar '13 - 8:34 
Questionwork perfect on win 7 but not on win xpmemberwalterhuang5 Feb '13 - 16:12 
AnswerRe: work perfect on win 7 but not on win xpmemberwalterhuang17 Feb '13 - 16:58 
QuestionWorked perfectly!!!memberMichael Dialogo6 Nov '12 - 19:30 
AnswerRe: Worked perfectly!!!memberRavi Bhavnani7 Nov '12 - 1:48 
QuestionDoes not work when textbox is multiline enabledmemberMember 119396917 Sep '11 - 8:40 
Thanks for sharing the snippet. One issue i found was that watermark does not work when the textbox is multiline. Found info some info here http://msdn.microsoft.com/en-us/library/bb761639(v=vs.85).aspx[^]
 
Microsoft messes up things un necessarily Smile | :)
 
Mohit
AnswerRe: Does not work when textbox is multiline enabledmemberRavi Bhavnani17 Sep '11 - 8:41 
QuestionImplementing with DevExpress.XtraEditors.TextEditmemberBrian, The IT Guy15 Jun '11 - 6:45 
AnswerRe: Implementing with DevExpress.XtraEditors.TextEditmemberRavi Bhavnani15 Jun '11 - 7:03 
QuestionCan it work with readonly controls?memberLiko72125 Feb '11 - 7:26 
AnswerRe: Can it work with readonly controls?memberRavi Bhavnani26 Feb '11 - 4:56 
GeneralCueProvider and MaskedTextBoxmemberzonextrem12 Aug '08 - 3:47 
GeneralRe: CueProvider and MaskedTextBoxmemberRavi Bhavnani12 Aug '08 - 8:16 
GeneralRe: CueProvider and MaskedTextBoxmemberzonextrem12 Aug '08 - 8:19 
GeneralRe: CueProvider and MaskedTextBoxmemberRavi Bhavnani12 Aug '08 - 8:22 
GeneralDemo not working :(memberbaruchl28 Jul '08 - 22:22 
AnswerRe: Demo not working :(memberRavi Bhavnani29 Jul '08 - 1:46 
GeneralRe: Demo not working :(memberTobiasP30 Jul '08 - 3:41 
GeneralRe: Demo not working :(memberRavi Bhavnani30 Jul '08 - 3:48 
GeneralNot working!!!memberQing Jiang25 Jul '08 - 4:52 
GeneralRe: Not working!!!memberRavi Bhavnani25 Jul '08 - 6:39 
GeneralRe: Not working!!!membercigwork2 Dec '12 - 10:07 
Generalnot workinmemberpro.rakesh24 Jul '08 - 23:58 
GeneralRe: not workinmemberRavi Bhavnani25 Jul '08 - 6:40 
GeneralI modified it to do an IExtenderProvider component [modified]memberFabrice CARUSO24 Jul '08 - 20:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 24 Jul 2008
Article Copyright 2008 by Ravi Bhavnani
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid