OnMouseUp Event

[Top]  [Chapter]  [Previous]  [Next]

Member of WPDLLInt

Declaration C#

MouseUp(MouseEventArgs e)


The .NET assembly uses the standard event type MouseUp.

The passed MouseEventArgs can be casted to the wpMouseEventArgs type to read the property "Editor".



Declaration OCX

OnMouseUp(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)


This event occurs when the user releases the mouse button. The parameter Shift can be used to check the state of the control keys. The parameter Button will be 0 for left button, 1 for right and 2 for the middle button.



The editor number, 1 or 2


0 = left button, 1 = right, 2 = middle mouse button


A bit field representing the state of the control keys:

1 : Shift key

2 : ALT key

4 : Ctrl key


X position relatively to the editors upper left corner.


Y position relatively to the editors upper left corner.


VB6 Example:


VB6: This code checks for a click into a merge field and then updates its contents:


Private Sub WPDLLInt1_OnMouseUp(ByVal Editor As LongByVal Button As LongByVal Shift As LongByVal X As LongByVal Y As Long)

    Dim Memo As IWPMemo

    Dim Obj As IWPTextObj

    Set Memo = WPDLLInt1.Memo

    Set Obj = Memo.GetObjAtXY(X, Y, 0, -1)

    If Not Obj Is Nothing Then

       Obj.EmbeddedText = "new text"

       Memo.ReformatAll FalseTrue

    End If

End Sub


C#: This event handler also checks for e merge field and opens a dialog to edit the embedded text.


private void wpdllInt1_MouseUp(object sender, MouseEventArgs e)


          wpMouseEventArgs me = (wpMouseEventArgs)e;

          IWPMemo Memo;

          if (me.Editor == 2)

               Memo = wpdllInt1.Memo2;

          else Memo = wpdllInt1.Memo;

          IWPTextCursor Cursor = Memo.TextCursor;


         //This is a simple form with a lable and a textbox + a OK and cancel Button

          Form2 f = new Form2();



              // Set Dialog Position

              int x = 0, y = 0;

               Memo.GetXY(8, ref x, ref y);

               f.StartPosition = FormStartPosition.Manual;

               f.Left = me.X + x;

               f.Top = me.Y + y;

              // Which Button was pressed?

              if (me.Button == MouseButtons.Left)

                   f.Text = "Left";

              else if (me.Button == MouseButtons.Middle)

                   f.Text = "Middle";

              if (me.Button == MouseButtons.Right)

                   f.Text = "Right";

              // Possibility: get Position

              // int cppos=0;

              // Memo.GetPosAtXY(2, me.X + x, me.Y + y, out cppos);


              // Find Field at current mouse position and open a form to edit the field contents

              IWPTextObj obj = Memo.GetObjAtXY(0,0, 1, -1);


              if (obj != null)


                   f.label1.Text = obj.Name;

                   f.textBox1.Text = obj.EmbeddedText;


                  if (f.ShowDialog(this) == DialogResult.OK)


                       obj.EmbeddedText = f.textBox1.Text;

                       Memo.ReformatAll(false, true);









[idh_wpdllint_onmouseup.htm]    Copyright © 2007 by WPCubed GmbH