G
Guest
Hi
I have searched extensively for help on inserting text at the position of
the mouse pointer in a text box as the final step of drag and drop process
What I have come with is listed below - the problem is that the SendMessage
function doesn't seem to perform the expected operation of moving the caret
to position in the textbox where the mouse is pointing to. (can be text or
richtext box either is good - sample code is based of attemp with richtext)
I would be greatfull if someone could perhaps assist me by pointing out my
error
Thanks
my attempt:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);
//DragOver event of the RichTextBox
private void txtMDXExpression_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{
const int EM_SETSEL = 0x0400 + 177;
txtMDXExpression.Focus();
txtMDXExpression.SelectionLength = 0;
//make a point object from argument parameters
Point mouseP = new Point(e.X,e.Y);
//get position of mouse within textbox
Point scrPt = txtMDXExpression.PointToClient(mouseP);
SendMessage(txtMDXExpression.Handle, EM_SETSEL, scrPt.X, scrPt.X )
}
I have searched extensively for help on inserting text at the position of
the mouse pointer in a text box as the final step of drag and drop process
What I have come with is listed below - the problem is that the SendMessage
function doesn't seem to perform the expected operation of moving the caret
to position in the textbox where the mouse is pointing to. (can be text or
richtext box either is good - sample code is based of attemp with richtext)
I would be greatfull if someone could perhaps assist me by pointing out my
error
Thanks
my attempt:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);
//DragOver event of the RichTextBox
private void txtMDXExpression_DragOver(object sender,
System.Windows.Forms.DragEventArgs e)
{
const int EM_SETSEL = 0x0400 + 177;
txtMDXExpression.Focus();
txtMDXExpression.SelectionLength = 0;
//make a point object from argument parameters
Point mouseP = new Point(e.X,e.Y);
//get position of mouse within textbox
Point scrPt = txtMDXExpression.PointToClient(mouseP);
SendMessage(txtMDXExpression.Handle, EM_SETSEL, scrPt.X, scrPt.X )
}