Re: Concatenated text and Leban's Rich Text Control

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Tried to get to this sooner but I have company for the Easter weekend.

First thing, you should not mix modifying the control's contents via
PlainText and RTFtext. Stick with RTFtext.

I cannot remember seeing that a line return is added to the end of inserted
text. Let's have a peek at my source code:

void CRTF2Ctrl::SetSelTextRTF(LPCTSTR lpszNewValue)
{
long l;

// Set our nSize global
nSize = (strlen(lpszNewValue)) ;
if (nSize == 0)
{
// DO NOTHING
return ;
}

BufIndex = 0;
// Insert formatted RTF text into the control
EDITSTREAM es;
es.dwError = 0;
es.pfnCallback = mEditStreamCallback;
es.dwCookie = (DWORD) lpszNewValue;

// REPLACE NOT CLEAR CONTENTS
l = ::SendMessage(m_hWnd, EM_STREAMIN, (WPARAM) SF_RTF | SFF_SELECTION,
(LPARAM) &es);
SetModifiedFlag();
}


I'm not adding a line return when I insert the RTF text.

Couple of questions:
1) Have you confirmed this behaviour, of the addition of a line return for
RTF text inserted via the SelTextRTF method, into a blank control?

2) So do I understand correctly that you have resolved your issue by calling
your RemovePar function?


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"milkmoney1970" <milkmoney1970@xxxxxxxxxxx> wrote in message
news:658d5ea3-79dd-4497-b593-c2b094c87b4a@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Thanks Stephen for taking the time to look at this.

Private Sub cmd_Add_Click()
Dim iStart As Integer
Dim strColor As String
Dim strBegin As String
Dim strEnd As String
Dim rtfAdd As RTF2
Dim rtfEdit As RTF2

On Error GoTo ErrorHandler 'Set error handler routine
Set rtfAdd = Me!rtf_Add.Object 'Set object for rtf add control
Set rtfEdit = Forms!frm_EditReview!rtf_Edit.Object 'Set object for
rtf edit control
iStart = rtfEdit.SelStart 'Get the start of selected text rich text
control
rtfAdd.PlainText = " " & rtfAdd.PlainText & " "
rtfAdd.SelStart = 0 'Set start mouse position
rtfAdd.SelLength = Len(rtfAdd.RTFtext) 'Set end mouse position
strColor = Forms!frm_Review!txt_Color 'Get the users color
Select Case strColor 'Set color for user's comments
Case "<font color=red>"
rtfAdd.SelColor (vbRed)
Case "<font color=blue>"
rtfAdd.SelColor (vbBlue)
Case "<font color=green>"
rtfAdd.SelColor (vbGreen)
Case "<font color=orange>"
rtfAdd.SelColor (vbOrange)
Case "<font color=purple>"
rtfAdd.SelColor (vbPurple)
Case "<font color=brown>"
rtfAdd.SelColor (vbBrown)
Case "<font color=black>"
rtfAdd.SelColor (vbRed)
End Select
rtfEdit.SelStart = iStart
rtfEdit.SelTextRTF = RemovePar(rtfAdd.SelTextRTF)
DoCmd.Close acForm, "frm_AddInfo" 'Close form
ExitHere:
Exit Sub
ErrorHandler:
dhError ("cmd_Add_Click")
Resume ExitHere
End Sub

Private Sub Form_Load()
Dim rtfAdd As RTF2
Dim rtfEdit As RTF2
Dim fnt As New StdFont
'On Error GoTo ErrorHandler
Set rtfAdd = Me!rtf_Add.Object 'Set objects for rtf add control
Set rtfEdit = Forms!frm_EditReview!rtf_Edit.Object 'Set objects for
rtf edit control
rtfAdd.RTFtext = "" 'Clean out rtf add field
With fnt
.Name = "calibri"
.Size = 11
End With
Set rtfAdd.Font = fnt
Me!rtf_Add.SetFocus
ExitHere:
Exit Sub
ErrorHandler:
dhError ("Form_Load")
Resume ExitHere
End Sub

On Mar 19, 11:43 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WWWdotlebansdot...@xxxxxxxxxxxx> wrote:
Post your code you are using to insert the text into the existing string.

--

HTH
StephenLebanshttp://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

"milkmoney1970" <milkmoney1...@xxxxxxxxxxx> wrote in message

news:654b4df5-2314-4685-b14f-cc2eaa027a43@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Greetings All,

I was wondering if anyone has run across the problem I'm having with
concatenating rtf control contents and line returns.

I am using Steven Leban's rich text tool in Access 2007 (as
Microsoft's integrated rich text control is pretty much useless if you
need to manipulate its contents) (Steven's tool is excellent). I am
trying to insert new text into the middle of a rich text field, after
formating it as needed, however, I've noticed that the rich text box
inserts a line return at the end of my inserted text.

I have searched around and have read that rich text sometimes works
this way, but was wondering if there is a way of removing or avoid
having, a line return inserted after my text.

Any guidance would be appreciated.



.



Relevant Pages

  • Re: Concatenated text and Lebans Rich Text Control
    ... know of any way to simulate one using your control? ... PlainText and RTFtext. ... Dim strColor As String ... Set rtfAdd = Me!rtf_Add.Object 'Set object for rtf add control ...
    (microsoft.public.access.forms)
  • Re: RichText Formatting Urls
    ... This worked which means RTF does support named links. ... as an RTF file to have a look at the rich text tags. ... However there is a RTF property against the control which gets the current ... So I'm now thinking about displaying my text with HTML in .NET 2s web ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: RTFcontrol of memo fields
    ... Do you currently have RTF formatted text in the Memo field? ... The RTF control can only display RTF encoded text. ... Dim sRTFdata As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Printing & Saving contents of scrollable window
    ... This is an interesting problem as there really isnt a lot of support for RTF ... the image of the RTF and display the image in your control area/outline. ... there can be either text (rich text) or an image. ... > going to need to both print and save these diagrams as an image. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: RichTextBox databinding problems
    ... let you bind to a binary property that took care of all this for you. ... > the last rtf character was truncated (see post "Re: Problem with rich text ... >>> control, but this seems to ignore databinding at all. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)