* MouseDown event of the EditBox LPARAMETERS nButton, nShift, nXCoord, nYCoord if m.nButton<>1 MOUSE CLICK AT (MROW("",3)), (MCOL("",3)) PIXELS LEFT endif
*** ActiveX Control Event *** LPARAMETERS nButton, nShift, nXCoord, nYCoord if m.nButton=2 * below code transforms any mouse clicks to left-button mouse clicks * to automatically position text cursor on place of click for * mouse button, not only for left button as in RTF control. local lcPointStructure local lnFormHandle, lnTopParentHandle, lnHandle local lnPressedKeys local lnButtonDown, lnButtonUp, lnMKButton local lnWM_MOUSEACTIVATE, lnWM_SETCURSOR, lnWM_MOUSEMOVE, ; lnWM_LBUTTONDOWN, lnWM_RBUTTONDOWN, lnWM_MBUTTONDOWN, ; lnWM_LBUTTONUP, lnWM_RBUTTONUP, lnWM_MBUTTONUP, ; lnHTCLIENT, lnMK_LBUTTON, lnMK_RBUTTON, ; lnMK_MBUTTON, lnMK_SHIFT, lnMK_CONTROL *-- Declare Win32 API functions declare integer SendMessage ; in Win32API ; as __SendMessage__ ; integer lnWindowHandle, ; integer lnMessage, ; integer lnWParam, ; integer lnLParam declare integer PostMessage ; in Win32API ; as __PostMessage__ ; integer lnWindowHandle, ; integer lnMessage, ; integer lnWParam, ; integer lnLParam declare integer GetDesktopWindow ; in Win32API ; as __GetDesktopWindow__ lnFormHandle = this.hwnd && window handle for RTF ActiveX control * Get a handle to the desktop window lnTopParentHandle = __GetDesktopWindow__() * Declare constants used by mouse messages lnWM_MOUSEACTIVATE = 0x0021 lnWM_SETCURSOR = 0x0020 lnWM_MOUSEMOVE = 0x0200 lnWM_LBUTTONDOWN = 0x0201 lnWM_RBUTTONDOWN = 0x0204 lnWM_MBUTTONDOWN = 0x0207 lnWM_LBUTTONUP = 0x0202 lnWM_RBUTTONUP = 0x0205 lnWM_MBUTTONUP = 0x0208 lnHTCLIENT = 0x0001 lnMK_LBUTTON = 0x0001 lnMK_RBUTTON = 0x0002 lnMK_MBUTTON = 0x0010 lnMK_SHIFT = 0x0004 lnMK_CONTROL = 0x0008 lnPressedKeys = 0 if BitAnd(m.nShift, 1) = 1 * The Shift key was pressed when * mouse was clicked lnPressedKeys = BitOr(m.lnPressedKeys, m.lnMK_SHIFT) endif if BitAnd(m.nShift, 2) = 2 *-- The Ctrl key was pressed when * mouse was clicked lnPressedKeys = BitOr(m.lnPressedKeys, m.lnMK_CONTROL) endif lnButtonDown = m.lnWM_LBUTTONDOWN do case case m.nButton = 1 *-- Left button lnButtonUp = m.lnWM_LBUTTONUP lnMKButton = m.lnMK_LBUTTON case m.nButton = 2 *-- Right button lnButtonUp = m.lnWM_RBUTTONUP lnMKButton = m.lnMK_RBUTTON case nButton = 4 *-- Middle button lnButtonUp = m.lnWM_MBUTTONUP lnMKButton = m.lnMK_MBUTTON endcase * Simulate a mouse up message(s) lnLParam = m.nYCoord* 256 * 256 + m.nXCoord = __SendMessage__( ; m.lnFormHandle, ; m.lnButtonUp, ; m.lnMKButton + m.lnPressedKeys, ; m.lnLParam) lnLParam = m.lnWM_MOUSEMOVE * 256 * 256 + m.lnHTCLIENT = __SendMessage__( ; m.lnFormHandle, ; m.lnWM_SETCURSOR, ; m.lnFormHandle, ; m.lnLParam) lnLParam = m.nYCoord* 256 * 256 + m.nXCoord = __PostMessage__( ; m.lnFormHandle, ; m.lnWM_MOUSEMOVE, ; m.lnPressedKeys, ; m.lnLParam) * Simulate a mouse down message(s) - always for left button click lnMKButton = lnMK_LBUTTON lnLParam = m.lnButtonDown * 256 * 256 + m.lnHTCLIENT = __PostMessage__( ; m.lnFormHandle, ; m.lnWM_MOUSEACTIVATE, ; m.lnTopParentHandle, ; m.lnLParam) = __PostMessage__( ; m.lnFormHandle, ; m.lnWM_SETCURSOR, ; m.lnFormHandle, ; m.lnLParam) lnLParam = m.nYCoord* 256 * 256 + m.nXCoord = __PostMessage__( ; m.lnFormHandle, ; m.lnButtonDown, ; m.lnMKButton, ; m.lnLParam) DOEVENTS && will not slow down VFP6 here because mouse events are in buffer * Put a code for right click event HERE, because there are no * separate RightClick event in RTF control. * Insert some text to demo the behaviour this.SelText = "My Name is ..." endif