By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

RichTextBox

P: n/a
How can I tell if the Insert Mode is on or off?

--
Dennis in Houston
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Insert Mode ????
i am not sure if i exactly understand what you mean with this ..

however if you mean with this the possibility to enter or copy paste data in
the richtextbox control then it is reading out the ReadOnly property
regards

Michel in Rotterdam ;-)

Michel Posseth ,


"Dennis" <De****@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
How can I tell if the Insert Mode is on or off?

--
Dennis in Houston

Nov 21 '05 #2

P: n/a
> How can I tell if the Insert Mode is on or off?

No way that I am aware of. I wish you could, and I wish MS would change the
insertion caret so users would know as well. Ditto for ordinary textboxes.
This is an easy thing for MS to do, and many years have gone by with this
suggestion offered by many people.
Nov 21 '05 #3

P: n/a
Thanks. I guess one has to track the Insert key and toggle a static or
global variable to track the Insert Key presses. MIcrosoft never was one to
add the finer points to their elementary controls...controls are not one of
their strong points.
--
Dennis in Houston
"AMercer" wrote:
How can I tell if the Insert Mode is on or off?


No way that I am aware of. I wish you could, and I wish MS would change the
insertion caret so users would know as well. Ditto for ordinary textboxes.
This is an easy thing for MS to do, and many years have gone by with this
suggestion offered by many people.

Nov 21 '05 #4

P: n/a
still don`t understand exactly what you mean :-)
but detecting if the insert key is pressed
can be done with the imessagefilter

i would still like to know what you mean with " Insert Mode is on or off? "
( i might be learning something :-)

regrds

Michel Posseth

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thanks. I guess one has to track the Insert key and toggle a static or
global variable to track the Insert Key presses. MIcrosoft never was one
to
add the finer points to their elementary controls...controls are not one
of
their strong points.
--
Dennis in Houston
"AMercer" wrote:
> How can I tell if the Insert Mode is on or off?


No way that I am aware of. I wish you could, and I wish MS would change
the
insertion caret so users would know as well. Ditto for ordinary
textboxes.
This is an easy thing for MS to do, and many years have gone by with this
suggestion offered by many people.

Nov 21 '05 #5

P: n/a
aha :-)
Most text editors and word processors have two text entry modes from which
you can choose. In insert mode, the editor inserts all characters you type
at the cursor position (or to the right of the insertion point). With each
new insertion, the editor pushes over characters to the right of the cursor
or pointer to make room for the new character.
If insert mode is turned off, the editor overwrites existing characters
instead of inserting the new ones before the old ones. This is often called
overstrike (or overwrite) mode. Most PC keyboards have an Ins key that lets
you switch back and forth between insert and overwrite modes.

For most programs, the default text entry mode is insert mode.


stupid me ,, ofcourse ;-)


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
still don`t understand exactly what you mean :-)
but detecting if the insert key is pressed
can be done with the imessagefilter

i would still like to know what you mean with " Insert Mode is on or off?
" ( i might be learning something :-)

regrds

Michel Posseth

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thanks. I guess one has to track the Insert key and toggle a static or
global variable to track the Insert Key presses. MIcrosoft never was one
to
add the finer points to their elementary controls...controls are not one
of
their strong points.
--
Dennis in Houston
"AMercer" wrote:
> How can I tell if the Insert Mode is on or off?

No way that I am aware of. I wish you could, and I wish MS would change
the
insertion caret so users would know as well. Ditto for ordinary
textboxes.
This is an easy thing for MS to do, and many years have gone by with
this
suggestion offered by many people.


Nov 21 '05 #6

P: n/a

well it seems pretty easy ,,,,

if the richtextbox is created the mode is alway insert , if the focus is on
the richtextbox ( carret is there blinking ) and the insert button is
pressed the mode changes to overwrite so trap the messages and you know what
the status is
did some testing ,, and this seems to work fine ( throw a richtextbox on a
form and copy paste below code )

Implements IMessageFilter

Private rtGotfocus As Boolean = True, rtInsert As Boolean = True, rtInsDwn
As Boolean = True

Public Event rtInsertStateChanged(ByVal insert As Boolean)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Application.AddMessageFilter(Me)

AddHandler rtInsertStateChanged, AddressOf rtStateChange

rtStateChange(True)

End Sub

Sub rtStateChange(ByVal insert As Boolean)

Label1.Text = " Status : " & CStr(IIf(insert, " Insert ", " Overwrite "))

End Sub

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _

As Boolean Implements IMessageFilter.PreFilterMessage

Dim keyCode As Keys = CType(m.WParam.ToInt32(), Keys) And Keys.KeyCode

If rtGotfocus AndAlso (keyCode = Keys.Insert) Then

If rtInsDwn Then

rtInsert = Not rtInsert

RaiseEvent rtInsertStateChanged(rtInsert)

End If

rtInsDwn = Not rtInsDwn

End If

End Function

Private Sub RichTextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.GotFocus

rtGotfocus = True

End Sub

Private Sub RichTextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.LostFocus

rtGotfocus = False

End Sub

End Class


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
aha :-)
Most text editors and word processors have two text entry modes from which
you can choose. In insert mode, the editor inserts all characters you type
at the cursor position (or to the right of the insertion point). With each
new insertion, the editor pushes over characters to the right of the
cursor or pointer to make room for the new character.
If insert mode is turned off, the editor overwrites existing characters
instead of inserting the new ones before the old ones. This is often
called overstrike (or overwrite) mode. Most PC keyboards have an Ins key
that lets you switch back and forth between insert and overwrite modes.

For most programs, the default text entry mode is insert mode.


stupid me ,, ofcourse ;-)


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
still don`t understand exactly what you mean :-)
but detecting if the insert key is pressed
can be done with the imessagefilter

i would still like to know what you mean with " Insert Mode is on or
off? " ( i might be learning something :-)

regrds

Michel Posseth

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thanks. I guess one has to track the Insert key and toggle a static or
global variable to track the Insert Key presses. MIcrosoft never was
one to
add the finer points to their elementary controls...controls are not one
of
their strong points.
--
Dennis in Houston
"AMercer" wrote:

> How can I tell if the Insert Mode is on or off?

No way that I am aware of. I wish you could, and I wish MS would
change the
insertion caret so users would know as well. Ditto for ordinary
textboxes.
This is an easy thing for MS to do, and many years have gone by with
this
suggestion offered by many people.



Nov 21 '05 #7

P: n/a
Thanks for the code...it's what I needed. However, it would be a lot easier
if M'soft had included a Property in the edit controls that returned the
"Overstrike" mode as True or False and maybe even an "OverstrikeModeChanged"
event. It's a feature that several people have ask for and would seem to be
very trivial for Microsoft to implement in their controls that have edit
features.
--
Dennis in Houston
"m.posseth" wrote:

well it seems pretty easy ,,,,

if the richtextbox is created the mode is alway insert , if the focus is on
the richtextbox ( carret is there blinking ) and the insert button is
pressed the mode changes to overwrite so trap the messages and you know what
the status is
did some testing ,, and this seems to work fine ( throw a richtextbox on a
form and copy paste below code )

Implements IMessageFilter

Private rtGotfocus As Boolean = True, rtInsert As Boolean = True, rtInsDwn
As Boolean = True

Public Event rtInsertStateChanged(ByVal insert As Boolean)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Application.AddMessageFilter(Me)

AddHandler rtInsertStateChanged, AddressOf rtStateChange

rtStateChange(True)

End Sub

Sub rtStateChange(ByVal insert As Boolean)

Label1.Text = " Status : " & CStr(IIf(insert, " Insert ", " Overwrite "))

End Sub

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message) _

As Boolean Implements IMessageFilter.PreFilterMessage

Dim keyCode As Keys = CType(m.WParam.ToInt32(), Keys) And Keys.KeyCode

If rtGotfocus AndAlso (keyCode = Keys.Insert) Then

If rtInsDwn Then

rtInsert = Not rtInsert

RaiseEvent rtInsertStateChanged(rtInsert)

End If

rtInsDwn = Not rtInsDwn

End If

End Function

Private Sub RichTextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.GotFocus

rtGotfocus = True

End Sub

Private Sub RichTextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.LostFocus

rtGotfocus = False

End Sub

End Class


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
aha :-)
Most text editors and word processors have two text entry modes from which
you can choose. In insert mode, the editor inserts all characters you type
at the cursor position (or to the right of the insertion point). With each
new insertion, the editor pushes over characters to the right of the
cursor or pointer to make room for the new character.
If insert mode is turned off, the editor overwrites existing characters
instead of inserting the new ones before the old ones. This is often
called overstrike (or overwrite) mode. Most PC keyboards have an Ins key
that lets you switch back and forth between insert and overwrite modes.

For most programs, the default text entry mode is insert mode.


stupid me ,, ofcourse ;-)


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:ef*************@TK2MSFTNGP14.phx.gbl...
still don`t understand exactly what you mean :-)
but detecting if the insert key is pressed
can be done with the imessagefilter

i would still like to know what you mean with " Insert Mode is on or
off? " ( i might be learning something :-)

regrds

Michel Posseth

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:A2**********************************@microsof t.com...
Thanks. I guess one has to track the Insert key and toggle a static or
global variable to track the Insert Key presses. MIcrosoft never was
one to
add the finer points to their elementary controls...controls are not one
of
their strong points.
--
Dennis in Houston
"AMercer" wrote:

> > How can I tell if the Insert Mode is on or off?
>
> No way that I am aware of. I wish you could, and I wish MS would
> change the
> insertion caret so users would know as well. Ditto for ordinary
> textboxes.
> This is an easy thing for MS to do, and many years have gone by with
> this
> suggestion offered by many people.



Nov 21 '05 #8

P: n/a
Indeed it would be a lot easier,,,,

for me it is always a sport to solve problems like this , in some sort of
way i even enjoy it ;-)

By the way with the imessagefilter i could solve lots of problems were in
the past ( VB6 ) i needed to do some fancy API calling or subclassing
i used it the first time for trapping webbrowser events
http://www.freevbcode.com/ShowCode.Asp?ID=5635

Investigate it some more and you will see that you will use this code more
frequent to solve those few things that MS "forgot"

Regards

Michel Posseth

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Thanks for the code...it's what I needed. However, it would be a lot
easier
if M'soft had included a Property in the edit controls that returned the
"Overstrike" mode as True or False and maybe even an
"OverstrikeModeChanged"
event. It's a feature that several people have ask for and would seem to
be
very trivial for Microsoft to implement in their controls that have edit
features.
--
Dennis in Houston
"m.posseth" wrote:

well it seems pretty easy ,,,,

if the richtextbox is created the mode is alway insert , if the focus is
on
the richtextbox ( carret is there blinking ) and the insert button is
pressed the mode changes to overwrite so trap the messages and you know
what
the status is
did some testing ,, and this seems to work fine ( throw a richtextbox on
a
form and copy paste below code )

Implements IMessageFilter

Private rtGotfocus As Boolean = True, rtInsert As Boolean = True,
rtInsDwn
As Boolean = True

Public Event rtInsertStateChanged(ByVal insert As Boolean)

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Application.AddMessageFilter(Me)

AddHandler rtInsertStateChanged, AddressOf rtStateChange

rtStateChange(True)

End Sub

Sub rtStateChange(ByVal insert As Boolean)

Label1.Text = " Status : " & CStr(IIf(insert, " Insert ", " Overwrite "))

End Sub

Public Function PreFilterMessage(ByRef m As System.Windows.Forms.Message)
_

As Boolean Implements IMessageFilter.PreFilterMessage

Dim keyCode As Keys = CType(m.WParam.ToInt32(), Keys) And Keys.KeyCode

If rtGotfocus AndAlso (keyCode = Keys.Insert) Then

If rtInsDwn Then

rtInsert = Not rtInsert

RaiseEvent rtInsertStateChanged(rtInsert)

End If

rtInsDwn = Not rtInsDwn

End If

End Function

Private Sub RichTextBox1_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.GotFocus

rtGotfocus = True

End Sub

Private Sub RichTextBox1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles RichTextBox1.LostFocus

rtGotfocus = False

End Sub

End Class


"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> aha :-)
>
>
> Most text editors and word processors have two text entry modes from
> which
> you can choose. In insert mode, the editor inserts all characters you
> type
> at the cursor position (or to the right of the insertion point). With
> each
> new insertion, the editor pushes over characters to the right of the
> cursor or pointer to make room for the new character.
> If insert mode is turned off, the editor overwrites existing characters
> instead of inserting the new ones before the old ones. This is often
> called overstrike (or overwrite) mode. Most PC keyboards have an Ins
> key
> that lets you switch back and forth between insert and overwrite modes.
>
> For most programs, the default text entry mode is insert mode.
>
>
>
>
> stupid me ,, ofcourse ;-)
>
>
>
>
> "m.posseth" <mi*****@nohausystems.nl> wrote in message
> news:ef*************@TK2MSFTNGP14.phx.gbl...
>> still don`t understand exactly what you mean :-)
>>
>>
>> but detecting if the insert key is pressed
>> can be done with the imessagefilter
>>
>> i would still like to know what you mean with " Insert Mode is on or
>> off? " ( i might be learning something :-)
>>
>> regrds
>>
>> Michel Posseth
>>
>>
>>
>> "Dennis" <De****@discussions.microsoft.com> wrote in message
>> news:A2**********************************@microsof t.com...
>>> Thanks. I guess one has to track the Insert key and toggle a static
>>> or
>>> global variable to track the Insert Key presses. MIcrosoft never was
>>> one to
>>> add the finer points to their elementary controls...controls are not
>>> one
>>> of
>>> their strong points.
>>> --
>>> Dennis in Houston
>>>
>>>
>>> "AMercer" wrote:
>>>
>>>> > How can I tell if the Insert Mode is on or off?
>>>>
>>>> No way that I am aware of. I wish you could, and I wish MS would
>>>> change the
>>>> insertion caret so users would know as well. Ditto for ordinary
>>>> textboxes.
>>>> This is an easy thing for MS to do, and many years have gone by with
>>>> this
>>>> suggestion offered by many people.
>>
>>
>
>


Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.