azlan has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have developed a software using Win32::GUI and I need to have my user to choose their desired language during the time when they login to the system. This will change not only the interface language but also the tooltip. I don't have any problem doing so for others but for the -tip I've never succeeded.

Example one of my button:

$MAIN->AddButton( -name => 'Load_3', -text => "Load file", -size => [100, $BH], -pos =>[$LM, 223], -tabstop => 1, -tip=> "Load your file here" );

I can have a function to directly change the -text but not the -tip. Have tried several ways but still failed. (Strangely it works only for Notifyicon) I have also tried using Win32::GUI::Tooltip, but I can't seams to make it working.

So can anyone please advise me the best way to do this.

Thanking you all in advance. :)

Regards, Azlan

Replies are listed 'Best First'.
Re: Need to dynamically change the -tip
by bobr (Monk) on Feb 25, 2010 at 09:40 UTC
    According to Win32::GUI::ToolTip:

    Tooltip controls are probably one of the most unintuitave of the Win32 controls when you first come accross them. A Tooltip control is a single window that supports one or more 'tools'. A tool is a window, or an area of a window that when the mouse hovers over, the tooltip window is displayed. The Tooltip is always a top level window (so don't try adding the WS_CHILD window style), and is typically owned by the top level window of your application/dialog.

    Create a tooltip window:

    my $tt = Win32::GUI::Tooltip->new( $main_window, );

    Add a tool to the tooltip:

    $tt->AddTool( -window => $main_window, -text => "Text that pops up", );

    and hover the mouse over an area of your main window.

    I just tested that you can call AddTool again to change tip message. You need to specify your button with $MAIN->Load_3, to get tooltip over your button.

    -- Roman

Re: Need to dynamically change the -tip
by Anonymous Monk on Feb 25, 2010 at 05:30 UTC
    Show your effort, preferably in a short self-contained and ready-to-run program :)
Re: Need to dynamically change the -tip
by azlan (Initiate) on Mar 06, 2010 at 01:34 UTC
    Thanks guys,

    I finally did it.

    $MAIN->AddButton( -name => 'Load_3', -text => "Load file", -size => [100, $BH], -pos =>[$LM, 223], -tabstop => 1, ); my $TIP = $MAIN->AddTooltip(); $TIP->AddTool(-text => 'Load your file here', -subclass => 1, -window => $MAIN->Load_3); $TIP->UpdateTipText($MAIN->Load_3,"Loading...");

    The original -tip set in the creation of the button have been removed and changed using the AddTool above. Otherwise the UpdateTipText above won't work.