WM_SETREDRAW - Stop Form from Redrawing

  • Thread starter Thread starter a
  • Start date Start date
A

a

I'm trying to stop a from from redrawing to prevent a textbox scroll
bug. Whenever I try to use Textbox.ScrollToCaret, the textbox scrolls
to the top line, then to the proper location. It's really distracting.

I'm trying to stop the form from redrawing, but it's not working.
Here's what I've tried so far, taken from a blog I ran across.

Dim Ret As IntPtr
Dim eventMask As IntPtr = IntPtr.Zero
Try
Ret = Win32Window.SendMessage( _
HWND,WM_SETREDRAW,-1,IntPtr.Zero)
Debug.WriteLine("SetRedraw ME - Ret = " & Ret.ToString)
eventMask = Win32Window.SendMessage( _
txtDataHWND,EM_GETEVENTMASK,0,IntPtr.Zero)
Ret = Win32Window.SendMessage(txtDataHWND, EM_SCROLLCARET, 0, 0)
Debug.WriteLine("ScrollToCaret - Ret = " & Ret.ToString)
Catch ex As Exception
Debug.WriteLine("Exception Trying to Scroll: " & ex.Message)
Finally
Win32Window.SendMessage( _
txtDataHWND, EM_SETEVENTMASK, 0, eventMask)
Ret = Win32Window.SendMessage( _
HWND, WM_SETREDRAW, 0, IntPtr.Zero)
Debug.WriteLine("SetRedraw ME - Ret = " & Ret.ToString)
End Try


I've also tried modifying it to send the WM_SETREDRAW message to the
Textbox directly, but neither of these functions worked.
 
a said:
I'm trying to stop a from from redrawing to prevent a textbox scroll
bug. Whenever I try to use Textbox.ScrollToCaret, the textbox scrolls
to the top line, then to the proper location. It's really distracting.

I'm trying to stop the form from redrawing, but it's not working. Here's
what I've tried so far, taken from a blog I ran across.

Some other ideas I've had....

A) Use a PictureBox, copy the textbox rectangle bitmap, overlap textbox,
update textbox, hide picturebox. This would have to be done for each
text update though, so it would have to be fast.
B) Make a second textbox and copy only visible text into it. Similar to
above method - Overlay textbox1, update textbox1, then hide textbox2.
C) Simulate Typing using SendKeys. This worked GREAT, but I could no
longer have the form read-only. Users could tap the screen by accident
and put the text in the wrong place.

I'm working on a remote text viewer. Like real-time chat. I need the
text to be updated quickly, and often. Any ideas how this can be done
without the annoying flicker?

Thanks!
 
Back
Top