[PARTIALLY RESOLVED] RichTextBox
Hi
I am sure there must be a very simple solution for this but guess what? I am stuck... I have tried to explain my problems in detail but if you still have a query, do ask.
Lets say a RTB has the following text...
Quote:
johny went for a walk
Today is monday
Yesterday was sunday
day after tomorrow will be Wednesday
1) How do I loop through every line in the RTB and display the text in a messagebox? For example, it should first display "johny went for a walk" and then "Today is monday" and so on till the end of RTB is reached.
2) How do I put a "#" sign before every sentence so that I get something like the below at a click of a button. If this is not possible which I doubt, an alternative for this would be what I have in mind (see Question 4)
Quote:
#johny went for a walk
#Today is monday
#Yesterday was sunday
#day after tomorrow will be Wednesday
3) How do I disable pasting of Ole objects in RTB? If a user copies text+image and presses Ctrl + V in the RTB, only the text should be copied. I know how to do it for simple text but I want to block Ole objects... In short I want selective "Paste" to happen
and lastly,
4) RichTextBox1.SelBullet = True will enable the bullet in RTB. Is there any way that I can change the type of bullet from the "Dot" to say a "#"?
Sidz
Re: [PARTIALLY RESOLVED] RichTextBox
Re: [PARTIALLY RESOLVED] RichTextBox
i am sure you can monitor the clipboard data to enable or disable pasting to the richtextbox
try like this for control V, only allows pasting of text, but you would need to have code for other pasting method, tested with text and image, text pasted, but no image
vb Code:
Private Sub Rtb_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyV And Not Clipboard.GetFormat(vbCFText) Then KeyCode = 0
End Sub
you would also need to check the shift property, for it to work properly for normal typing
Re: [PARTIALLY RESOLVED] RichTextBox
ok pete, I'll give it a try
Re: [PARTIALLY RESOLVED] RichTextBox
Following up on westconn1's idea. The following appears to work well. I rem'd out the RTF format because it can contain embedded objects, which also means you lose RTF formatting.
Code:
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyV Then
If (Shift And vbCtrlMask) Then
' If Clipboard.GetFormat(vbCFRTF) Then
' RichTextBox1.SelText = Clipboard.GetText(vbCFRTF)
If Clipboard.GetFormat(vbCFText) Then
RichTextBox1.SelText = Clipboard.GetText(vbCFText)
End If
KeyCode = 0&
End If
End If
End Sub
As a side note. If RTF formatting is desired but embedded objects/images, etc are not then maybe pasting the info to a hidden RTF control, processing the lines from that and copying those lines only to the main control? Just an idea.
Re: [PARTIALLY RESOLVED] RichTextBox
still need to trap for pasting from context or other menu, also drag drop
Re: [PARTIALLY RESOLVED] RichTextBox
Quote:
Originally Posted by westconn1
still need to trap for pasting from context or other menu, also drag drop
Probably trap for drag/drop, but the rtb doesn't have a context menu. Not for me, thought that was strange. Any one have a context menu for their RTB, SP6?
Re: [PARTIALLY RESOLVED] RichTextBox
it's a property setting. Enablecontextmenu or some such. Gives you cut and paste commands.
Re: [PARTIALLY RESOLVED] RichTextBox
For your #4 question I use something similar where a floating forms insert symbols into the rtb. For th pound sign(#)
rtb.SelText = Space(3) & Chr$(35)
Its not a bullet ,but could be used as such
1 Attachment(s)
Re: [PARTIALLY RESOLVED] RichTextBox
@ Keith: I am speechless :) I had almost lost hope on this one. I copied the picture and text as shown in the picture and pasted it in the RTB. It works as I wanted it. It still needs a slight modification which I will be able to take care of. If you see the picture, it creates a gap where the picture was.
@ Keith/Pete/Lord Orwell: I am not too much worried about blocking the Menu because the user in my application will not have access to that.
@ isnoend07: No this is not what I want. I'll explain where it is coming from... In the Code generator addin which I created (See the link in my signature), the RTB's are coded in such a way that your codes get automatically formatted as they would in VB6 Editor. So In the Description RTB I wanted to use ' as a bullet so that every line could be commented. I achieved what I wanted but with a different technique... Thanks to Keith, he pointed out that you could change the bullets to only 6 different styles by pressing Ctrl+Shift+L (The single quote is not one of them, wish it was... it would have saved me some coding :))
So now only the last question i.e. Qno 4, remains unsolved….
Edit: Keith, seems like I recently rated you... It is not allowing me to do it again. Let me spread some reputation and then I will come back to this thread... It is a promise :) Thanks once again for your help :thumb:
Re: [PARTIALLY RESOLVED] RichTextBox
you should be able to replace any bullet character within the textrtf with some other character, but i am not sure what other repercussions there maybe to doing that
can you change the bullets in a richtext document in word or wordpad, the richtextbox only supports a limited range of the richtext specification, but other features can be directly inserted into the richtext string, the problem with this is the richtextbox does not know how to display anything extra
Re: [PARTIALLY RESOLVED] RichTextBox
Hi Pete, can you give me an example.
1 Attachment(s)
Re: [PARTIALLY RESOLVED] RichTextBox
i never tried for bullets, but i was able to do to insert decimal tabs, before shell printing with wordpad,
open the file for input, replace the rtf tags with the desired ones, then save the file again
all wrong works fine, see image
Code:
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}
{\f3\froman\fcharset2\fprq2{\*\panose 05050102010706020507}Symbol;}{\f14\fnil\fcharset2\fprq2{\*\panose 05000000000000000000}Wingdings;}{\f28\froman\fcharset238\fprq2 Times New Roman CE;}{\f29\froman\fcharset204\fprq2 Times New Roman Cyr;}
{\f31\froman\fcharset161\fprq2 Times New Roman Greek;}{\f32\froman\fcharset162\fprq2 Times New Roman Tur;}{\f33\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f34\froman\fcharset178\fprq2 Times New Roman (Arabic);}
{\f35\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f44\fmodern\fcharset238\fprq1 Courier New CE;}{\f45\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f47\fmodern\fcharset161\fprq1 Courier New Greek;}{\f48\fmodern\fcharset162\fprq1 Courier New Tur;}
{\f49\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f50\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f51\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;
\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;
\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang3081\langfe1033\cgrid\langnp3081\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}}
{\*\listtable{\list\listtemplateid67698703\listsimple{\listlevel\levelnfc0\levelnfcn0\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace0\levelindent0{\leveltext\'02\'00.;}{\levelnumbers\'01;}\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1
\fi-360\li720\jclisttab\tx720 }{\listname ;}\listid1126236972}{\list\listtemplateid841522974\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid1759122602
\'01\u-3913 ?;}{\levelnumbers;}\f3\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li1440\jclisttab\tx1440 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext
\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li1440\jclisttab\tx1440 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0
{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li2160\jclisttab\tx2160 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1
\levelspace1080\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li2880\jclisttab\tx2880 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0
\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li3600\jclisttab\tx3600 }{\listlevel\levelnfc23\levelnfcn23\leveljc0
\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li4320\jclisttab\tx4320 }{\listlevel\levelnfc23
\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li5040\jclisttab\tx5040 }
{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li5760
\jclisttab\tx5760 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1
\chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li6480\jclisttab\tx6480 }{\listname ;}\listid1178622011}{\list\listtemplateid841522974\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0
{\leveltext\leveltemplateid67698695\'01\u-3983 ?;}{\levelnumbers;}\f14\fs16\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li1440\jclisttab\tx1440 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1
\levelspace1080\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li1440\jclisttab\tx1440 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0
\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li2160\jclisttab\tx2160 }{\listlevel\levelnfc23\levelnfcn23\leveljc0
\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li2880\jclisttab\tx2880 }{\listlevel\levelnfc23
\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li3600\jclisttab\tx3600 }{\listlevel
\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698693\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li4320
\jclisttab\tx4320 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698689\'01\u-3913 ?;}{\levelnumbers;}\f3\chbrdr\brdrnone\brdrcf1
\chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li5040\jclisttab\tx5040 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698691\'01o;}{\levelnumbers;}\f2\chbrdr
\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li5760\jclisttab\tx5760 }{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace1080\levelindent0{\leveltext\leveltemplateid67698693
\'01\u-3929 ?;}{\levelnumbers;}\f14\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-360\li6480\jclisttab\tx6480 }{\listname ;}\listid1482885489}}{\*\listoverridetable{\listoverride\listid1126236972\listoverridecount0\ls1}
{\listoverride\listid1178622011\listoverridecount0\ls2}{\listoverride\listid1482885489\listoverridecount0\ls3}}{\info{\title q}{\author peter hall}{\operator peter hall}{\creatim\yr2009\mo2\dy16\hr21\min54}{\revtim\yr2009\mo2\dy16\hr21\min55}{\version1}
{\edmins1}{\nofpages1}{\nofwords0}{\nofchars0}{\*\company }{\nofcharsws0}{\vern8247}}\paperw11906\paperh16838 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180
\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd
\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang
{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7
\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\listtext\pard\plain
\f14\fs16\lang3081\langfe1033\langnp3081 \loch\af14\dbch\af0\hich\f14 \'71\tab}\pard\plain \ql \fi-360\li1440\ri0\widctlpar\jclisttab\tx1440\aspalpha\aspnum\faauto\ls3\adjustright\rin0\lin1440\itap0 \fs24\lang3081\langfe1033\cgrid\langnp3081\langfenp1033
{Gg
\par {\listtext\pard\plain\f14\fs16\lang3081\langfe1033\langnp3081 \loch\af14\dbch\af0\hich\f14 \'71\tab}Gg
\par {\listtext\pard\plain\f14\fs16\lang3081\langfe1033\langnp3081 \loch\af14\dbch\af0\hich\f14 \'71\tab}Ggyyh
\par {\listtext\pard\plain\f14\fs16\lang3081\langfe1033\langnp3081 \loch\af14\dbch\af0\hich\f14 \'71\tab}Qwerty
\par {\listtext\pard\plain\f14\fs16\lang3081\langfe1033\langnp3081 \loch\af14\dbch\af0\hich\f14 \'71\tab}Tony
\par }\pard \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 {
\par
\par }}
looks like a lot of text for 4 lines of garbage, most of which you don't need
i would create 2 rtf in word, just with different bullets then should be able to find what part represents the bullet character, my guess is it will be in the last 20 lines
i saved a rtf in word with different bullets, then opened in a richtextbox, open in notepad to see as above