GetPosAtXY Method |
[Top] [Chapter] [Previous] [Next] |
This method searches for the character position at x,y. Declaration bool GetPosAtXY([In] int X, [In] int Y, [In] int Mode, out int CPPos); Description The Result is false if no text was found.
This code inserts the character X at the click position:
private void wpdllInt1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { IWPMemo Memo = wpdllInt1.CurrMemo; int pos; if (Memo.GetPosAtXY(e.X,e.Y,0,out pos)) { int oldpos = Memo.TextCursor.CPPosition; Memo.TextCursor.CPPosition = pos; Memo.TextCursor.InputString("X",0); Memo.TextCursor.CPPosition = oldpos; Memo.ReformatAll(false,true); } }
For .NET Drag and Drop set the property AllowDrop to true.
Then you need two event handlers:
private void wpdllInt1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { wpdllInt1.TextCursor.InputText("Dropped text"); wpdllInt1.Reformat(); }
private void wpdllInt1_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { int pos; if (wpdllInt1.Memo.GetPosAtXY(0,0,-1, out pos)) { wpdllInt1.Memo.TextCursor.CPPosition= pos; e.Effect=DragDropEffects.All; } else e.Effect=DragDropEffects.None; } |