EM_SETSEL
-
Hallo,
Ich füge mir einer Funktion an eine textbox immer etwas hinzu. Nur müsste ich jetzt auch den Cursor immer ans Ende setzen.Das geht mit EM_SETSEL
Nur verstehe ich es nicht so richtig:
An application sends an EM_SETSEL message to select a range of characters in an edit control. EM_SETSEL wParam = (WPARAM) (INT) nStart; // starting position lParam = (LPARAM) (INT) nEnd; // ending position Parameters nStart Value of wParam. Specifies the starting character position of the selection. nEnd Specifies the ending character position of the selection. Return Values This message does not return a value. Remarks In a rich edit control, if the selection is not entirely contained in the first 64K, use the message EM_EXSETSEL. 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. The caret is placed at the end of the selection indicated by the greater of the two values nEnd and nStart. In previous versions of Windows, the wParam parameter is a flag that is set to FALSE to scroll the caret into view or set to TRUE to omit the scrolling. A Win32-based application should use the EM_SCROLLCARET message to scroll the caret into view. In earlier versions of Windows, the starting and ending positions of the selection are indicated by the low- and high-order words, respectively, of the lParam parameter.
Wie muss ich es jetzt machen, dass der Cursor ans Ende gesetzt wird?
wenn nStart größer ist als nEnd oder wie?Bitte helft mir.
Danke!
cu para
-
Schonmal probiert, bei beiden das gleiche anzugeben?
(Vielleicht auch nStart = -1 und nEnd = position - probiers halt aus)
-
Original erstellt von flenders:
Schonmal probiert, bei beiden das gleiche anzugeben?
(Vielleicht auch nStart = -1 und nEnd = position - probiers halt aus)
und was ist nEnd=position? Was soll ich denn für position nehmen??
ich denke es müsste auch so gehen das ich beides das gleiche neheme und zwar die Länge des Textes. Nur sah es dem Text nach so aus, als wäre da schon etwas vereinfacht!Danke
cu para
-
Funtzt aber au net.
Hier mal mein Code:// function to add a text void utilAppendTextToWindow(HWND hWnd, char *szText) { // private char *szOldText; char *szNewText; int tl; // get len of text tl = GetWindowTextLength(hWnd); // allocate szOldText = new char[tl+2]; szNewText = new char[tl+strlen(szText)+2]; // get old text GetWindowText(hWnd, szOldText, tl+2); // append wsprintf(szNewText, "%s%s\r\n", szOldText, szText); SetWindowText(hWnd, szNewText); tl = GetWindowTextLength(hWnd); // set cusor to end of text SendMessage(hWnd, EM_SETSEL, tl, tl); }
-
Jaja, ok! vergesst es
Hab was besseres gefundenEM_SCROLL
also danke!
cu para
-
Also ich hätte das so verstanden, dass für beides, wie du schon sagtest das gleiche und zwar die Länge des Textes einsetzt! (vielleicht auch in nStart = -1 und nEnd = LängeDesTextes)
-
(jaja ich weis er hat schon was enderes...) aber EM_SETSEL ist doch dazu da den text (oder nen teil) zu MARKIEREN!
und wenn da was markiert is gibet keinen cursor (caret..)
-
Aber gehen tut das so schon, hab ich auch schon mal gemacht:
SendMessage(hEdit,EM_SETSEL,len,len);
Das setzt der/die/das Caret ans Ende des Textes :), glaub ich ;).
cya