Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:31:23+00:00 2026-06-02T02:31:23+00:00

Sorry, title was a bit vague. Basically, I am making a chat program in

  • 0

Sorry, title was a bit vague.

Basically, I am making a chat program in C++ and using windows.h API. I have most of the program working, just small things are not working correctly. I have a box that a user types what they wish to say in, and in that box it says “Enter text here” in italics. I want to set it so that when the user clicks in that box, those words disappear and the user can freely type. As it is set now, if they click within the box it goes to the end of the word “here” and they must manually delete the words.

Is there a simple way to do this? Possibly when creating the box or text? Or must I add logic of my own in order to accomplish this?

Attached is the code where I create both the box, and where I set the font:

Box:

hwSendEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "Enter Text Here", 
WS_CHILD|WS_VISIBLE, 2, 215, 790, 22, hwMain, 0, hInst, 0);

Font:

chFont = CreateFont(12, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "Tahoma");
SendMessage(hwSendEdit, WM_SETFONT, reinterpret_cast<WPARAM>(chFont), 0);

Thank you for any help you can provide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:31:27+00:00Added an answer on June 2, 2026 at 2:31 am

    You need to respond to the WM_ACTIVATE message for the control. It has a parameter in wParam that tells you if the control is being activated or deactivated. If it’s being activated, check the window text to see if it’s equal to your prompt string; if so set the font back to normal and use SetWindowText to clear the text. If it’s being deactivated, use GetWindowText to see if the text is empty and if so set the font back to italic and replace your prompt string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if the title sounds a bit vague. Stackoverflow posting newbie here. I have
Sorry if the title doesn't make sense. Basically I have a series of strings
Sorry the title is a little bit long. So I have a twitter account
Sorry for dodgy title, couldn't think of anything better... Anyway, I have written a
Sorry for the title.....bit difficult to word what I really want to ask. Some
Sorry for the long title, didn't want people just reading the title and not
Sorry, the title is a bit hard to understand but I'm not 100% sure
Sorry, difficult to give the question a proper title? I'm basically appending a lot
sorry if the title is a little.. vague i couldnt pin it down. So
My question title sounds a little bit difficult - sorry. I'm new in MEF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.