Programming note: tooltips again

This posting is of historical interest. It exists to help other programmers who may come across a similar problem.

When you move your mouse over a toolbar button, a small tooltip pops up to tell you what the button does. If the button is disabled then Cardbox also shows a yellow box next to the button, telling you why it’s disabled, in the same way that it does with disabled menu items.

On Windows, the tooltip and the yellow box are adjacent, so that you can read them both. On Wine, the tooltip was in the same place as the yellow box and obscuring part of it.

The problem lay with the TTN_SHOW notification that was sent by the tooltip to the toolbar window. The Microsoft documentation says, ambiguously, “This notification notifies the owner window that a ToolTip control is about to be displayed”.

Windows does this:

  1. Prepare the tooltip window, giving it the correct size and position.
  2. Send TTN_SHOW.
  3. Make the tooltip window visible.

Wine does this:

  1. Send TTN_SHOW.
  2. Prepare the tooltip window, giving it a size and position.
  3. Make the tooltip window visible.

This causes trouble for Cardbox. When Cardbox receives TTN_SHOW it asks the tooltip control for its size and position, and uses this information to decide where to put its yellow information box so that there is no interference. The bad screen display with Wine came about because the tooltip control didn’t have a size and position yet and so wasn’t taken into account when Cardbox was positioning its information box.

It was easy enough to get Cardbox to work round this (instead of handling TTN_SHOW directly, it posted a message to itself, which was processed after the tooltip had been made visible and given a size and position).

Nevertheless, this inconsistency between Wine and Windows is worth correcting in case other programs depend on the Windows behaviour. For example, Raymond Chen of Microsoft, in his Old New Thing blog, has a posting that refers to TTN_SHOW. He shows how a program can dynamically adjust the position of tooltips at the moment they are displayed. His technique can’t work if the tooltip resizes itself after TTN_SHOW has been processed, and many Windows programs are likely to be affected if Wine behaves the “wrong” (ie. non-Microsoft) way.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: