Reputation: 4719
I have .NET WPF application and one of requirement is that user may select and copy text outside of my application. My application has to respond to clipboard event. Look up word from dictionary and next to selected text show tooltip with word's translation.
As I understand this has to be accomplished using calls to Windows API.
I have found example code, that accomplishes this task.
One of my first ideas, was to convert this example into library that I can call from .NET application (basically my library would contain 2 methods: show and hide tooltip). Unfortunately my VC++ knowledge is next to nothing.
Is there any other way to solve this problem?
Thank You very much.
Upvotes: 1
Views: 989
Reputation: 29594
There is nothing magical about tooltips - they are just windows with a thin border, no title, yellowish background and always on top style.
You can easily duplicate those in WPF:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Background="Yellow"
WindowStyle="None"
Topmost="True">
<Border BorderBrush="Black" BorderThickness="1">
<TextBlock Text="Tooltip text"/>
</Border>
</Window>
And now you can use all of Window's methods and properties to move, resize, show and hide your "tooltip", as a bonus you can also insert more advanced context into the tooltip (images, buttons, hyperlinks, your logo) or make it look more intresting.
Upvotes: 2