1

Before I've performed adding this question I've searched in this site for my question - According to website's posting rules - and I found these links and it didn't help me:

  1. Get word under mouse pointer
  2. get the text under the mouse pointer
  3. Getting the text under the mouse pointer

My questions is: I'm programming a Geology dictionary and it is available for users now, but I want to add a feature that make users see the translation of a specific word when they move their mouse on it for a specific period and the word may be in any app like MS Word,IE,Firefox or any other app (I quoted this idea from the Easy Lingo dictionary if you know it), then the application will perform a query in the database and return the result to the user in a tooltip or something like that at the position of the mouse. So, how can I get the word under the mouse pointer, is that an API or what?
Would you help me please?

Community
  • 1
  • 1
Ahmed Suror
  • 439
  • 6
  • 17
  • You really should make question more concrete... But short - since it is your app find control under mouse position, than find text *you* put there (by mouse position). – Alexei Levenkov Mar 06 '13 at 00:43
  • Have you looked into this? http://stackoverflow.com/questions/6384562/how-to-get-text-under-mouse-in-any-open-window/ – djv Mar 06 '13 at 03:03
  • Yer sir, I've looked into http://stackoverflow.com/questions/6384562/how-to-get-text-under-mouse-in-any-open-window/ but it didn't help. – Ahmed Suror Mar 06 '13 at 11:59

1 Answers1

-1

Almost every visual control (like textboxes or labels) has the MouseHover-event.

private void label1_MouseHover(object sender, EventArgs e)
{
  // get text by mouse-over
  string textOfTheLabel = ((Label) sender).Text;
  string translatedText = GetTranslationFromDB(textOfTheLabel);

  // tooltip
  System.Windows.Forms.ToolTip toolTip1 = new System.Windows.Forms.ToolTip();
  toolTip1.SetToolTip((Label) sender, translatedText);
}
Michael
  • 621
  • 5
  • 17
  • This would work for a label with a single word, within your own .NET application - but Ahmed is asking for it to work "in any app like MS Word,IE,Firefox or any other app". Imagine you hovered over the words Dendritic Drainage, typed here on SO, by me, and a tooltip popped up with the definition. – djv Mar 06 '13 at 03:00
  • Thank you Mr. Michael but this will work only through my application, I want to make it public (from any app). – Ahmed Suror Mar 06 '13 at 11:57