fix: 使用WM_GETTEXTLENGTH获取末尾位置插入日志, 避免点击中间位置导致日志乱序
This commit is contained in:
parent
f7efcc5378
commit
de576330bb
@ -36,6 +36,7 @@ const (
|
||||
WM_CTLCOLOREDIT = 0x0133
|
||||
EM_SETSEL = 0x00B1
|
||||
EM_REPLACESEL = 0x00C2
|
||||
WM_GETTEXTLENGTH = 0x000E
|
||||
|
||||
SW_SHOW = 5
|
||||
IDC_ARROW = 32512
|
||||
@ -186,8 +187,9 @@ func appendText(text string) {
|
||||
if hWndEdit == 0 {
|
||||
return
|
||||
}
|
||||
// 光标移到末尾
|
||||
pSendMessageW.Call(hWndEdit, EM_SETSEL, ^uintptr(0), ^uintptr(0))
|
||||
// 获取文本长度,将光标移到末尾(避免鼠标点击中间位置导致日志插入到光标处)
|
||||
textLen, _, _ := pSendMessageW.Call(hWndEdit, WM_GETTEXTLENGTH, 0, 0)
|
||||
pSendMessageW.Call(hWndEdit, EM_SETSEL, textLen, textLen)
|
||||
// 插入文本
|
||||
ptr, _ := syscall.UTF16PtrFromString(text)
|
||||
pSendMessageW.Call(hWndEdit, EM_REPLACESEL, 1, uintptr(unsafe.Pointer(ptr)))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user