commit 50e82f34b337d4b9e2d06a9e7dfa8a6cc510c876
parent b98a8652ae8bd66501f76b0e35066f5e9a1cbfc4
Author: cfillion <cfillion@users.noreply.github.com>
Date: Tue, 2 Feb 2016 14:33:09 -0800
richedit: scroll to the top after loading a document on windows
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/richedit.cpp b/src/richedit.cpp
@@ -95,9 +95,14 @@ bool RichEdit::setRichText(const string &rtf)
if(!length)
return false;
+ // move caret to the end
CHARRANGE cr{length, length};
SendMessage(handle(), EM_EXSETSEL, 0, (LPARAM)&cr);
+ // scroll back to top
+ LONG lines = (LONG)SendMessage(handle(), EM_GETLINECOUNT, 0, 0);
+ SendMessage(handle(), EM_LINESCROLL, 0, -lines);
+
return true;
}
#endif