OnMouseDownWord Event

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

Member of WPDLLInt

Declaration C#

OnMouseDownWord(Object Sender, int Editor, int Button, int Shift, int X, int Y, IWPParInterface Paragraph, int PosInPar, int Count)


Declaration OCX

OnMouseDownWord(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long, ByVal Paragraph As WPTDynInt.IWPParInterface, ByVal PosInPar As Long, ByVal Count As Long)



This event is triggered when the user clicks on any of the words in the text. It will be also fired when the context menu key is being pressed.

Usually you will use the event to display a popup menu. Using the parameter Paragraph you can read and change the text at the position the click was performed.


This event is also used by custom spellchecking which can be activated using Command(907).


If you use this event to show a custom popup dialog please use Memo.SetBProp(0, 19, -1) to deactivate the default popup dialog.


Tip: If custom spellchecking was activated using Command(907) and the word was marked to be wrong, bit 10 (value 512) will be set in the bit field "Shift". The current word will be selected in this case. In the event handler you can show a popup menu and either remove the misspell-marker or also replace the text. The misspell-marker will be removed if either Paragraph.ReplaceText or Paragraph.ReplaceCharAttr was used inside the event handler.


Note: The .NET ContextMenu Show() method already returns before the Click events of the items have been triggered, to solve this problem you need to call method Application.DoEvents after Show.


This example shows how to display a popup menu to change the current word:

private bool TextWasOK;

private string NewText;

private void wpdllInt1_OnMouseDownWord(object Sender, int Editor, int Button, int Shift, int X, int Y, WPDynamic.IWPParInterface Paragraph, int PosInPar, int Count)



 // Add first menu - add this word

 MenuItem men = new MenuItem();

 men.Text = "Add: " + Paragraph.GetSubText(PosInPar,Count);

 contextMenu1.MenuItems.Add(0, men);

 men.Click  += new System.EventHandler(this.SpellMen_IgnoreThisWord);

 // Add second menu - replace with this text

 MenuItem men2 = new MenuItem();

 men2.Text = "Replacement text";

 contextMenu1.MenuItems.Add(0, men2);

 men2.Click  += new System.EventHandler(this.SpellMen_ChangeWord);

 // Initialize global variables

 TextWasOK = false;

 NewText = "";

 // Display popup and wait

  contextMenu1.Show(wpdllInt1,new Point(X,Y));

 // Popup was closed

 // Now trigger the Click events


 // and change the text



 // or just force the removal of the misspell-marker

 else if (TextWasOK)




private void SpellMen_IgnoreWord(object sender, System.EventArgs e)


 TextWasOK = true;



private void SpellMen_ChangeWord(object sender, System.EventArgs e)


 TextWasOK = true;

 NewText = ((MenuItem)sender).Text;




[idh_wpdllint_onmousedownword.htm]    Copyright © 2007 by WPCubed GmbH