+#if wxUSE_RICHEDIT
+ // EM_SCROLLCARET doesn't work for me with the richedit controls
+ // unless it has focus although I don't see any mention of it in the
+ // docs - this is the only workaround I found. Of course it's not
+ // perfect as it adds the dummy focus set/kill events but it's still
+ // better than nothing
+ HWND hwndFocusOld;
+ if ( IsRich() )
+ {
+ hwndFocusOld = ::GetFocus();
+ if ( hwndFocusOld == GetHwnd() )
+ {
+ // don't change focus
+ hwndFocusOld = 0;
+ }
+
+ if ( hwndFocusOld )
+ {
+ ::SetFocus(GetHwnd());
+ }
+ }
+ else // not rich
+ {
+ hwndFocusOld = 0;
+ }
+#endif // wxUSE_RICHEDIT
+