BBC BASIC for Windows
Programming >> User Interface >> Tool Tips
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1490205058
Tool Tips
Post by KenDown on Mar 22nd, 2017, 5:50pm
I'm adapting a program I wrote to use UTF-8 text (Bulgarian, if you must know) and everything is working fine except that all the tool tips don't come up! I've torn my hair out over it and finally discovered that I - not, I hope, unnaturally - had used WinLib5U, which the documentation says is for UTF-8.
As soon as I changed it back to WinLib5A, the tool tips reappeared.
Is there any way of creating tool tips with 5U?
Re: Tool Tips
Post by DDRM on Mar 23rd, 2017, 08:52am
Hi KenDown,
As far as I can see the procedure for tooltips is in Winlib (not Winlib5), and there is a UTF version of that, too (WINLIBU). Did you change that, too, when you changed to UTF?
Best wishes,
D
Re: Tool Tips
Post by KenDown on Mar 23rd, 2017, 11:31am
Hmmmm. No, I didn't know about WinLibU and perhaps I will experiment with it. All I know is that the tool tips appear when I use WinLib5A and don't when I use 5U. Perhaps if I use both WinLibU and WinLib5U it will solve the problem?
I'll try it.
Re: Tool Tips
Post by KenDown on Mar 23rd, 2017, 11:37am
No, thanks for the suggestion, but it makes no difference. It continues to be that WinLib5A produces tool tips and WinLib5U somehow stops them appearing.
Re: Tool Tips
Post by DDRM on Mar 24th, 2017, 12:06pm
Hi KenDown,
So you aren't using Winlib at all?
As far as I can see, Winlib5A doesn't support tool tips. Did you make a modified version, by copying the relevant block out of Winlib?
Best wishes,
D
Re: Tool Tips
Post by KenDown on Mar 24th, 2017, 8:47pm
Oh yes, I'm using WinLib - in fact, after you kindly pointed out that there is a WinLibU, I have used that instead of the plain WinLib. I haven't noticed any difference anywhere else in the program and it didn't make any difference to the tooltips problem.
I shall shortly write a short program that does nothing else but create an icon and a tooltip and see if that is affected by WinLib5U. It is, I suppose, always possible that *I* have done something which mucks it up - can't think what, but there you are.
Re: Tool Tips
Post by KenDown on Mar 25th, 2017, 06:45am
So here's a short program that does nothing but display a dialog box. I'm not sure what WinLib does, but the program won't work without the FN_createwindow in WinLib5A.
Run the program and hover the mouse over the "OK" button to see a message. Change WINLIB5A to WINLIB5U and do the same. (The tooltips code is taken from the Wiki.)
PROCinit
*SYS 1
click%=0
ON SYS click%=FNsys(@msg%,@wparam%,@lparam%):RETURN
SYS"DragAcceptFiles",@hwnd%,1
REPEAT
pause%=INKEY(1)
CASEclick%OF
WHEN301:click%=0
PROC_closedialog(warn%)
ENDCASE
UNTIL!warn%=0
PROC_closedialog(warn%)
END
:
DEFFNsys(M%,W%,L%)
CASEM%OF
WHEN273:click%=W%AND&FFF
WHEN563:PROCdrag(W%,L%):click%=0
ENDCASE
=click%
:
DEFPROCdrag(W%,L%)
SYS"DragQueryFile",W%,-1,0,0TON%
IFN%=0ENDPROC
SYS"DragQueryFile",W%,I%,K%,255
PROCopen($$K%)
ENDPROC
:
DEFPROC_CreateToolTip(dlg%,htt%,id%,tip$)
tip$+=CHR$0
SYS"GetDlgItem",!dlg%,id%TOti.uId%
ti.cbSize%=DIM(ti{})
ti.uFlags%=17
ti.hwnd%=!dlg%
ti.lpszText%=!^tip$
SYS"SendMessage",htt%,1028,0,ti{}
ENDPROC
:
REM ===== Initialisation routines =====
:
DEFPROCinit
INSTALL @lib$+"WINLIB"
INSTALL @lib$+"WINLIB2"
INSTALL @lib$+"WINLIB5A"
REM Warn dialog box
warn%=FN_newdialog("Warning",80,0,80,60,10,10*50)
PROC_static(warn%,"",900,4,4,72,30,1)
PROC_pushbutton(warn%,"OK",901,14,36,46,12,1)
PROC_showdialog(warn%)
htt%=FN_createwindow(!warn%,"tooltips_class32","",0,0,0,0,0,&D0000003,0)
DIMti{cbSize%,uFlags%,hwnd%,uId%,rect{l%,t%,r%,b%},hinst%,lpszText%}
PROC_CreateToolTip(warn%,htt%,901,"Click to close")
ENDPROC
Re: Tool Tips
Post by DDRM on Mar 26th, 2017, 5:21pm
Hi KenDown,
OK, so you are providing the code for the tooltips separately. REMming out your install of WinLib doesn't seem to have any effect, so I suspect it isn't actually doing anything, which is why changing to WinLibU doesn't have any effect.
I suspect you will need to adapt your tooltip code to handle UTF-8. A quick look at the tooltip code in WinlibU suggests you may need to do two things:
1) Use SendMessageW instead of SendMessage (but making this amendment to your code doesn't solve the problem)
2) Convert your string into the right format with MultiByteToWideChar?
Hope that helps - it might be worth comparing the tooltip code in Winlib with that in WinlibU. failing that, try asking Richard on the other forum! I'm sure he'll sort it out instantly.
Best wishes,
D
Re: Tool Tips
Post by KenDown on Mar 26th, 2017, 6:08pm
The code is taken pretty much as a whole straight from the Wiki, so if it said to do things separately, that's why I'm doing them that way.
Anyway, thanks for your suggestions. I'll get round to trying them out in the next few days.
Much appreciated.