473,796 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ 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 15441
control.Suspend Layout() ?
Nov 17 '05 #2
Doesn't seem to do anything with regard to preventing drawing.

Grant

"The Crow" <q> wrote in message
news:uU******** ******@TK2MSFTN GP15.phx.gbl...
control.Suspend Layout() ?

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 LockWindowUpdat e 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.mi crosoft.com> wrote in message
news:vt******** *****@TK2MSFTNG XA01.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.c om> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Everyone,

The LockWindowUpdat e 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.mi crosoft.com> wrote in message
news:vt******** *****@TK2MSFTNG XA01.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 LockWindowUpdat e 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
3252
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 file back into the ricktextbox using loadfile. The problem is that the richtextbox seems to remain bound to the rtf file. If I make a change in the richtextbox after spell checking, the changes are successfully saved to the database but if the...
2
17387
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 the control or the scrolltocaret method I decided that it would be worth posting to anyone who might have similar concerns. For the record this works well in an environment where you cannot have focus going to the richtextbox....such as a chat...
4
3625
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 start this behavior at will. When I stop the behavior, this will give users a chance to examine the text that is at the top of the document while new text is being added at the bottom. I have tried inheriting from the RichTextBox control and...
0
1581
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
4879
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 can I print out this content to printer easily? Thanks! James
3
1790
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 visible until the routine has finished b) If the form looses focus it appears to the user that it has crashed
0
2061
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 inside with panel. The RichTextBox keep inside with other panel. The panel height and width is same with RichTextBox. The RichTextBox both scrolling options are make it as false. I done the coding for RichTextBox's height to fit with...
4
2516
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, it will search for a particular file in the computer(searches entire drives).
0
1959
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 in all, you should see an image following your mouse. BUT. its only seen after you press play and then resize the window. this leads me to conclude that theres a problem with repaint(). can someone please help? thanks. heres my code: (EnemyShip...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
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 we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.