 |
|
 |
Worked perfectly right out of the gate.
|
|
|
|
 |
|
 |
Jeremy,
GetRTF() was just what I've been looking for.
Now all I need is ConvertRTFtoHTML()
--jay
|
|
|
|
 |
|
 |
If the support GIF / BMP ....
|
|
|
|
 |
|
 |
Hello,
thanks for this framework and i have a little problem to show Unicode strings inside of my ritchedit control.
Error is: i see only the first character in buffer!!
Error in this line:
DWORD CALLBACK CAutoRichEditCtrl::CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CString *pstr = (CString *) dwCookie;
if (pstr->GetLength() < cb)
{
*pcb = pstr->GetLength();
memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
pstr->Empty();
}
else
{
*pcb = cb;
memcpy(pbBuff, (LPCSTR) *pstr, *pcb); *pstr = pstr->Right(pstr->GetLength() - cb);
}
return 0;
}
Have you any suggestions for me??
Thanks for any help!
best wishes
Arrin
|
|
|
|
 |
|
 |
I have a DLL that I am trying to use this control in, and the DLL has to be UNICODE. I am trying to auto populate the control with text when the user does something in the dialog. I am using the control only for formatted information display, no edit ability when it ships to the user, but is editable during my debugging. When I call SetRTF, nothing appears in the control. If I manually type something in it and then do something in the dialog that causes it to change, the text I typed in will disappear, but no new text appears. In order to get it to compile in UNICODE I had to change the following line in the streamin function.
memcpy(pbBuff, (LPCSTR) *pstr, *pcb);
to
memcpy(pbBuff, (LPCTSTR) *pstr, *pcb * sizeof(TCHAR));
Since I am in a DLL, I could not call AfxInitRichEdit in the InitInstance, so I placed it in the DllMain function instead.
Any ideas on how to get it to work?
I am using Visual Studio 2005
I converted the demo app to UNICODE and it exhibits the same behaviour. I can type text in the RichEditCtrl and execute the GetRTF command and it shows the formatted text in the top edit box, and can immediately execute the SetRTF command and the RichEditCtrl empties.
-- modified at 12:48 Monday 12th February, 2007
|
|
|
|
 |
|
 |
can this class support tables and tab stops, font colouring etc etc etc?
Andrew
|
|
|
|
 |
|
 |
Necessary to generate a DLL that to recoup the text formatted (rtf) for a CString. How I must proceed?
|
|
|
|
 |
|
 |
1.Riched20.dll different.
2.Unicode and DBCS
replace dll, but problem stay?
Can you help me?
|
|
|
|
 |
|
|
 |
|
 |
Hi,
What is the correct way to capture Tab Key presses in a RichEditCtrl. I saw the answer for Catching tabs but was not convinced with the answer. If I have to get the current position of the Cursor in the RichEditCtrl (GetSel()), how do I do that, and from there on how do I insert a Tab.
Some one could help me.
Thanks and Regards
Frank
|
|
|
|
 |
|
 |
Let's do this the easy way!
Open the project folder and delete the file "yourapp.clw" Now press Ctrl + W to bring up the class wizard. Select "Yes" you would like to build the class wizard database from the source files and press "Ok". This will allow the class "CAutoRichEditCtrl" to be modified by using the class wizard (much easier this way). Now open class wizard again and select the "CAutoRichEditCtrl" class and add the message "WM_GETDLGCODE". Now edit the body of the function so it looks like the following:
UINT CAutoRichEditCtrl::OnGetDlgCode()
{
return DLGC_WANTALLKEYS;
}
If you don't like the default tab stops you can change them using the SetParaFormat() function.
Jason
|
|
|
|
 |
|
 |
I have tried using the CAutoRichEditCtrl class (which is great) but i have stumbled upon a problem. I enable the control to recieve OLE objects (in my case pictures) by implementing IRichEditOleCallback and adding a SetOLECallback to my InitDialog. This works fine, the control accepts bitmap objects and the GetRTF function returns perfect RTF code containing all the OLE items.
The problem is that when i try to insert this text back into the control all OLE objects are removed and replaced by spaces. When i insert the same text into a CRichEditView all is fine.
Any ideas how this can be corrected?
|
|
|
|
 |
|
 |
iam using a different font in which some characters have a dot above it. whenever i try to write such characters a white space gets automatically appended. how do i remove such white spaces???
please help me......
thanks!
ramya.
|
|
|
|
 |
|
 |
ok - i can retrieve text from the control
but how do i insert text to it ? (not using GUI ofcourse)
(btw - Great Control)
|
|
|
|
 |
 | abc  |  | Anonymous | 18:48 26 Aug '03 |
|
|
 |
|
 |
I think it's not releated to your code - but an error in RichEdit control itself. Try this:
Add a bullet and write something, then add few blank lines and write something. It should looks like that:
* some text
another text
Then click on GetRTF and SetRTF few times - extrad dots are beign generated!
Any idea how to get rid of this ?
Thanks!
Irek
Check out my software at: http://www.ireksoftware.com
|
|
|
|
 |
|
 |
I found this problem too, you may want to edit your title to "Bug with Bulleting" or something similar.
Looks like it's a bug in MS's CRichEditCtrl. Haven't been able to figure out how to fix it yet. Any luck on your side?
|
|
|
|
 |
|
 |
This is a bug in the RichEditCtrl. This bug is solved in RichEditCtrl version 2.0. In VC 6.0 the RichEditCtrl version 1.0 is still used by the resoure editor. If you change "RICHEDIT" manually into "RichEdit20A" in the rc file, version 2.0 will be used in your dialog and the problem disappears.
I have tested this with VC 7.0.
|
|
|
|
 |
|
 |
//***************************************************************************************
// I want to draw the RichTextControl content in a specified rectangle on my printing page
// (as i done with editbox control) using FormatRange function with the different
// Font styles as in RichEditControl - HelpMe please!.
// DrawRichText(CDC *pDC) -> could u solve the problem that i have in this function ?..
//***************************************************************************************
//The partial code
//RTCtrlPrint1View.h
public:
CRTCtrlPrint1Doc* GetDocument();
//My*************************************
void RTCtrlCreate();
void DrawRichText(CDC *pDC);
void DrawEditText(CDC *pDC);
CRichEditCtrl m_redit;
CRect m_redRect;
CEdit m_edit;
CRect m_edRect;
UINT r;
CFont font;
//**************************************
//RTCtrlPrint1View.cpp
void CRTCtrlPrint1View::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
/*B**********************************************/
//edith box displaytext font
font.CreateFont(14,0,0,0,FW_NORMAL,FALSE,FALSE,
0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
DEFAULT_PITCH|FF_MODERN,"Arial");
r=14;
m_edRect = CRect(50*r,-100*r,240*r,-700*r);
m_redRect = CRect(250*r,-100*r,750*r,-700*r);
CSize sizeTotal;
sizeTotal.cx = 850*r;
sizeTotal.cy = 1100*r;
SetScrollSizes(MM_TWIPS, sizeTotal); //MM_TWIPS
RTCtrlCreate();
/*E**********************************************/
}
void CRTCtrlPrint1View::OnDraw(CDC* pDC)
{
CRTCtrlPrint1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
/*B**********************************************/
pDC->Rectangle(1*r,1*r,800*r,-1100*r);//Print Area Rect
if(pDC->IsPrinting())
{
DrawEditText(pDC);//Simple Edit box text
DrawRichText(pDC);//My RichEdit box text
}
/*E**********************************************/
}
#define IDC_REDIT 4001 //defining a resource ID
#define IDC_EDIT 4002 //defining a resource ID
void CRTCtrlPrint1View::RTCtrlCreate() //creates both Rich edit & Edit Controls
{
/*B**********************************************/
CRect m_temp;
CClientDC dc(this);
OnPrepareDC(&dc);
//creating edit box in scroll view
m_temp = m_edRect;
dc.LPtoDP(m_temp);
m_edit.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,m_temp,this,IDC_EDIT);
m_edit.SetFont(&font,FALSE);
m_edit.SetWindowText("Help Me! Thank u");
//creating rich edit box in scroll view
m_temp = m_redRect;
dc.LPtoDP(m_temp);
m_redit.Create(WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,m_temp,this,IDC_REDIT);
//writing some text in richtext control
CString str;
str="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\froman\\fprq2\\fcharset0 Times New Roman;}{\\f1\\fswiss\\fprq2\\fcharset0 System;}}{\\colortbl ;\\red255\\green0\\blue0;\\red51\\green153\\blue102;\\red0\\green0\\blue255;}\\viewkind4\\uc1\\pard\\cf1\\i\\f0\\fs24 ThankYou\
\\cf0\\i0 \\cf2\\b for\
\\cf0\\b0 \\cf3 Trying\
\\cf0 !\\b\\f1\\fs20 \\par }";
EDITSTREAM es;
es.dwCookie = (DWORD)&str;
es.pfnCallback = RichEditStreamInCallback;
m_redit.StreamIn(SF_RTF,es);
/*E**********************************************/
}
void CRTCtrlPrint1View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC, pInfo);
/*B**********************************************/
// pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetMapMode(MM_TWIPS);
/*E**********************************************/
}
void CRTCtrlPrint1View::DrawEditText(CDC *pDC)
{
/*B**********************************************/
CRect m_temp;
m_temp = m_edRect;
CString str;
m_edit.GetWindowText(str);
pDC->SetBkMode(TRANSPARENT);
pDC->Rectangle(m_temp);
//Draws with Fonts as we wish
pDC->DrawText(str,m_temp,DT_WORDBREAK|DT_EXPANDTABS|DT_NOPREFIX);
/*E**********************************************/
}
//***************************************************************************************
// I want to draw the RichTextControl content in a specified rectangle on my printing page
// (as i done with editbox control) using FormatRange function with the different
// Font styles as in RichEditControl - HelpMe please!.
// DrawRichText(CDC *pDC) -> could u solve the problem that i have in this function ?..
//***************************************************************************************
void CRTCtrlPrint1View::DrawRichText(CDC *pDC)
{
/*B**********************************************/
CRect m_temp;
FORMATRANGE fmtRange;
long lLineWidth;
m_temp = m_redRect;
// pDC->LPtoDP(m_temp);
pDC->Rectangle(m_temp);
lLineWidth = ::MulDiv(pDC->GetDeviceCaps(PHYSICALWIDTH), 1440, pDC->GetDeviceCaps(LOGPIXELSX));
fmtRange.hdc = pDC->m_hDC;
fmtRange.hdcTarget = pDC->m_hDC;
fmtRange.rc = m_temp;
fmtRange.rcPage = m_temp;
fmtRange.chrg.cpMin = 0;
fmtRange.chrg.cpMax = -1;
m_redit.SetTargetDevice(pDC->m_hDC, lLineWidth);
m_redit.FormatRange(&fmtRange, TRUE);
/*E**********************************************/
}
any body brave..
Balaji
|
|
|
|
 |
|
 |
Hi,
not really the right forum, but perhaps here is an RTF expert
I wanted to use the RTF/CRichEditCtrl as a kind of report system, where the reports are generated from templates of rtf files. A first simple solution would be to search and replace Tags within the RTF file with the computed values.
A better solution would be to use the field tag from the RTF specification directly. For example the author field from a word document would look like:
{\field{\*\fldinst
{ AUTHOR \\* MERGEFORMAT }}{\fldrslt {Dirk}}}
where fldinst is the specific field instruction and fldrslt is the latest evaluated result.
Unhappily the CRichEditCtrl does not evaluate internal fields (like author) either, and I couldn't find any Interface in the ITextDocument specification to access the fields of the document.
Does anybody know how to reevaluate the contents of fields programmatically? Something like a callback function with the fied instruction (fldinst) and the return value is the evaluated result? Another possibility would be to reparse the complete document again and aply the evaluated values into the result field (fldrslt) and then feed the document back to the Ctrl.
Any ideas / code?
Thanks
|
|
|
|
 |
|
 |
RTF documents can have informations that are not displayed like author information, version etc.
Has anyone tried to add and retrieve for example author information to a RTF document? Also has anyone tried to add bitmaps to a RTF document?
|
|
|
|
 |
|
 |
Can you tell us what was updated?
Thanks
|
|
|
|
 |
|
 |
I'm honestly not sure of that myself... My guess is that it was just some sort of administrative thing?
|
|
|
|
 |
|
 |
NT4/VS.NET needs replacement in this fct:
// for (int i = 0; i <= sFontName.GetLength()-1; i++)
// cf.szFaceName[i] = sFontName[i];
lstrcpy(cf.szFaceName,sFontName);
otherwise the szFaceName will keep letters in szFaceName that are not replaced, sometimes causing a crash!
|
|
|
|
 |
|
 |
Yes, I just stumbled across that, too ... I did a slightly different fix, by adding the following after the for loop:
cf.szFaceName[sFontName.GetLength()] = '\0';
|
|
|
|
 |