473,473 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Stop repaint of RichTextBox?

I have code where I append text to a rich text box. I grab the current
SelectionStart and SelectionLength before I append the text and then after I
reset the SelectionStart and SelectionLength to their former values. I then
do a ScrollToCaret() to insure that the selection still shows on the screen
(because the append text moves it.)

Now, it all works but I get a noticible flash as I append the text and
apparently the control updates.

So, is there some way to stop the control updating until I'm all done?

Thanks,

Grant Schenck
Nov 17 '05 #1
8 15331
control.SuspendLayout() ?
Nov 17 '05 #2
Doesn't seem to do anything with regard to preventing drawing.

Grant

"The Crow" <q> wrote in message
news:uU**************@TK2MSFTNGP15.phx.gbl...
control.SuspendLayout() ?

Nov 17 '05 #3
Hi Grant,

It seems there is no way out except calling SuspendLayout() to prevend
re-drawing during updating.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #4
Hi,

Try to remove the focus from the rtf control, do your changes and set
the focus again on the rtf control (you have to save the cursor
position and set it too at the end).

Nov 17 '05 #5
Hi Grant,

Thanks for your post.

Yes, SuspendLayout is just used to suspend the layout of the controls, such
as size changing, location changing. It can not disable the paiting and
scrolling in textbox.

I do not think there is any way to append the text into the textbox without
it being scrolling. Winform AppendText method internally sends
EM_REPLACESEL to the textbox.
But in win32 world, EM_REPLACESEL message will cause the scrolling to the
end out of our control. Also, SetWindowText win32 API will also cause the
scrolling to the top.

Based on my test, the scrolling flash only occurs when we add the text in
high frequency. I think you may cache multi-adding operations in a private
field, then add the text in a longer interval. This should reduce the
flashing in your application.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #6
Everyone,

The LockWindowUpdate API function prevents a window from being redrawn. The
original poster can try it to reduce the flashing.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:vt*************@TK2MSFTNGXA01.phx.gbl...
Hi Grant,

Thanks for your post.

Yes, SuspendLayout is just used to suspend the layout of the controls,
such
as size changing, location changing. It can not disable the paiting and
scrolling in textbox.

I do not think there is any way to append the text into the textbox
without
it being scrolling. Winform AppendText method internally sends
EM_REPLACESEL to the textbox.
But in win32 world, EM_REPLACESEL message will cause the scrolling to the
end out of our control. Also, SetWindowText win32 API will also cause the
scrolling to the top.

Based on my test, the scrolling flash only occurs when we add the text in
high frequency. I think you may cache multi-adding operations in a private
field, then add the text in a longer interval. This should reduce the
flashing in your application.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 17 '05 #7
I ended up sending a WM_SETREDRAW via SendMessage to disable then reenable
followed by an Invalidate() after I finished updating. That seemed to work.

Thanks all who answered.

Grant

"Dmytro Lapshyn [MVP]" <x-****@no-spam-please.hotpop.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
Everyone,

The LockWindowUpdate API function prevents a window from being redrawn. The original poster can try it to reduce the flashing.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:vt*************@TK2MSFTNGXA01.phx.gbl...
Hi Grant,

Thanks for your post.

Yes, SuspendLayout is just used to suspend the layout of the controls,
such
as size changing, location changing. It can not disable the paiting and
scrolling in textbox.

I do not think there is any way to append the text into the textbox
without
it being scrolling. Winform AppendText method internally sends
EM_REPLACESEL to the textbox.
But in win32 world, EM_REPLACESEL message will cause the scrolling to the end out of our control. Also, SetWindowText win32 API will also cause the scrolling to the top.

Based on my test, the scrolling flash only occurs when we add the text in high frequency. I think you may cache multi-adding operations in a private field, then add the text in a longer interval. This should reduce the
flashing in your application.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #8
Hi Grant and "Dmytro Lapshyn [MVP]"

Oh, yes, it seems that both LockWindowUpdate and WM_SETREDRAW with wParam
set to false will prevent the TextBox from updating untill we release the
lock. Thank you for sharing the solution with the community. But, if we do
not want to update the UI immediately, I think it is better for us to cache
multi-updating, then update the textbox at a time. This should have the
same effect as locking the UI drawing.

Anyway, we have several different approaches to resolve this problem :-).
If you have any further concern, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
4
by: D. Yates | last post by:
Hi, When a RichTextBox control doesn't have focus, it DOES NOT scroll to the last line that is added; however, if it does have focus, it WILL scroll to the last line added. I want to stop and...
0
by: sskset | last post by:
i want to repaint the richtextbox by the client's requirment. let it auto show the row num at the first of the text area what should i do? override it's base's onpaint method? how?
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
by: Ben | last post by:
Hi We have a windows form that takes a while to run a routine. During this we have created a information label, updating the user on the progress but: a) The changes on the label are not...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
4
by: ravindarjobs | last post by:
hi...... i am using ms access 2003,vb6 i have a form. in that i have 2 buttons 1. start search 2 stop search when i click the "start search" button the fucntion SearchSystem() is called,...
0
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.