|
|
I´m using your richtextbox in a final exam for the university, and I´m reading the font name with 'FN (string) = rtbTexto.SelectionFont.Name', and works right!
But... when I select more than ONE name of font at the same time, Visual goes in an unhandled exception (sorry for my english) .
How can I handle this?
Thanks in advance!
Fernando Martin
|
|
|
|
|
How can I append text to the richtextbox and keep the previous highligting. Currently, if I add any text, the entire background color the richtextbox will take on the highligting color? Any ideas on how to keep the current highlighted keywords and append text?
|
|
|
|
|
Hi!
Very nice job!
But:
I am getting stucked when working with some texts ad trying to "Highlight" some words.
E.G.
Test that conatins only the word:
"CompareTest"
Any idia?
Thanks in advance...
|
|
|
|
|
Hi,
Just add
If Me.Text.Length = StartFrom Then
Exit While
End If
in the Highlight section.
Hope this helps 
|
|
|
|
|
I have been struggling with the RichTextBox for about three days now and have been met with only frustration. My application is a terminal emulator that requires text coloring and highlighting for some of the terminal types. I dropped the project right into my solution in source control, added a reference, changed my System.Windows.Forms.RichTextBox to Tarro.Windows.Forms.RichTextBox and my struggles with highlighting text were instantly over. This freed me up to concentrate on the actual core of the application rather than fight with the standard RichTextBox. I'm giving it 5 stars!
-- modified at 3:47 Tuesday 9th May, 2006
One thing I forgot to mention. There is a small bug with the ScrollToBottom function. It seems to clip the bottom line. I tried resizing my textbox thinking that I could affect the size of the offset, but it always seemed to have the same offset. The scroll bar indicates it hasn't scrolled to the bottom as well since it shows a small amount of space between the thumb bar and the bottom scroll button.
|
|
|
|
|
I fixed the scrolling issue and just wanted to post the fix here. In the ScrollToBottom proc you have a line that reads:
<br />
SendMessage(Me.Handle, EMFlags.EM_SETSCROLLPOS, 0, New RichTextBox.POINT(0, Max - Me.Height)).<br />
The fix is to replace Me.Height with Me.ClientSize.Height so the line now reads:
<br />
SendMessage(Me.Handle, EMFlags.EM_SETSCROLLPOS, 0, New RichTextBox.POINT(0, Max - Me.ClientSize.Height)).<br />
-- modified at 1:32 Wednesday 10th May, 2006
|
|
|
|
|
- Who can tell me the CharFormat2 Structure :
<structlayout(layoutkind.sequential)> Private Structure CharFormat2
Public cbSize As Int32
Public dwMask As Int32 'this is mean ???
Public dwEffects As Int32 'This is mean ???
Public yHeight As Int32
Public yOffset As Int32 'This is mean ???
Public crTextColor As Int32 'This is mean ???
Public bCharSet As Byte 'This is mean ???
Public bPitchAndFamily As Byte 'This is mean ???
<marshalas(unmanagedtype.byvaltstr, sizeconst:="32)"> Public szFaceName As String
Public wWeight As Int16
Public sSpacing As Int16
Public crBackColor As Int32
Public lcid As Int32
Public dwReserved As Int32
Public sStyle As Int16
Public wKerning As Int16
Public bUnderlineType As Byte
Public bAnimation As Byte
Public bRevAuthor As Byte
Public bReserved1 As Byte
End Structure
for all.
- How can I get a explanation for SendMessage's functions. I found out a lot of SendMessage function but I don't know how do I do ???
- EveryBody can help me, thanks you !!!!
|
|
|
|
|
If you have got(or you are getting) the new express Visual C++ 2005 Edition, you will find that your code works really easily in that version. Because the new language is a mixture of Visual Basic and VS.Net, your code is ideal for highlighting text. The following example is for a RichTextBox (richTextBox1) on a windowsform. After you have highlighted some text and you have clicked a button, this is all the code that is needed:
richTextBox1->SelectionBackColor = Color::Red;
I think that you have saved people a lot of hard work.Well done.
|
|
|
|
|
Really nice code - easy to read and extend. I have a need for hiding some text as well, so I added a property SelectionHidden and a procedure UnHideAll(), in almost exactly the same way. Very easy to do (of course I can let you have the code if you like).
Thanks for your efforts!
Roger Lainson
|
|
|
|
|
Sir,
Your article is very nice. Pls add some description about how to highlight the RichTextbox text through another form.
|
|
|
|
|
when i reference the dll in the c# project, the tarro class is working. but when i compile the project the error begin to occur.i dont really understand it. but i'm sure it is with the dll, and one more thing, when i use regasm to register the tarro dll. it cant be registered because of its depedencies. i really dont understand the error. can someone help me on how to answer the problem.thanks a lot
|
|
|
|
|
Hi Frederick,
Have you added the capability to adding images to your extended richtextbox? Did you figure out a managed way using interop? Please let me know!
Thank you
|
|
|
|
|
but wouldn't using RegEx be faster in the high-lighting procedure?
Another thing - If I just put an RTB on a form and run it, there are a few shortcut keys that work in it although I never set them, and there's property to turn it off (Ctrl-I to increase indentation, Ctrl-1,2,5 to change the line-spacing *no method to do it programtically??*).
Any idea how to set it off?
|
|
|
|
|
Not that I know to, there probably is though, you could look up the RichText stuff on MSDN, and if all else fail, you could override WndProc and kill the shortcuts manually.
--
Rob Hutchinson - Software Architect.
|
|
|
|
|
Well, I managed to do this with ProcessCmdKey, but I'm not sure if it works 100%.
Do the shortcut keys work on your system too?
I'm not sure if it's a "feature" or a bug...
|
|
|
|
|
From MSDN:
"Command keys are keys that take precedence over regular input keys. Examples of command keys are shortcut keys and access keys. If this control has a shortcut menu (also known as a context menu), this method calls the processCmdKey method of the ContextMenu object that represents the shortcut menu to check for menu shortcuts. Finally, if the control has a parent, the key is passed to the parent's processCmdKey method. In this way, command keys are "bubbled" up the control hierarchy. "
-- The Context Menu doesn't have a ProcessCmdKey method!
So what am I supposed to do?
The MSDN Page
|
|
|
|
|
I'm not really sure, I`ve not messed with command keys and such before very much, you could try posting about this on the main C# forums here on CP, you are more likely to get a response there
I`ll look into it a bit more too, see if I can find anything.
--
Rob Hutchinson - Software Architect.
|
|
|
|
|
Hi, this looks good, but you should add a feature to your derived class:
InsertImage(Image img);
I found code to do this on google:
public void InserImage()
{
System.Windows.Forms.OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Filter = "JPEG (*.jpg)|*.jpg|BMP (*.bmp)|*.bmp|PNG
(*.png)|*.png";
fileDialog.RestoreDirectory =true;
if(fileDialog.ShowDialog() == DialogResult.Cancel )
return;
string lstrFile = fileDialog.FileName;
Bitmap myBitmap = new Bitmap(lstrFile);
Clipboard.SetDataObject(myBitmap);
DataFormats.Format myFormat = DataFormats.GetFormat
(DataFormats.Bitmap);
if(NoteBox.CanPaste(myFormat))
{
NoteBox.Paste(myFormat);
}
else
{
MessageBox.Show("The data format that you attempted ste is not supported
by this control.");
} NoteBox.Focus();
}
|
|
|
|
|
Using the clipboard to insert the bitmap is a bit,.... 'Iffy'. I will look into doing this the proper way if there is one, and failing that, use the code above Cheers.
|
|
|
|
|
Using the clipboard is the only way to do this using managed code as far as I know
|
|
|
|
|
It is, but you can use Interop to make it happen. Since the RichTextBox is just interop anyhow it shouldn't matter one way or another.
On another one, being able to add Tables would be HIGHLY usefull...
|
|
|
|
|
is there anyway you can convert this into c#?
thanks
|
|
|
|
|
Maybe someone have the same functionality (write a partial text within a rich text box with a different background color?).
but in C#
thanks.
Pablo.
Regards,
Pablo Srabstein
|
|
|
|