Re: [win32gui] [perl-win32-gui-users] Tooltip once again
Robert May wrote: The example attached shows a couple of ways of setting the tools for a tooltip control and a couple of ways of setting the text. I haven't the time to look at a tracking example right now but here's the basic principle: (1) Add the tool to the tooltip control with the TTF_TRACK and TTF_ABSOLUTE options (-track => 1, -absolute => 1). You won't need to -subclass => 1 option due to (2) and (3) below. (2) Your application become responsible for when to display and hide the tooltip, using the TrackActivate() method. (3) Your application becomes responsible for setting the tooltip position with the TrackPosition() method (probably in a mouse move handler) You can read all about tooltips and their related tools on msdn at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/tooltip/reflist.asp In the example provided, and all my further tests, using the subclass option provides inaccurate location for the automated placement. Try moving the window down a ways. You will find you need to expand the window. It looks like the subclass option is using screen x,y vs where it should be using window x,y. More likely the conversion was not realized somewhere in the code, as I doubt anyone did this intentionally. And I hate to be a pain, but I can't get my head around how to use the TrackActivate and TrackPosition methods appropriately.
Re: [win32gui] [perl-win32-gui-users] Tooltip once again
Jason P. wrote: Robert May wrote: In the example provided, and all my further tests, using the subclass option provides inaccurate location for the automated placement. Try moving the window down a ways. You will find you need to expand the window. It looks like the subclass option is using screen x,y vs where it should be using window x,y. More likely the conversion was not realized somewhere in the code, as I doubt anyone did this intentionally. I noticed this (and the report in your earlier post of the tooltip window appearing under the textfield), but didn't have time to investigate yesterday. It turns out that the co-ordinates are bing sent correctly, but that the control is being created incorrectly as a child winodow (hence expects its co-ordinates relative to it's parent's client area) when it should be a top-level owned window. I've raised a tracker, and will fix in the next release. And I hate to be a pain, but I can't get my head around how to use the TrackActivate and TrackPosition methods appropriately. OK, as I was interested in seeing this work too, here's an example. There may well be easier ways to achieve this. Rob. #!perl -w use strict; use warnings; use Win32::GUI; sub TME_LEAVE() {2}; sub OFFSET_X() {16}; sub OFFSET_Y() {16}; my $mw = Win32::GUI::Window->new( -name => "MW", -title => "Tracking Tooltip", -size => [400,300], -onMouseMove => \&displayTooltip, -onMouseOut => \&hideTooltip, ) or die "Failed to create MW"; my $tip = Win32::GUI::Tooltip->new( $mw, -name => "TT", -pushexstyle => WS_EX_TOPMOST, # You might get away without this ) or die "Failed to create TT"; # Add a tool, specifying id and a client area # rectangle $tip->AddTool( -text => "", -id => 1001, -rect => [ $mw->GetClientRect() ], -track => 1, -absolute => 1, ); $mw->Show(); Win32::GUI::Dialog(); exit(0); sub displayTooltip { my ($win, $cx, $cy) = @_; # x,y in client co-ordinates # Take into account that client co-ordinates can be negative, # the need to do this will go when tracker 1262098 is fixed $cx -= 65536 if $cx > 32767; $cy -= 65536 if $cy > 32767; # convert pos to screen co-ordinates my ($sx, $sy) = $win->ClientToScreen($cx, $cy); # Update the tip text to the co-ordinates of the mouse $win->{TT}->UpdateTipText(1001,"Screen:$sx,$sy Client:$cx,$cy"); # Update tooltip position to an offset from the mouse position $win->{TT}->TrackPosition($cx + OFFSET_X, $cy + OFFSET_Y); # TODO: will need to be $sx, $sy when tracker # 1273134 is fixed # Show the tooltip $win->{TT}->TrackActivate(1001,1); # Set up mouse tracking so we get an onMouseOut event when we # leave the window $win->TrackMouse(0, TME_LEAVE); return; } sub hideTooltip { my ($win) = @_; # Hide the tooltip $win->{TT}->TrackActivate(1001,0); return; }
Re: [win32gui] [perl-win32-gui-users] Tooltip once again
hey Rob, that helped me a whole lot - both of your examples.. thanks! :) I think this offset issue prevented me from seeing the tips in the first place, because I was working with a centered main window... one question though: is it possible to have the tips being showed also outside of my main-window (f.e. if the mouse is near the windowboarder)? Also when working with the WM_HELP msg - there is all the info available inside the passed HELPINFO structure within lParam. things like iCtrlId, hItemHandle, dwContextId and POINT struct with cursor pos So I have to learn pack and unpack on c-structs very soon - your example from the "DC used for customdrawn Toolbar" discussion put me on that track.. ;) thanks again, Dominik
Re: [win32gui] [perl-win32-gui-users] Tooltip once again
Dominik wrote: one question though: is it possible to have the tips being showed also outside of my main-window (f.e. if the mouse is near the windowboarder)? You'll get that with the fix to the creation styles that I just put into CVS. Currently the addition of the WS_CHILD style to the tooltip control results it it getting clipped to its parent window. Without this style it will be a true top-level window and can be drawn anywhere on the screen. If you need it now, and can build from source, then grab the latest code from CVS. If this is not an option, then you'll have to wait for V1.03. Also when working with the WM_HELP msg - there is all the info available inside the passed HELPINFO structure within lParam. things like iCtrlId, hItemHandle, dwContextId and POINT struct with cursor pos So I have to learn pack and unpack on c-structs very soon - your example from the "DC used for customdrawn Toolbar" discussion put me on that track.. ;) If you think it would be useful to have native support for WM_HELP messages, then please raise an RFE tracker. Good luck! Rob.
[perl-win32-gui-users] Textfield - insert at cursor
Is there a way with a textfield to insert text at the current cursor position? The cursor may be anywhere in the existing text Thanks, Steve