|
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)
|
|
|
|
|
|
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';
|
|
|
|
|
SetFontName doesn't seem to function for me.
|
|
|
|
|
It should work just fine, as long as you supply a nul byte after the name of the font. My earlier posting showed how this was done, as did Anonymous' posting about the bug.
|
|
|
|
|
I am using richedit20.dll(version). Most of the features like multi undo and redo work but somehow the paste doesn't work. It cuts the text but doesn't paste it. If I cut the text from some other application and try paste, it works.When I look at the clipboard there is nothing in it. I am using CRichEditView. I tried GetPriorityClipboardFormat(), but it returns -1.
Thanks
|
|
|
|
|
To print directly from the control add the following method (from Al Williams website)
<br />
BOOL CAutoRichEditCtrl::Print(CString Title)<br />
{<br />
CDC ThePrintDC;
CPrintDialog PrintDialog(FALSE);
<br />
if(PrintDialog.DoModal()==IDOK)
{<br />
ThePrintDC.Attach(PrintDialog.GetPrinterDC());
}<br />
else<br />
return FALSE;
long CharRange=0;<br />
long LastChar=0;
DOCINFO di;
::ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize=sizeof(DOCINFO);
di.lpszDocName=Title;
FORMATRANGE fr;
::ZeroMemory(&fr, sizeof(FORMATRANGE));
HDC hdc=ThePrintDC.GetSafeHdc();
fr.hdc=hdc;
fr.hdcTarget=hdc;
int nHorizRes = ThePrintDC.GetDeviceCaps(HORZRES),
nVertRes = ThePrintDC.GetDeviceCaps(VERTRES),
nLogPixelsX = ThePrintDC.GetDeviceCaps(LOGPIXELSX),
nLogPixelsY = ThePrintDC.GetDeviceCaps(LOGPIXELSY);
fr.rcPage.left = 0;
fr.rcPage.top = 0;<br />
fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440;
fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440;
fr.rc.left = fr.rcPage.left + 1440;
fr.rc.top = fr.rcPage.top + 1440;<br />
fr.rc.right = fr.rcPage.right - 1440;<br />
fr.rc.bottom = fr.rcPage.bottom - 1440;<br />
CHARRANGE cr;<br />
cr.cpMin=0;<br />
cr.cpMax=-1;
fr.chrg=cr;
CharRange=GetTextLength();<br />
int ErrorStatus=0;<br />
<br />
ThePrintDC.StartDoc(&di);
do<br />
{<br />
ThePrintDC.StartPage();
LastChar = FormatRange( &fr, TRUE );
ErrorStatus=ThePrintDC.EndPage();
cr.cpMin=LastChar;
cr.cpMax=CharRange;
fr.chrg=cr;
}while(LastChar==0);
switch(ErrorStatus)<br />
{<br />
case SP_ERROR:<br />
{<br />
ThePrintDC.AbortDoc();<br />
AfxMessageBox("There was a general printing error, please check printer is working properly, connected, on line etc.", MB_OK | MB_ICONEXCLAMATION);<br />
return FALSE;<br />
}<br />
case SP_APPABORT:<br />
{<br />
ThePrintDC.AbortDoc();<br />
return FALSE;<br />
}<br />
case SP_USERABORT:<br />
{<br />
ThePrintDC.AbortDoc();<br />
return FALSE;<br />
}<br />
case SP_OUTOFDISK:<br />
{<br />
ThePrintDC.AbortDoc();<br />
AfxMessageBox("The print spooler is out of disk space, free up some disk space and try again.", MB_OK | MB_ICONEXCLAMATION);<br />
return FALSE;<br />
}<br />
case SP_OUTOFMEMORY:<br />
{<br />
ThePrintDC.AbortDoc();<br />
AfxMessageBox("Your computer is out of memory, shut down some applications and/or some windows and try again.", MB_OK | MB_ICONEXCLAMATION);<br />
return FALSE;<br />
}<br />
default:<br />
{<br />
ThePrintDC.EndDoc();<br />
return TRUE;<br />
}<br />
}<br />
<br />
}<br />
|
|
|
|
|
//***************************************************************************************
// 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
|
|
|
|
|
I Try to used this AutoRichEdit. That work very well on win 9X & Win XP. But there is probleme on Win NT. Moreover, the "demo" doesn't work on NT.
Have you got an idea to solve my problem
|
|
|
|
|
I can affirm this.. the font is not changed, no matter what functions you choose in the demo. A fix would be very nice.
|
|
|
|
|