mimicking a Mac OS X Tiger Feature

  • Thread starter Thread starter VP
  • Start date Start date
V

VP

g'day folks,

I was just browsing through some of the features apple's new tiger
operating system. One of the features I found was the invocation of
the dictionary feature implemented in Tiger. Essentially, one would
place their mouse on top of a word they are interested in and they
simply hold down CTRL-COMMAND-D this fires the dictionary window
displaying the definition of the word in question.

This link gives a good description :
http://a1408.g.akamai.net/7/1408/77...enter20050429/pdf/tiger/Tiger_Definitions.pdf

Being new to windows programming, I was wondering how could I go about
mimicking such a feature in windows. For starters the dictionary
application could listen for certain keypress event with a
keycombination such as CTRL-SHIFT-ATL-D. One thing I can't quite
figure out is that how is it possible to pass the selected text from
any application into the dictionary window.

Any feedback will be appreciated.
thanks
Vee
 
One thing I can't quite
figure out is that how is it possible to pass the selected text from
any application into the dictionary window.

Text rendered in the context of a "control" in a windows application will be in a window itself. If the underlying control is a
Label or Text-based control, the Win32 API should be enough to extract the text from the window using a few Interop calls:

[DllImport("user32.dll")]
private static extern int GetWindowText(IntPtr window, [In][Out] StringBuilder text, int copyCount);

[DllImport("user32.dll")]
private static extern int GetWindowTextLength(IntPtr window);

public void GetWindowText(IntPtr WindowHandle)
{

int length = GetWindowTextLength(WindowHandle);
StringBuilder sb = new StringBuilder(length + 1);
GetWindowText(WindowHandle, sb, sb.Capacity);
return sb.ToString();
}
 
thanks Dave for your post. Another suggestion made to me was to write
my own application as a service application. So thats another thing i
will look into. Couple of ideas I had before I read your reply was to
actually, assign a hotkey to my application then upon selecting the
text in the active application say notepad, the hotkey would copy the
selected text to clipboard then paste it into my dictionary
application. Its a wild idea but I will give it a shot.

One other question I had for you was that, how does one get information
about the opportunities Win32API can offer in windows application
development.. I have only started learning c# since March. I dont know
my current manner of learning is by searching for c# articles
understanding the code and dissecting the relavant bits to be used for
my own purpose.

once again thanks
 
dave, thanks for the links they proved to be very useful.

james,
i could install the product you mentioned but the purpose for me to
venture into such a project is to teach myself writing code on a
windows platform :-)
i do appreciate the link because it makes me realise that my idea is
feasible.

thanks

James said:
Have you considered just installing Answers.com's "1-Click Answers" ?
http://www.answers.com/main/product_info.jsp

--
--
Truth,
James Curran
[erstwhile VC++ MVP]

Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com

VP said:
g'day folks,

I was just browsing through some of the features apple's new tiger
operating system. One of the features I found was the invocation of
the dictionary feature implemented in Tiger. Essentially, one would
place their mouse on top of a word they are interested in and they
simply hold down CTRL-COMMAND-D this fires the dictionary window
displaying the definition of the word in question.

This link gives a good description :
http://a1408.g.akamai.net/7/1408/77...enter20050429/pdf/tiger/Tiger_Definitions.pdf
Being new to windows programming, I was wondering how could I go about
mimicking such a feature in windows. For starters the dictionary
application could listen for certain keypress event with a
keycombination such as CTRL-SHIFT-ATL-D. One thing I can't quite
figure out is that how is it possible to pass the selected text from
any application into the dictionary window.

Any feedback will be appreciated.
thanks
Vee
 
Back
Top