Solved

How to simulate VB's Procedure Seperator in a rich textbox

Posted on 2002-05-11
13
1,851 Views
Last Modified: 2012-05-04
Does anybody know how I can add a seperator line in a rich textbox,similar to the one in the VB IDE?
0
Comment
Question by:vinnyd79
  • 4
  • 3
  • 2
  • +4
13 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003865
hearing...
0
 
LVL 3

Expert Comment

by:null_pointer
ID: 7003983
Not very sure but i think what you can do is insert a line image every time you want.

RichTextBox1.OLEObjects.Add , , fileName

0
 
LVL 5

Expert Comment

by:raizon
ID: 7004055
listening
0
 
LVL 17

Expert Comment

by:inthedark
ID: 7004071
I created a Word processor by using keydown, keypress and keyup keyboard events and using a picture box.  The program loads and displays a file 5600% faster than MS Word for windows.  It is amazing what you can do with VB.

The first time I wrote the code I made a mistake and used class ojects, one object per word. But this was slow. I converted to use arrays and it became super fast.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7004793
"RichTextBox1.OLEObjects.Add , , fileName"
I thinh not since default behaviour is open the application used to create the image also.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7004796
I don't know if it could be usefull but give it a shoot:
http://www.developersdomain.com/vb/toolbox/codehighlight.htm
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 28

Author Comment

by:vinnyd79
ID: 7005982
Richie - the control seems to just color the words.I didn't see any way to create the seperator line.

I tried the OLEObjects.Add ,but this is not what I want to do.I want the lines to be visible,but I don't want them to be moveable by the cursor.

I read about doing this with an API a while back,but cannot seem to find the info now.
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7456333
You need to insert the rtf values.  The RichTextBox supports the line rtf code according to the following web page:
http://www.chami.com/tips/delphi/013097D.html

However, when I used word to create a RTF document with a line in it, it didn't work.

Here's another web page that seemed to put some of this together:

http://www.codeguru.com/richedit/rtf_string_streamin.shtml

I don't know if this will help, but it was worth a try.


0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7456342
You can send the rtf codes to the Richtextbox by using the SelRTF property.

Here's the RTF for the simple line document I created with word:

{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\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;}}{\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\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}}{\info{\author Tom Walgrave}{\operator Tom Walgrave}
{\creatim\yr2002\mo11\dy15\hr21\min37}{\revtim\yr2002\mo11\dy15\hr21\min38}{\version1}{\edmins1}{\nofpages1}{\nofwords0}{\nofchars0}{\nofcharsws0}{\vern8283}}
\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{\*\template
C:\\Documents and Settings\\twalgrave\\Application Data\\Microsoft\\Templates\\Normal.dot}\sectd \linex0\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 )}}\pard\plain
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\fs20\lang1024\langfe1024\noproof
{\shp{\*\shpinst\shpleft-180\shptop-900\shpright4860\shpbottom-900\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026{\sp{\sn shapeType}{\sv 20}}{\sp{\sn fFlipH}{\sv 0}}{\sp{\sn fFlipV}{\sv 0}}
{\sp{\sn shapePath}{\sv 4}}{\sp{\sn fFillOK}{\sv 0}}{\sp{\sn fFilled}{\sv 0}}{\sp{\sn fArrowheadsOK}{\sv 1}}{\sp{\sn fLayoutInCell}{\sv 1}}}{\shprslt{\*\do\dobxcolumn\dobypara\dodhgt8192\dpline\dpptx0\dppty0\dpptx5040\dppty0
\dpx-180\dpy-900\dpxsize5040\dpysize0\dplinew15\dplinecor0\dplinecog0\dplinecob0}}}}{
0
 
LVL 16

Accepted Solution

by:
twalgrave earned 200 total points
ID: 7456389
OK, bad news.  Although it allows the line to be entered via:
Dim sRTF As String
sRTF = "{\rtf1\ansi\ansicpg1252\uc1 \line}"
RichTextBox1.SelRTF = sRTF
I can't seem to make the line actually appear.

Here's what I get when I insert several lines via this code:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}}
\viewkind4\uc1\pard\f0\fs24
\par
\par
\par
\par
\par
\par
\par
\par
\par
\par }
So you can see the lines are being added (par)

However, there are many more rtf codes supported and I don't understand rtf format very well.  Look in the help file under the title Supported RTF Codes.
0
 
LVL 28

Author Comment

by:vinnyd79
ID: 7626856
That was good info on the RTF codes but I was never able to get the line to appear.I tried playing around with underline and also tried using LineTo API ,but it always appeared behind the RichTextBox.What I would like to do is use VB's code window in my app.I actually have this working,but I would like to find a cleaner way to do it.
What I am doing is launching a blank vb project that contains an empty bas module.I sized the code window to fit a picturebox,then closed vb and made the projects ".vbw" file Read-Only.Im then using FindWindow to get the blank vb proj's handle and using SetParent to put it into a picturebox.Im using MoveWindow to set it so all you see is the code window with the scrollbars.The app uses an access DB,and what I am doing is using sendkeys to copy data from the code Window to the clipboard and vice versa.It appears to work well,but I hate using sendkeys and launching the blank project shows up on the Taskbar.When I close the app,I then have to close the Blank VbProject and say "No" to save changes.If I say Yes,VB Crashes,the PC Crashes as well.
If possible i would like to figure out a way to not use sendkeys,perhaps using the Extensibilty Object Model?
Also,is there a better way to capture the VB window?If I try to capture the code window directly,it works but I have no mouse cursor in the box.If I capture the Code windows parent I get cursor and can highlight,but I cannot get the Window to have the focus for Sendkeys to work.
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7626894
Have you tried something like using the script control?

I don't know how customizable it is for coloring, but I suspect it is a simple edit window and that usually means you can send styles to the text via the APIs.  It also has the added bonus of an immediate window and other features that a language front-end would need.
http://builder.com.com/article.jhtml?id=u00320020520adm01.htm

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7722598
Hi vinnyd79,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

vinnyd79, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now