473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Please help!!

Hi all,

We are into the development of an application in C#. In one of the module we
are using RichEdit control as text editor. This text editor is resposible
for highlighting certain keywords. After parsing the text we are using the
following methods for setting the color of the text.

RichText.Select(int startIndex, int length) &
RichText.SelectionColor = Color.Red

This is working fine. But while loading a file of 10000 lines, this color
setting is taking almost 15mints, which is not at all desiarable. Is there
any better way to do this. The file format is ASCII and we don't want to use
rtf format.

We are using .Net 1.1.

We have found that for selecting text, SendCommand API with command ID
EM_SETSEL is much faster.

But still we are missing a proper solution for changing the font color of
selected text. Currently we are

using the method "SelectionColor" which is very slow. Could you give an
alternative solution for this issue.

Thanx in advance.
Nov 15 '05 #1
2 3378
Hi,

You can use "Text Object Model" technology
---------------------------------------------
More information:

MSDN Library under:

User Interface Design and Development
/ Windows Controls
/ Individual Control Information
/ Rich Edit Controls
/ Messages
and (or)
/ Text Object Model
/ Interfaces
/ ITextRange

---------------------------------------------
Used Interfaces:

ITextDocument,
ITextRange.

both defined in RICHED20.dll
(C:\WINDOWS\System32\RICHED20.dll)

From VS Studio IDE :

Project / Add Reference / (tab) COM

add
"tom"

---------------------------------------------
I have this tested with success in Delphi only

From my program /Delphi, sorry, but it is relativ simple/:
///////////////////////////////////////////////////////////////////////////
//--- function for retrieving connection with TOM
function TForm1.GetTextDocumentAndRange(const RichEdit1HWND:THandle;
var RichEditOle:IUnknown; var pDoc:ITextDocument;
var r:ITextRange):Boolean;
begin
// RichEdit1HWND this is hwnd (window handle) of my RichEdit1 component
if (SendMessage( RichEdit1HWND, EM_GETOLEINTERFACE, 0,
Longint(@RichEditOle) ) <> 0) then
if (RichEditOle<>nil) and
(RichEditOle.QueryInterface(IID_ITextDocument, pDoc) = 0) then
begin
r:=pDoc.Range(0,0);
result:=r<>nil;
end;
end;

// IID_ITextDocument -> GUID constant from tom_tlb.pas - generated from
delphi by importing tom
// IID_ITextDocument has value: {8CC497C0-A1DF-11CE-8098-00AA0047BE5D}
////////////////////////////////////////////////////////////////////////////
//

From preceding function you have r as ITextRange

ITextRange serve as "hidden" selection

Now You can use functions as:

r.FindText()
r.Move()
r.MoveEnd()
...
r.MoveStart()
...
r.collapse
r.copy
r.paste
...
...
r.Start = .. // Begin of selection - but this is only virtually selected
r.End = .. // End of selection

// and more - for retrieving TextRange

// and HIGHLIGHTING selection / word :

// changing font color
r.Font.ForeColor =

// changing style
r.Font.Bold = true / false

and so on (see MSDN Lib please)

Warning : at end you have to free r and pDoc

-----
Miro

"Catherine Jones" <no*@moreply.com> píąe v diskusním příspěvku
news:u0**************@TK2MSFTNGP10.phx.gbl...
Hi all,

We are into the development of an application in C#. In one of the module we are using RichEdit control as text editor. This text editor is resposible
for highlighting certain keywords. After parsing the text we are using the
following methods for setting the color of the text.

RichText.Select(int startIndex, int length) &
RichText.SelectionColor = Color.Red

This is working fine. But while loading a file of 10000 lines, this color
setting is taking almost 15mints, which is not at all desiarable. Is there
any better way to do this. The file format is ASCII and we don't want to use rtf format.

We are using .Net 1.1.

We have found that for selecting text, SendCommand API with command ID
EM_SETSEL is much faster.

But still we are missing a proper solution for changing the font color of
selected text. Currently we are

using the method "SelectionColor" which is very slow. Could you give an
alternative solution for this issue.

Thanx in advance.


Nov 15 '05 #2
many many thanks for your time and help. I am trying to implement this. Will
bother you again in case i again fcae a problem. :)
"Miroslav Balaz" <mi************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

You can use "Text Object Model" technology
---------------------------------------------
More information:

MSDN Library under:

User Interface Design and Development
/ Windows Controls
/ Individual Control Information
/ Rich Edit Controls
/ Messages
and (or)
/ Text Object Model
/ Interfaces
/ ITextRange

---------------------------------------------
Used Interfaces:

ITextDocument,
ITextRange.

both defined in RICHED20.dll
(C:\WINDOWS\System32\RICHED20.dll)

From VS Studio IDE :

Project / Add Reference / (tab) COM

add
"tom"

---------------------------------------------
I have this tested with success in Delphi only

From my program /Delphi, sorry, but it is relativ simple/:
///////////////////////////////////////////////////////////////////////////

//--- function for retrieving connection with TOM
function TForm1.GetTextDocumentAndRange(const RichEdit1HWND:THandle;
var RichEditOle:IUnknown; var pDoc:ITextDocument;
var r:ITextRange):Boolean;
begin
// RichEdit1HWND this is hwnd (window handle) of my RichEdit1 component
if (SendMessage( RichEdit1HWND, EM_GETOLEINTERFACE, 0,
Longint(@RichEditOle) ) <> 0) then
if (RichEditOle<>nil) and
(RichEditOle.QueryInterface(IID_ITextDocument, pDoc) = 0) then
begin
r:=pDoc.Range(0,0);
result:=r<>nil;
end;
end;

// IID_ITextDocument -> GUID constant from tom_tlb.pas - generated from
delphi by importing tom
// IID_ITextDocument has value: {8CC497C0-A1DF-11CE-8098-00AA0047BE5D}
//////////////////////////////////////////////////////////////////////////// //

From preceding function you have r as ITextRange

ITextRange serve as "hidden" selection

Now You can use functions as:

r.FindText()
r.Move()
r.MoveEnd()
..
r.MoveStart()
..
r.collapse
r.copy
r.paste
..
..
r.Start = .. // Begin of selection - but this is only virtually selected
r.End = .. // End of selection

// and more - for retrieving TextRange

// and HIGHLIGHTING selection / word :

// changing font color
r.Font.ForeColor =

// changing style
r.Font.Bold = true / false

and so on (see MSDN Lib please)

Warning : at end you have to free r and pDoc

-----
Miro

"Catherine Jones" <no*@moreply.com> píąe v diskusním příspěvku
news:u0**************@TK2MSFTNGP10.phx.gbl...
Hi all,

We are into the development of an application in C#. In one of the module
we
are using RichEdit control as text editor. This text editor is

resposible for highlighting certain keywords. After parsing the text we are using the following methods for setting the color of the text.

RichText.Select(int startIndex, int length) &
RichText.SelectionColor = Color.Red

This is working fine. But while loading a file of 10000 lines, this color setting is taking almost 15mints, which is not at all desiarable. Is there any better way to do this. The file format is ASCII and we don't want to

use
rtf format.

We are using .Net 1.1.

We have found that for selecting text, SendCommand API with command ID
EM_SETSEL is much faster.

But still we are missing a proper solution for changing the font color of selected text. Currently we are

using the method "SelectionColor" which is very slow. Could you give an
alternative solution for this issue.

Thanx in advance.


Nov 15 '05 #3

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

Similar topics

2
by: m3ckon | last post by:
Hi there, had to rush some sql and am now going back to it due to a slow db performance. I have a db for sales leads and have created 3 views based on the data I need to produce. However one...
6
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7"...
0
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web...
7
by: Alan Bashy | last post by:
Please, guys, In need help with this. It is due in the next week. Please, help me to implement the functions in this programm especially the first three constructor. I need them guys. Please, help...
1
by: Steve | last post by:
Hi, I've asked this question a couple of times before on this forum but no one seems to be nice enough to point me to the right direction or help me out with any information, if possible. Please...
22
by: KitKat | last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7, and Cam 8. Well it does that but it also needs to change the file name to the same folder where the file is being...
17
by: Saps | last post by:
Hi all. Can anyone help me here. I have loads of .sql files and i need a way to call these from my asp page so the user can run them from the browser. Meaning i have a page with a list of all...
8
by: CM | last post by:
Hi, Could anyone please help me? I am completing my Master's Degree and need to reproduce a Webpage in Word. Aspects of the page are lost and some of the text goes. I would really appreciate it....
1
SKJoy2001
by: SKJoy2001 | last post by:
PLEASE HELP ME!!! P E R L!!! I have a CGI (PERL) file namely 'test.cgi' and it has the correct permission (755) on the FTP server and it is within the CGI path. I have the following code in it:...
6
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
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...
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...
0
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,...

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.