• Advertisement

Archived

This topic is now archived and is closed to further replies.

Clearing an edit control

This topic is 5036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya, I''ve got a win32 EDIT control/window that I need to be able to clear the text from! doing SetWindowText(hwndEdit,""); leaves a line-break (since this is a multiline edit control). How would I go about completely removing everything from the control? Thanks

Share this post


Link to post
Share on other sites
Advertisement
That code is correct and it should remove everything, including newlines. Are you doing stuff with the EN_CHANGE message to affect what happens when text is typed in? SetWindowText() causes the EN_CHANGE message to be sent, so it''s possible you''re putting the newline in yourself.

Share this post


Link to post
Share on other sites
ahh, I think I found out why it''s doing this.

Im using a GetAsyncKeyState for the return key in my message loop to detect when the user hits the return key and it''s in the GetAsyncKeyState''s if statement that I''m clearing the text out but I guess it clears the text out BEFORE the edit control adds my linebreak.

If I were to take out the multiline style when I create it, how would I prevent the windows "beep" sound from playing when I hit the return key with the edit control in focus?

Share this post


Link to post
Share on other sites
Subclass the control and handle the WM_KEYDOWN message (or it might be WM_CHAR) and return the message as handled when you encounter a return.


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites

  • Advertisement