473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Text control: desired behavior--HELP

I am looking for a text control (or API) that can emulate the behavior
of CodeWrite where you can move the cursor in any direction on a blank
text area and begin typing (so you are not confined to the left
margin). Visual Basic used to be like this in Versions prior to 5.

I can't for the life of me figure out what to call this "feature" so
it has been hard to search for.

Any help would be appreciated
Jul 17 '05 #1
3 2460
> I am looking for a text control (or API) that can emulate the behavior
of CodeWrite where you can move the cursor in any direction on a blank
text area and begin typing (so you are not confined to the left
margin). Visual Basic used to be like this in Versions prior to 5.

I can't for the life of me figure out what to call this "feature" so
it has been hard to search for.

Any help would be appreciated


I think the feature name you are thinking of is something like "free-form
text entry".

I've never seen CodeWrite, so I don't know how it operates; however, I've
taken a guess. First and foremost, for this to make any sense in operation,
you will have to use a fixed-width font so up/down arrows take you to a
predictable location. I'd suggest you use something like Courier or Courier
New (which looks smoother to me). Since you can put the cursor anywhere
within the TextBox, I figured it should operate in TypeOver (as opposed to
Insert) Mode, hitting return would just take you to the beginning of the
next line (lines wouldn't be split), selections are replaced in place with
the characters after it remaining in place, and so on.

Here is some **rough** code that will give you an idea to get you started
(you'll want to play with it, I'm sure). Place a TextBox on the form and set
the Font to "Courier New" and pick a FontSize you like (do these at
design-time only). Then paste this code into the form's code window. That
should be all you need to do; just run the program and try it out.

Rick - MVP

Dim CharsWide As Long
Dim LinesHigh As Long

Private Sub Form_Load()
Dim CharWidth As Long
Dim CharHeight As Long
With Text1
Set Me.Font = .Font
CharWidth = Me.TextWidth("X")
CharHeight = Me.TextHeight("X")
CharsWide = .Width \ CharWidth
LinesHigh = .Height \ CharHeight
For x = 1 To LinesHigh
.SelText = String$(CharsWide, " ")
Next
.MaxLength = CharsWide * LinesHigh
End With
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim TextFromClipBoard As String
Dim CurrentSelStart As Long
With Text1
If KeyCode = vbKeyDelete Then
If .SelLength = 0 Then .SelLength = 1
CurrentSelStart = .SelStart
.SelText = String(.SelLength, " ")
.SelStart = CurrentSelStart
KeyCode = 0
ElseIf KeyCode = vbKeyBack Then
.SelLength = 0
ElseIf (Shift = vbShiftMask And KeyCode = vbKeyInsert) Or _
(Shift = vbCtrlMask And KeyCode = vbKeyV) Then
CurrentSelStart = .SelStart
TextFromClipBoard = Clipboard.GetText
.SelText = String(.SelLength, " ")
.SelStart = CurrentSelStart
.SelLength = Len(TextFromClipBoard)
.SelText = TextFromClipBoard
KeyCode = 0
End If
End With
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
With Text1
If KeyAscii = 13 Then
If .SelStart \ CharsWide < LinesHigh - 1 Then
SendKeys "{DOWN}{HOME}"
End If
KeyAscii = 0
ElseIf KeyAscii = 8 Then
If .SelStart Then
.SelStart = .SelStart - 1
.SelLength = 1
.SelText = " "
.SelStart = .SelStart - 1
End If
KeyAscii = 0
ElseIf KeyAscii > 31 Then
.SelLength = 1
End If
End With
End Sub
Jul 17 '05 #2
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message news:<07********************@comcast.com>...
Then paste this code into the form's code window. That
should be all you need to do; just run the program and try it out.

Thanks, looks like I was already ALMOST there. What I was doing was
about 90% of what your code does. I'll try it. Thanks!!!!
Jul 17 '05 #3
> > Then paste this code into the form's code window. That
should be all you need to do; just run the program and try it out.


Thanks, looks like I was already ALMOST there. What I was doing was
about 90% of what your code does. I'll try it. Thanks!!!!


I'm not offering my code up as an ideal approach to your problem, just as a
possible starting point. I really don't have a feel for an interface of this
type. For example, while I wanted the BackSpace key to work like most people
expect, I didn't have any idea how to approach it here (so I just made it
erase the previous character). The problem in doing it the "right" way is
what to you do with the remainder of the text on subsequent lines? On the
same line, we could just slide the rest of the line over one character; but
what about the next line down? Does its first character wrap to the last
character position of the current line? Or to the end of the text on the
current line? It probably depends on how it came into being... by word
wrapping or by hitting a carriage return, there is no way of knowing. I
guess we could track the carriage returns, but what if more text was added
on the line after the carriage return (something that can't be done in a
normal text editor without adding spaces in front of the carriage return
plus the new text). And handling the BackSpace key is just one of the
questions I had. Anyway, good luck with the program.

Rick - MVP
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: magician | last post by:
Hi Im having trouble setting the bold and 'not' bold properties in a rich text control. All the text in the control is entered through code and the bold property is different for different...
1
by: MisterJ | last post by:
Here is the situation: I am attempting to reposition a rich text control within a frame in a running vb6 program. What I want to do is to click on the text box then drag it to a new position....
8
by: none | last post by:
Hi, I wrote a program for work that processed and formatted some collected text data in a Tkinter based GUI display. I've found that as my data files get longer (a few thousand lines), there...
0
by: NancyASAP | last post by:
In case anyone hasn't seen this problem, just sharing the info.... I created a dotnet 1.1 page with a literal control. I used a streamreader to open a text file to fill the control. I filled the...
2
by: Gwin | last post by:
I am programming a client service dbase in access 2000 for a non-profit health clinic. I want to create a navigation menu that can show varying numbers of command buttons with varying captions,...
4
by: David Davis | last post by:
Woll2Woll has a product for Delphi called Infopower which has a rtf control with a built-in word processor. Does anyone know of a third party control that has the same capabilities. I don't have...
2
by: tlyczko | last post by:
Hello, I'm experimenting with Stephen Lebans' Rich Text Control for doing RTF data entry into a memo field. I imported the table, form, toobar, and modules from the A2k version into an A2k3...
1
by: (PeteCresswell) | last post by:
Got a text control that where .Locked = True. I have the text blue and underlined to simulate a clickable link on a web page. If the user clicks on that field, I open up a window that shows the...
1
by: ozzy66 | last post by:
Hiho NG, I've created a tool (tray application) like "keytext" or "shortcut" that is a little tool where you can store text components which you can call from any running app. Such a stored text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.