I have an Editbox in a dialog, when the dialog is created I send a text to the editbox, but this makes the text in the editbox to be marked (chosen).
How can I avoid it?
thanks.
Printable View
I have an Editbox in a dialog, when the dialog is created I send a text to the editbox, but this makes the text in the editbox to be marked (chosen).
How can I avoid it?
thanks.
According the off-line MSDN:
According the link you gave me:Code:SendMessage(GetDlgItem(hDlg, IDD_PREVIEW_PORT), EM_SETSEL, -1, 0);
They both don't work, why?Code:SendMessage(GetDlgItem(hDlg, IDD_PREVIEW_PORT), EM_SETSEL, 1, 0);
:rolleyes:
I agree with Devil Panther. Something is up here. MSDN says:
That is entirely untrue. Every "1" should be replaced with "-1" for it to be true. What's with the emoticon adrian? Care to explain yourself?Quote:
If the start is 0 and the end is 1, all the text in the edit control is selected. If the start is 1, any current selection is deselected.
Devil Panther, the following line works for me:
Code:SendMessage(hEdit,EM_SETSEL,-1,0);
The MSDN library says...
>>>
If the start is 0 and the end is 1, all the text in the edit control is selected. If the start is 1, any current selection is deselected.
<<<
... however, the cd's say...
>>>
If the nStart parameter is 0 and the nEnd parameter is –1, all the text in the edit control is selected. If nStart is –1, any current selection is removed.
<<<
... which is a little odd since I had always assumed one was created from the other.
So the online MSDN is incorrect? It appears that way to me.
Would seem so. The -1 is what I've always used and never had any trouble with.
I think it just checks for a non-zero value, so 1 and -1 are the same.
Actually DevilPanther, that's untrue. Doing what MSDN says will NOT give you the desired results. specifying 0,1 will select the first character. Specifying 1,0 will select the first character also. I advise that you use -1.
EDIT: Typo