Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB6 - RichTextBox - How To Prevent Resize Of Image

56 views
Skip to first unread message

Daniel Friend

unread,
Mar 17, 2004, 5:42:32 AM3/17/04
to
I have a richtextbox control on a form. The rtf has images. If a user
clicks on the image, it can be resized. How can I prevent that?

RichTextBox1.Locked=True

does not work

Thanks,

Dan


Mark Alexander Bertenshaw

unread,
Mar 17, 2004, 8:57:24 AM3/17/04
to

"Daniel Friend" <d...@donotspam.com> wrote in message
news:egdQOyAD...@TK2MSFTNGP11.phx.gbl...

Daniel -

I have racked my brains about this one. Unfortunately, there is no simple
solution. You would have to use subclassing to intercept the WM_MOUSEMOVE
message: I would guess it is the one which starts the dragging process of
resize. You can't use timers and GetCapture() since timers are blocked by
dragging actions.

Another approach would be to trap the Change event, check whether the text
has changed, and make the assumption that if the text hasn't changed, then a
picture has been moved or resized.

--
Mark Alexander Bertenshaw
LEAX Controls
Battersea
UK


Mark Alexander Bertenshaw

unread,
Mar 17, 2004, 9:02:27 AM3/17/04
to

"Daniel Friend" <d...@donotspam.com> wrote in message
news:egdQOyAD...@TK2MSFTNGP11.phx.gbl...

Sorry - I forgot to add that you would then Undo the changes with:

----------------

Private Declare Function SendMessage Lib "User32.dll" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long

Private Const EM_UNDO As Long = &HC7

Private m_sOldText As String

Private Sub rtb_Change()
If m_sOldText = rtb.Text Then
SendMessage rtb.hWnd, EM_UNDO, ByVal 0&, ByVal 0&
Else
m_sOldText = rtb.Text
End If
End Sub

----------------

Obviously, you need to set m_sOldText when you load the document.

Rick Rothstein

unread,
Mar 17, 2004, 10:26:13 AM3/17/04
to

It looks like if you know where the picture was placed at, then you can
block its being resized. For example, let's say you stored the SelStart
location of a picture you place in the RichTextBox control in a variable
named PicturePosition, or you store the current SelStart location in
PicturePosition after checking that the ClipBoard.GetFormat method was
returning something other than vbCFText when the user pasted in anything
from the ClipBoard (remember that Shift+Insert and Ctrl+V perform a Paste
operation), then placing this code

With RichTextBox1
If .SelStart >= PicturePosition And .SelLength >= 1 Then
.SelLength = 0
End If
End With

in BOTH the KeyUp and MouseUp events seems to take away the ability to
resize the picture placed there .

Rick - MVP


0 new messages