Rich Text Control Causes Insanity

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MisterJ

    Rich Text Control Causes Insanity

    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.

    What happens is that the text box has a mind of its own and goes
    elsewhere.

    Yes, I am aware of the operation of the DragMode property. The problem
    seems to be centered around the fact that the text control does not
    respond to the mousedown event when DragMode is VbAutomatic. (thus
    preventing the discovery of the original x and y coordinates when the
    mouse is pressed)

    Please, if you know how to reposition a rich text control on a frame
    during runtime, let me know. My mental health is at stake here !

    Regards and Many Thanks,
    Jerry

    Remove the obvious no spam info in my email address before emailing
    me.


  • Rick Rothstein

    #2
    Re: Rich Text Control Causes Insanity

    [color=blue]
    > 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.[/color]

    Give this code a try. I handle the moving in the MouseDown event and,
    since the mouse editing functionality all start with a left-mouse click,
    I chose to initiate the moving with the Shift key down (you can change
    that if you wish).

    Rick - MVP

    Option Explicit

    Private Declare Function ReleaseCapture _
    Lib "user32" () As Long

    Private Declare Function SendMessage _
    Lib "user32" _
    Alias "SendMessag eA" _
    (ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Any) As Integer

    Const WM_NCLBUTTONDOW N = &HA1
    Const HTCAPTION = 2

    Public Sub MoveObject(hwnd As Long)
    ReleaseCapture
    SendMessage hwnd, WM_NCLBUTTONDOW N, HTCAPTION, 0&
    End Sub

    Private Sub RichTextBox1_Mo useDown(Button As Integer, Shift As Integer,
    x As Single, y As Single)
    If Shift = vbShiftMask Then
    MoveObject RichTextBox1.hw nd
    End If
    End Sub

    Comment

    Working...