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);

           }

   }

 

Parameters

X

The horizontal position

Y

The vertical position

Mode

Selects the way the X and Y parameter is expected:

-1: Dont use X and Y parameter. Use current mouse position instead.

0 : X and Y are client coordinates of the editor. If you use the method in OnMouseDown or OnMouseMove use this mode.

1 : X and Y are coordinates relative to upper left corner of edit control (including the toolbars)

2 : X and Y are screen coordinates (relative to desktop)

out CPPos

The absolute character position.


[idh_iwpmemo_getposatxy.htm]    Copyright © 2007 by WPCubed GmbH