|
|
Comments and Discussions
|
|
 |

|
Hi,
Could you please provide ideas how to paste simple tables (e.g. two rows, two columns) from Microsoft Word or WordPad into this editor?
After pasting from Word or Wordpad into this rich edit control, the table is not displayed correctly.
Any help is appreciated.
Thank you.
|
|
|
|
|

|
Hi @all,
I used this class in my application and now I am trying to print a CRulerRichEditCtrl! Everything works fine, just one thing does not work.
I use FormatRange and DisplayBand to print the CRichEditCtrl, but I don't know how to find out at which point on my paper the application stops printing. I want to print another line of text after the CRichEditCtrl and so I need to know, where I can print further.
Can anybody tell me what I have to do?
Sorry for my english
Greetings,
Lexaja
|
|
|
|

|
Hello there.
Is it possible to layout the edit text context in form of two columns ?
ie there should be a fictiouness vertical separator in the middle such that text is first draw to the left and then completed starting at the top of the right region ?
Thank you.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|

|
The RTF-control is not supporting this. I imagine it would be possible to do by hand (two controls, perhaps, or using the built in table capabilities?) - I do believe, however that it would be quite complicated to implement.
|
|
|
|

|
Hi there, great class and thank you for writing it.
Is it possible to use this class in a commercial application?
thanks.
|
|
|
|

|
The parts I've written are in the public domain. The control, however, uses code from two other articles as stated above. One (the color picker) is published under the The Code Project Open License (CPOL), the other - the CStdioFile class, has no licence at all. You might want to check with the two writers of those articles.
|
|
|
|
|

|
If memory serves, you had to - at least MFC under MSVC 6.0, add code to accomplish this. It existed a component giving copy & paste support - you'll just have to check CFormView on MSDN.
|
|
|
|

|
remove the copy & paste accelerator items,it will do work.
|
|
|
|

|
The demo does not display embedded images already present in a RTF file. Does your control support embedded images? If it does, then I have a great need for your control.
|
|
|
|
|

|
Hi
Is is possible to use it inside a CView (or derived class)? If yes, how? I dont want to use CRichEditView class (and the associated Doc one). Also is there any way of forcing with richedit.dll would be loaded?
thanks
|
|
|
|

|
You could make an instance of the control a member of a plain vanilla view, resizing it in the view OnSize-handler. A specific DLL is already loaded by the CRulerRichEditCtrl constructor, you might want to modify this.
|
|
|
|

|
Thanks a lot Johan
The resize is not working. Assertion fails. I did this: (m_rtf is the CRichEditRulerCtrl type member of CView derived class).
void CRTFCtrlTestView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
if(m_rtf.GetSafeHwnd())
{
m_rtf.MoveWindow(0, 0, cx, cy);
}
}
|
|
|
|

|
You might want to break into the code when the assertion triggers. By pressing - if memory serves - the middle button, the line with the assert from the MFC source code will be displayed. More often than not, this gives a clear indication what has gone wrong.
|
|
|
|

|
Hi Johan
Finally got it working. The fact is MoveWindow wont work, dont know why.
This piece works:
GetClientRect(&rect);
m_Rtf.SetWindowPos(&wndTop, 0,0, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW);
(thanks to David Kruglinsky)
The toolbar bitmap was also not loading.
regards.
alam
|
|
|
|
|

|
this was a bit brief, I guess the body got lost somewhere
|
|
|
|

|
Hi. Thanks for your good Rich Edit Implementation. It works very fine, but i got a Problem on a Windows 2003 Server. The Rich Edit Box is not Displayed. Any guess, what might cause this?
Thanks a lot
|
|
|
|

|
Most likely because the RTF-control is missing on it. I've no idea on the redistribution rules, and must therefore unfortunately recommend a search on MSDN (www.msdn.microsoft.com). Riched20.dll is the dll containing the control.
|
|
|
|

|
Hello,
I'm End-User and looking for a RTF Editor that can handle
bigger Files than 30 MB. Windows WordPad limits ca. 28 MB.
Your Demo.exe (and many RTF Editors i tested)freezing, when
I wan't start a 28MB.RTF(Wordpad load this File in 3 sec.)
Is there a Way to create a RTF Editor for Big Documents?
salü
@thehop
|
|
|
|

|
You might want to experiment with the LimitText method of the control. You might perhaps also want to think of ways to split that amount of data, rest assured, no one will ever have the patience to read that much
|
|
|
|

|
Not a particularly big thing, but if you call ShowRuler / ShowToolbar (FALSE) before creating the control, the show state is ignored in CreateRuler / CreateToolbar.
The corrected code (without comments) is below.
Iain.
BOOL CRulerRichEditCtrl::CreateToolbar()
{
CRect rect;
GetClientRect( rect );
CRect toolbarRect( 0, 0, rect.right, TOOLBAR_HEIGHT );
BOOL bReturn = m_toolbar.Create( this, toolbarRect );
ShowRuler (m_showRuler);
return bReturn;
}
BOOL CRulerRichEditCtrl::CreateRuler()
{
CRect rect;
GetClientRect( rect );
CRect rulerRect( 0, TOOLBAR_HEIGHT, rect.right, TOOLBAR_HEIGHT + RULER_HEIGHT );
BOOL bReturn = m_ruler.Create( rulerRect, this, RULER_CONTROL );
ShowRuler (m_showRuler);
return bReturn;
}
|
|
|
|

|
Hoho! The bug count is creeping upwards, soon time for an update, I should think.
|
|
|
|

|
You declared the first char vector of size [cb + 1], of course, to be a null terminated string.
Is the case that the TCHAR vector to be declared in the same way, of size length + 1 not just length, and to have wBuff[ length ] = ( TCHAR ) 0;, since you use it as a string. Otherwise the saved file will have extra characters at the end.
|
|
|
|

|
It will indeed be very difficult for str to know the length of the added buffer without a terminating NULL in wBuff.
|
|
|
|

|
Here is some fixed code for StreamOut()
if( length )
{
TCHAR* wBuff = new TCHAR[ length+1 ];
::MultiByteToWideChar( CP_UTF8, 0, buff, max, wBuff, length+1 );
wBuff[length]=0;
*str += wBuff;
delete[] wBuff;
}
|
|
|
|

|
Thanks for the feedback - it seems like I'll have to update this article
|
|
|
|

|
Why is the source code using CP_UTF8 ?
For example, in function "StreamOutLen", this occurs:
** BEGIN QUOTE **
#ifdef _UNICODE
// We want to convert the buff to wide chars
*pLen += ::MultiByteToWideChar(CP_UTF8, 0, pbBuff, cb, NULL, 0);
** END QUOTE **
I'm no expert, but as far as I know, it is very unlikely that the current ANSI codepage (to use MS terminology) is UTF-8. I mean, I don't know what the default ANSI codepage is for the handful of languages that MS-Windows supports which don't have ANSI codepage --and I even forget what they are -- but for most languages supported by MS-Windows, there is a Microsoft codepage.
Wouldn't the CStrings be in the current Microsoft codepage, rather than in UTF-8?
Bottom line: I would expect to see CP_ACP there instead of CP_UTF8. But, I'd think it wouldn't work at all (except for pure ASCII letters) with that CP_UTF8 in there, so if it is working at all for anything but ASCII, I must be wrong
|
|
|
|

|
Ok, I was wrong. It is converting from internal UCS-2 to external UTF-8 for storage -- and it isn't really storing anything as UTF-8 anyway, it turns out to be storing things as unicode escaped RTF -- maybe the rich edit internals are doing that before these stream functions are called. So feel free to delete this whole thread.
|
|
|
|

|
Well, it is an interesting issue. Let us just hope the day comes when we can forget - one way or the other - everything about different character sets!
|
|
|
|

|
Hello Johan,
Thank you for this cool control! It is very useful for me. I especially appreciate that it works correctly with UNICODE (unlike other similar controls).
Unfortunately I found one issue with it. When I paste some text into the control (using Ctrl+V), some strange characters are placed before the actual text. The characters are always the same (áíčíářáé, but that probably depends on the OS version, I have WinXP czech).
This does not happen when the text is a plain text. It happens only if the text is a rich text (I tested pasting texts from various web sites).
Thank you again
Vaclav
-- modified at 6:25 Friday 4th November, 2005
|
|
|
|

|
Hm, you write "various websites". Given that websites seldom are coded in RTF, I wonder if that is really what you are getting into the control. You might want to check the format of the contents of the clipboard (I have some hazy recollection that you can see the content type in Office-applications, for example. Otherwise, there are most likely clipboard inspectors in abundance for download).
If you write the proper text directly into another instance of the control and copy/past it, will it be corrupted as well? If you copy from WordPad? Word?
|
|
|
|

|
Hello,
How can I get a FLAT style scrollbar in RichEditCtrl?
Thanks!
|
|
|
|

|
I've no idea if it is possible. Checking MSDN (www.msdn.microsoft.com[^]), I can see that there are flat scrollbars as separate controls. Synchronizing them with a RTF-control would be a major hassle. Owner-draw, perhaps? You might want to search more on MSDN.
|
|
|
|

|
Hello, Mr. Rosengren. I'm a new guy in programming from china. I get your code on codeproject, it's very helpful to me. But now I meet a problem. I think the fonts which your editor supported is just the TTF font which supported by MS. If I want to input and edit the fonts which MS do not supported like the font used by autodesk company(.SHX font), what shall i do? Can you give me some advice? My email is pzili@21cn.com.Thanks a lot!
|
|
|
|

|
Thanks a lot for the feedback! As for using SHX-fonts in the RTF-control, I suspect you are out of luck. I think that the best you can do is trying to find Windows-usable counterparts for the fonts, at least as far as it is possible. You'll have some tricky work converting from and to the RTF-control as well, something I regret to say I would even hesitate to try to do commercially.
|
|
|
|

|
I replaced an existing richeditctrl with your nice control. While all other tested features worked, findtext seems not to be working. I didnt do to much investigation - because this could be of general interest to others too. I used m_rtf.GetRichEditCtrl().Findtext.
Here is the full function in question:
void CTextDlg::OnTextFind()
{
CTextFindDlg dlg;
if(dlg.DoModal()== IDOK) //not canceled
{
DWORD dwFlags=0;
if(dlg.m_bCase)
dwFlags |=FR_MATCHCASE ;
if(dlg.m_bWholeWord)
dwFlags |= FR_WHOLEWORD ;
FINDTEXTEX txt;
CHARRANGE chr;
chr.cpMax=-1;
chr.cpMin=m_LastFound+1;
txt.chrg=chr;
txt.lpstrText = dlg.m_strTextToFind.GetBuffer(255);
m_LastFound= m_rtf.GetRichEditCtrl().FindText(dwFlags,&txt);
if(m_LastFound < 0)
AfxMessageBox("Not found");
else
......
......
As already said, this piece of code worked for years with a CRichEditCtrl (v3.0).
Tracing shows that everything works, but FindText delivers always -1 for not found,
although the searched text is in the control (no matter lower case, upper or whole word).
I personaly don't work too often with Richedit. I remember faintly that you got to enable
some features before they work. But these cases concern notify messages
(and some options) as far as I remember.
Thanks!
Rotbarsch
|
|
|
|

|
The RTF-control is a monster, and will sooner or later either kill me or give me gray hairs. Or both (but not in that order, I assume).
Indeed the code you show will not find anything. By initially setting dwFlags to FR_DOWN, I got it to work, however. You might need to force the selection with a SetSel as well. I didn't need to do it, but I got a felling that it might be best to do it...
|
|
|
|

|
Thanks a lot - in the name of many I suppose. But why? (only rhetorical question-no answer expected. Microsoft code is full of wonders.)
|
|
|
|

|
Often, you'll have to read the docs for both MFC and the pure SDK functions *sigh*.
|
|
|
|

|
hi johan
try creating a bulleted list with say 4 items. then select the list and indent it multiple times. you should see the space between the bullet and the text get wider as the number of indents increases.
i'm looking into it myself but wondered if you had run into this before.
.dan.g.
AbstractSpoon Software
|
|
|
|

|
I must admit not having tested nested bullets. I'll check out the tab-setting (which I assume is used for the bullets) and the bulleting myself.
|
|
|
|

|
many thanks. i had hoped to have found another richedit component against which to have compared yours but whilst there are alot of richedit apps out there all (so far) do not support indenting.
.dan.g.
AbstractSpoon Software
|
|
|
|

|
Well, this was due to my lack of understanding of the parameters of the PARAFORMAT struct. The member dxOffset should be set to the desired offset from the bullet, not the screen. So, by searching for dxOffset in RulerRichEditCtrl.cpp, and replace the value with 0, this is fixed.
It will however leave the bullet a bit close to the text. This can of course be set to something more appropriate, in twips mind you, but then it will also have to be done in DoBullet in the same file.
I'll do a regular update, but it'll take a little time.
|
|
|
|

|
hi johan
i'm close to releasing the rtf plugin for ToDoList and was just filling in the copyright section of the dll. are you happy with joint copyright on the dll and a credit in ToDoList's about box?
i was also toying with the idea of adding an about box to the plugin dll itself, accessible from the context menu which i've added.
it's not so much that you might be very bothered about this but i appreciate the work you've done (it made my life in this respect much easier) and feel that free software should get all the credit it can.
rgds
.dan.g.
AbstractSpoon Software
|
|
|
|

|
Hi Johan,
Excellent work! Just one question, is it possible to have the text wrap automatically to the next line when you reach the end of the window width (i.e. can horizontal scrolling be disabled and instead word wrapping be used?)
Thanks,
Ibrahim
|
|
|
|

|
Sorry, my dumb mistake. Just realized it's in the styles of the rtf control.
Thanks and sorry for the noise!
Ibrahim
|
|
|
|

|
Thanks for the feedback!
You'll currently have to do a modification in the sourcecode to accomplish this, you'll have to change the line:
DWORD style = ES_NOHIDESEL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_WANTRETURN | ES_MULTILINE;
to
DWORD style = ES_NOHIDESEL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_WANTRETURN | ES_MULTILINE;
in RulerRichEditCtrl.cpp. I will change the next revision so that this is made automatically when the last parameter to the complete control Create-call is FALSE.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
A complete mini-editor with a formatting toolbar and a ruler with editable tab-positions.
| Type | Article |
| Licence | Public Domain |
| First Posted | 22 Apr 2004 |
| Views | 198,422 |
| Bookmarked | 150 times |
|
|