Jump to content
  • Advertisement
Sign in to follow this  
Subotron

Highlight edit box selection (SOLVED)

This topic is 4495 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

I'm currently exploring the resource editor in Visual C++. I added some edit boxes to my window, but they give me some headaches because of 2 things I can't accomplish: 1: (more general, not only edit boxes) using the tab button doesn't switch to another control, although I set the tab stops for some items. 2: when I set the focus on an edit box, I want to 'highlight' the text (number) inside (i.o.w. it should become blue, the same as when you double-click on it) If you people can tell me how to archieve the two things above, I'm a very happy man (for about 5 seconds until I find a new problem, but nevertheless...) [Edited by - Subotron on June 6, 2006 12:18:48 PM]

Share this post


Link to post
Share on other sites
Advertisement
thanks, but I should've mentioned I'm not using MFC or stdafx.h

I tried this:

case EN_SETFOCUS:
if (LOWORD(wparam) == IDC_EDIT_BOX)
{
HWND temp = GetDlgItem(window.get_wnd(0), IDC_EDIT_BOX); // handler to the edit box (=correct)
DWORD text_length = GetWindowTextLength(temp);
SetFocus(temp);

#ifdef WIN32
// This happens, because I can replace the text afterwards, but
// just EM_SETSEL doesn't make it blue
SendMessage(temp, EM_SETSEL, 0, text_length);
#else
SendMessage(temp, EM_SETSEL, 0, MAKELONG (text_length, text_length));
#endif
}
break;

As said in the comment, the text is selected (as EM_REPLACESEL works) but doesn't turn blue... (I associate being blue with meaning "if you press a key now this will replace the currently selected text in the edit box" which comes in handy in combination with tabs)

[Edited by - Subotron on June 5, 2006 10:19:54 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Sounds like you're doing non modal dialogs, and is forgetting to call IsDialogMessage in your main message loop.

Share this post


Link to post
Share on other sites
edit: I looked up that function, and put it in my message handler function like this:

if (!IsDialogMessage(wnd[0], &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

where wnd[0] is the window handle and translate/dispatch functions where already there but without an if-check.

This fixes the no-tab problem, but not the selection problem

Share this post


Link to post
Share on other sites
hmmm it is fixed now, by throwing out the code I put in at all! Don't know why this failed when I tried before, probably forgot something, but it works now! I never understood that a dialog window CAN do all these things for you, by just one function :)

Thanks a lot guys!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!