forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Multiline tooltips when using %th[ms_style]

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
mhudson



Joined: 05 Jan 2006
Posts: 18

PostPosted: Tue Feb 27, 2007 11:23 am    Post subject: Multiline tooltips when using %th[ms_style] Reply with quote

Hello,

I have lately been playing with using a graphics region on which I have drawn a grid of cells. I make use of full_mouse_input on %gr to link to a callback function that is used with the x and y coordinates of the mouse at any time to determine which cell the user is pointing at. My desire is to have a tooltip that can pop up when inside any cell to give some details that are specific to that cell's meaning.

I have managed to do this via set_tooltip_text@, and using %th with the ms_style option, as described in the %di section of the chm help file.

However, unlike with the usual use of %th in which I have often used a CHAR(10) to generate a newline character, I find that the use of the ms_style option has meant that I do not get multline tooltips. I have tried using CHAR(13), and a combination of the two, but this also does not work.

Does anyone have any suggestions as to how to get multiline tooltip text in this case? Or is this not possible?

Thanks,

Mark.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Feb 27, 2007 1:17 pm    Post subject: Reply with quote

Mark

Here are two things you could try but I am not hopeful

1) splice in CHAR(13)//CHAR(10)

2) use set_tooltip_text@ with the above.

It can be done using API calls but translating this into ClearWin+ would not be simple.
Back to top
View user's profile Send private message AIM Address
mhudson



Joined: 05 Jan 2006
Posts: 18

PostPosted: Tue Feb 27, 2007 2:28 pm    Post subject: tooltips question Reply with quote

Hi Paul,

I have indeed already tried CHAR(13)//CHAR(10) and even the other way around. These do not work.

However, a quick browse on the Web seems to indicate that using the message TTM_SETMAXTIPWIDTH can do the trick. This is usually, it seems, set to -1, in which case characters are printed rather than evaluated. Hence CHAR(10) and CHAR(13) won't work. However, if this is set to a positive value, the claim is that word wrap kicks in the these CR and LF chars are evaluated as desired.

TTM_SETMAXTIPWIDTH and some other tooltip messages do not appear to be defined in the include files with FTN95, but the main issue would be how to send the message in the first place. I can get the handle of the graphics region on which the tooltips will appear, but is that the right handle for the SendMessage subroutine?

Any ideas?

Mark.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Feb 27, 2007 3:44 pm    Post subject: Reply with quote

Yes it looks like you can use TTM_SETMAXTIPWIDTH.

In C it would look like this...

HWND hwndP=GetParent(hwnd);
HWND hwndTT=(HWND)GetWindowLong(hwndP,GWL_USERDATA);
if(hwndTT)
{
SendMessage(hwndTT,TTM_SETMAXTIPWIDTH,0,300);
}


where hwnd is the handle of the control given by %lc and 300 is the width of the tip in pixels (I guess).

You will need to use CHAR(13)//CHAR(10) in the text as well to get the line breaks at the right point.

I have not tested this but it is worth a try.
Back to top
View user's profile Send private message AIM Address
mhudson



Joined: 05 Jan 2006
Posts: 18

PostPosted: Wed Feb 28, 2007 11:44 am    Post subject: excellent! Reply with quote

Hi Paul,

This worked very nicely, thanks. The only remaining issue is that the tooltip is always visible, and follows the mouse around, updating as it goes. I have got around this by introducing my own code to make the tip appear when the mouse is moved in a certain way, but if you have any comments, I would be glad to hear them.

In case anyone else is watching, here are some bits of code that were used to get the tip updating and having multi-line capability:

Assuming that %th[ms_style] has been used at some point and that we have a help string attached to a graphics region...:

I used %lc after creating the graphics region, so as to get the region's handle:

Code:

i = winio@('%`^?gr[white,rgb_colours,flush,full_mouse_input]@&', &
         & width,height,         &
         & MainGraphicsHdl,GRCallback,infostr)

i = winio@('%lc&',GraphicsControlHdl)


Then, whenever I am about to set the tooltip text, according to where on the graphics region I am pointing, I do the following:

Code:

HwndP = GetParent(GraphicsControlHdl)
ToolTipHdl = GetWindowLong(HwndP,GWL_USERDATA)

if (ToolTipHdl /= 0) then
  call SendMessage(ToolTipHdl,TTM_SETMAXTIPWIDTH,0,500) ! maximum of 500 pixels wide
  call SendMessage(ToolTipHdl,TTM_SETTIPBKCOLOR,RGB@(255,255,128),0)! pale yellow background
  call SendMessage(ToolTipHdl,TTM_SETDELAYTIME,TTDT_AUTOPOP,10000) ! make tooltip stay visible for 10 secs if mouse stationary
 
  call set_tooltip_text@(GraphicsControlHdl,trim(infostr))
end if


Not all of this is necessary, of course. I set the background and autopop values, too, just for playing-around's sake.

One small point: the constants that are used in the send message routine are not defined in the MSWIN module, so I have set them up as parameters:

Code:

integer, parameter :: TTM_SETMAXTIPWIDTH = 1048, TTM_SETTIPBKCOLOR = 1043, TTM_SETTIPTEXTCOLOR = 1044
integer, parameter :: TTM_GETTIPBKCOLOR = 1046
integer, parameter :: TTM_SETDELAYTIME = 1027
integer, parameter :: TTDT_AUTOPOP = 2


Thanks for the help.

Could you provide brief explanation as to why one gets the tooltip handle using GWL_USERDATA?

Mark.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Wed Feb 28, 2007 1:17 pm    Post subject: Reply with quote

>> Could you provide brief explanation as to why one gets the tooltip handle using GWL_USERDATA?

This is just from the inner workings of ClearWin+ (i.e. the place I chose to store the handle). Since this works, I ought to provide a routine like set_tooltip_text@ to set the width.
Back to top
View user's profile Send private message AIM Address
mhudson



Joined: 05 Jan 2006
Posts: 18

PostPosted: Wed Feb 28, 2007 1:23 pm    Post subject: Reply with quote

>> This is just from the inner workings of ClearWin+ (i.e. the place I chose to store the handle). Since this works, I ought to provide a routine like set_tooltip_text@ to set the width.

I did wonder if that were the case - the GWL_USERDATA attribute looked as though it were a bit like a VB "tag" into which one can store anything one wants.

If you do create a new subroutine to do this width manipulation, that would be cool. But, in any case, finding out about this has led me to get a better understanding of the use of API calls from within FTN95/Clearwin code, which is always useful.

And now that I know how to get the tooltip handle, I can play around with various things to my heart's content.

Thanks again,

Mark.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group