Highlighting text in an EditBox
I am trying to set my editbox up so that when the user clicks on an edit box, the text inside the editbox will automatically become highlighted. I figured sending an EM_SETSEL message on every EN_SETFOCUS notification would do that easily, except for the little snag that it isn't working: the caret position scrolls to the right a bit, but thats about it... no text is highlighted at all. Here is my simple code:
According to MSDN, a wparam of 0 and an lparam of -1 should select all text, but it does not do this (nor for any combination of start/end values I have tried).
SendMessage((HWND)lParam, EM_SETSEL, (WPARAM)0, (LPARAM)-1);
There's probably some simple thing I'm missing, but other than that I have no clue as to why something so simple has become so hard, please help, thanks.