Click here to Skip to main content
11,417,390 members (49,312 online)
Click here to Skip to main content

CueProvider

, 24 Jul 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
A lightweight class that lets you add cues to a TextBox.

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)

Share

About the Author

Ravi Bhavnani
Technical Lead
Canada Canada
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, HCI 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.
Follow on   Google+   LinkedIn

Comments and Discussions

 
Questioncool Pin
lhcxx15-Mar-13 9:34
memberlhcxx15-Mar-13 9:34 
Questionwork perfect on win 7 but not on win xp Pin
walterhuang5-Feb-13 17:12
memberwalterhuang5-Feb-13 17:12 
AnswerRe: work perfect on win 7 but not on win xp Pin
walterhuang17-Feb-13 17:58
memberwalterhuang17-Feb-13 17:58 
QuestionWorked perfectly!!! Pin
Michael Dialogo6-Nov-12 20:30
memberMichael Dialogo6-Nov-12 20:30 
AnswerRe: Worked perfectly!!! Pin
Ravi Bhavnani7-Nov-12 2:48
memberRavi Bhavnani7-Nov-12 2:48 
QuestionDoes not work when textbox is multiline enabled Pin
Member 119396917-Sep-11 9:40
memberMember 119396917-Sep-11 9:40 
AnswerRe: Does not work when textbox is multiline enabled Pin
Ravi Bhavnani17-Sep-11 9:41
memberRavi Bhavnani17-Sep-11 9:41 
QuestionImplementing with DevExpress.XtraEditors.TextEdit Pin
Brian, The IT Guy15-Jun-11 7:45
memberBrian, The IT Guy15-Jun-11 7:45 
AnswerRe: Implementing with DevExpress.XtraEditors.TextEdit Pin
Ravi Bhavnani15-Jun-11 8:03
memberRavi Bhavnani15-Jun-11 8:03 
AnswerRe: Implementing with DevExpress.XtraEditors.TextEdit Pin
Uwe Keim10-Oct-13 5:07
sitebuilderUwe Keim10-Oct-13 5:07 
QuestionCan it work with readonly controls? Pin
Liko72125-Feb-11 8:26
memberLiko72125-Feb-11 8:26 
AnswerRe: Can it work with readonly controls? Pin
Ravi Bhavnani26-Feb-11 5:56
memberRavi Bhavnani26-Feb-11 5:56 
GeneralCueProvider and MaskedTextBox Pin
zonextrem12-Aug-08 4:47
memberzonextrem12-Aug-08 4:47 
GeneralRe: CueProvider and MaskedTextBox Pin
Ravi Bhavnani12-Aug-08 9:16
memberRavi Bhavnani12-Aug-08 9:16 
GeneralRe: CueProvider and MaskedTextBox Pin
zonextrem12-Aug-08 9:19
memberzonextrem12-Aug-08 9:19 
GeneralRe: CueProvider and MaskedTextBox Pin
Ravi Bhavnani12-Aug-08 9:22
memberRavi Bhavnani12-Aug-08 9:22 
GeneralDemo not working :( Pin
baruchl28-Jul-08 23:22
memberbaruchl28-Jul-08 23:22 
AnswerRe: Demo not working :( Pin
Ravi Bhavnani29-Jul-08 2:46
memberRavi Bhavnani29-Jul-08 2:46 
GeneralRe: Demo not working :( Pin
TobiasP30-Jul-08 4:41
memberTobiasP30-Jul-08 4:41 
GeneralRe: Demo not working :( Pin
Ravi Bhavnani30-Jul-08 4:48
memberRavi Bhavnani30-Jul-08 4:48 
GeneralNot working!!! Pin
Qing Jiang25-Jul-08 5:52
memberQing Jiang25-Jul-08 5:52 
GeneralRe: Not working!!! Pin
Ravi Bhavnani25-Jul-08 7:39
memberRavi Bhavnani25-Jul-08 7:39 
GeneralRe: Not working!!! Pin
cigwork2-Dec-12 11:07
membercigwork2-Dec-12 11:07 
Generalnot workin Pin
pro.rakesh25-Jul-08 0:58
memberpro.rakesh25-Jul-08 0:58 
GeneralRe: not workin Pin
Ravi Bhavnani25-Jul-08 7:40
memberRavi Bhavnani25-Jul-08 7:40 
GeneralI modified it to do an IExtenderProvider component [modified] Pin
Fabrice CARUSO24-Jul-08 21:11
memberFabrice CARUSO24-Jul-08 21:11 
GeneralRe: I modified it to do an IExtenderProvider component Pin
Ravi Bhavnani25-Jul-08 7:39
memberRavi Bhavnani25-Jul-08 7:39 
GeneralA few suggestions... Pin
Scott Dorman24-Jul-08 18:11
mvpScott Dorman24-Jul-08 18:11 
GeneralRe: A few suggestions... Pin
Ravi Bhavnani25-Jul-08 7:38
memberRavi Bhavnani25-Jul-08 7:38 
GeneralRe: A few suggestions... Pin
Scott Dorman25-Jul-08 15:19
mvpScott Dorman25-Jul-08 15:19 
GeneralRe: A few suggestions... Pin
Ravi Bhavnani25-Jul-08 20:21
memberRavi Bhavnani25-Jul-08 20:21 
GeneralNot working... Pin
henur22-Jul-08 7:59
memberhenur22-Jul-08 7:59 
GeneralRe: Not working... Pin
Ravi Bhavnani22-Jul-08 8:51
memberRavi Bhavnani22-Jul-08 8:51 
GeneralRe: Not working... Pin
henur22-Jul-08 22:48
memberhenur22-Jul-08 22:48 
GeneralRe: Not working... Pin
Ravi Bhavnani23-Jul-08 7:55
memberRavi Bhavnani23-Jul-08 7:55 
AnswerRe: Not working... Pin
Ravi Bhavnani24-Jul-08 12:52
memberRavi Bhavnani24-Jul-08 12:52 
GeneralRe: Not working... Pin
henur26-Jul-08 22:12
memberhenur26-Jul-08 22:12 
GeneralRe: Not working... Pin
Ravi Bhavnani27-Jul-08 8:26
memberRavi Bhavnani27-Jul-08 8:26 
GeneralRe: Not working... Pin
HunterM21-Aug-08 11:47
memberHunterM21-Aug-08 11:47 
GeneralRe: Not working... Pin
Ravi Bhavnani23-Aug-08 12:35
memberRavi Bhavnani23-Aug-08 12:35 
GeneralRe: Not working... Pin
HunterM25-Aug-08 8:03
memberHunterM25-Aug-08 8:03 
GeneralRe: Not working... Pin
Ravi Bhavnani25-Aug-08 8:53
memberRavi Bhavnani25-Aug-08 8:53 
AnswerRe: Not working... Pin
Ravi Bhavnani27-Jul-08 14:05
memberRavi Bhavnani27-Jul-08 14:05 
GeneralNice Post... Pin
Pankajkumar Nikam22-Jul-08 0:18
memberPankajkumar Nikam22-Jul-08 0:18 
GeneralRe: Nice Post... Pin
Ravi Bhavnani22-Jul-08 8:51
memberRavi Bhavnani22-Jul-08 8:51 
GeneralUsefull Pin
HiMik200317-Jul-08 0:50
memberHiMik200317-Jul-08 0:50 
GeneralRe: Usefull Pin
Ravi Bhavnani17-Jul-08 4:43
memberRavi Bhavnani17-Jul-08 4:43 
GeneralNot working in XP - VS 2005 Pin
J@@NS16-Jul-08 22:49
memberJ@@NS16-Jul-08 22:49 
GeneralRe: Not working in XP - VS 2005 Pin
Ravi Bhavnani17-Jul-08 4:42
memberRavi Bhavnani17-Jul-08 4:42 
GeneralSample doesnot work, Pin
ring_016-Jul-08 21:44
memberring_016-Jul-08 21:44 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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