Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default phantom caption in VB6 textbox

Tags:

vb6

How can I do this in VB6.0...

There's a default Caption in Textbox when it is empty, let say "Enter Name Here". but when the user fills in, the Caption will be replaced...

like image 573
Aaron Avatar asked Jul 29 '26 22:07

Aaron


1 Answers

The Windows API has had cue banners (or prompt text) built in since Windows XP. It's not directly exposed by VB 6, but that doesn't stop you from getting at it by making a few API calls.

There are several advantages of going this route, versus implementing your own custom style. For one thing, it's already available for free, meaning you have to do very little work to use it. Second, it's already been fully tested and professionally polished. Third, it will automatically get upgrades whenever the next version of Windows comes out.

All the code you need is available here: SendMessage: Use Cue Banners to Prompt Users

As the page explains, you need to make sure that you've included a manifest with your EXE so that you can take advantage of the Windows XP themes and features. The only real tricky part about the code is that you need to make sure you pass a Unicode string.

The final effect looks something like this:

   Cue Banner sample

like image 60
Cody Gray Avatar answered Aug 01 '26 20:08

Cody Gray